/* InterImm kit: the shared look of every InterImm site.

   Source of truth: InterImm/interimm.github.io (branch `hugo`), assets/kit/.
   Published at https://interimm.org/kit/interimm.css with its fonts and
   https://interimm.org/kit/interimm.js. Other sites link those URLs instead of
   copying them, so they pick up changes automatically. See kit/README.md.

   The idea: every page is a public document of the Interplanetary Immigration
   Center. Paper and ink, serif headings, thin rules, one Mars-rust colour, and
   one live element (the signal line under the header) that always knows how far
   away Mars is. Colours are tokens on :root and follow the visitor's light or
   dark setting. Keep changes additive: other sites depend on these class names. */

/* ---------- fonts (self-hosted, SIL OFL; see static/kit/fonts) ---------- */
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-italic.woff2") format("woff2");
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-2199;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-2199;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;

  --bg: #f5f5f1;            /* paper */
  --bg-alt: #efeee8;
  --surface: #fbfbf8;
  --surface-2: #efeee8;
  --text: #17171a;          /* ink */
  --muted: #64635d;
  --border: #dddcd4;        /* rules */
  --border-strong: #17171a;
  --link: #17171a;
  --focus: #b0441c;
  --accent: #b0441c;        /* Mars rust, used sparingly */
  --accent-hover: #93381a;
  --accent-text: #ffffff;
  --accent-soft: rgb(176 68 28 / 0.08);
  --shadow: 0 1px 2px rgb(23 23 26 / 0.04), 0 12px 32px rgb(23 23 26 / 0.06);

  --radius: 0.25rem;
  --wrap: 74rem;
  --measure: 40rem;
  --cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC";
  --cjk-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "SimSun";
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, var(--cjk), sans-serif, var(--emoji);
  --font-serif: "Source Serif 4", Georgia, var(--cjk-serif), serif;
  --font-display: var(--font-serif);
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, var(--cjk), monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --bg-alt: #19191c;
    --surface: #1b1b1e;
    --surface-2: #232327;
    --text: #ebeae4;
    --muted: #9b9a93;
    --border: #2d2d31;
    --border-strong: #ebeae4;
    --link: #ebeae4;
    --focus: #e27a50;
    --accent: #e27a50;
    --accent-hover: #ec916c;
    --accent-text: #1c0700;
    --accent-soft: rgb(226 122 80 / 0.12);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 16px 40px rgb(0 0 0 / 0.3);
  }
  .brand-mark { filter: invert(1); }
}

/* `.space` used to be an always-dark starfield band. It is now a quiet header
   band on paper, kept so pages that use it still get the right spacing. */
.space { position: relative; color: var(--text); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }

h1, h2, h3 {
  font-family: var(--font-display); font-weight: 400;
  line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.6em; text-wrap: balance;
}
:lang(zh) :is(h1, h2, h3), :is(h1, h2, h3):lang(zh) { letter-spacing: 0.02em; }
p { margin: 0 0 1em; text-wrap: pretty; }
img, video, svg { max-width: 100%; height: auto; }
a {
  color: var(--link);
  text-decoration-line: underline; text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.15s, color 0.15s;
}
a:hover { text-decoration-color: currentColor; }
ul, ol { margin: 0 0 1em; }
::selection { background: var(--accent); color: var(--accent-text); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  padding: 0.6rem 1rem; background: var(--text); color: var(--bg); font-weight: 500; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.text-center { text-align: center; }
.prose .text-center { text-align: start; }

/* Small uppercase label in the mono face: section names, metadata, captions. */
.kicker {
  display: block; margin: 0 0 1rem;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 400;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.kicker:lang(zh), :lang(zh) .kicker { letter-spacing: 0.12em; }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.pulse { display: none; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.icon-emoji { display: inline-grid; place-items: center; font-size: 1.1rem; line-height: 1; }

/* ---------- header ---------- */
.site-header { position: relative; z-index: 50; background: var(--bg); }
.header-inner { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 2rem; min-height: 4.75rem; padding-block: 1rem; }

.brand {
  display: inline-flex; align-items: center; gap: 0.75rem;
  font-family: var(--font-serif); font-weight: 400; font-size: 1.125rem; line-height: 1.2;
  color: var(--text); text-decoration: none;
}
.brand-mark { flex: none; width: 2.25rem; height: 2.25rem; }
.brand-name { display: flex; flex-direction: column; }
.brand-sub { margin-top: 0.2rem; line-height: 1.2; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.site-nav { display: flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.25rem 1.5rem; }
.nav-list { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 1.25rem; list-style: none; margin: 0; padding: 0; }

.nav-link, .dropdown > summary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0; color: var(--muted); font-size: 0.9375rem; font-weight: 400; text-decoration: none; cursor: pointer;
  transition: color 0.15s;
}
.nav-link:hover, .dropdown > summary:hover, .dropdown[open] > summary { color: var(--text); }
.nav-link[aria-current="page"], .dropdown[data-current] > summary { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.5em; }
.lang-link { color: var(--text); }
.nav-tools .nav-link svg { width: 1rem; height: 1rem; }

.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::after {
  content: ""; width: 0.3em; height: 0.3em; margin-top: -0.2em;
  border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg);
}
.dropdown-menu {
  position: absolute; top: calc(100% + 0.6rem); left: -1rem; z-index: 60;
  min-width: min(19rem, 90vw); margin: 0; padding: 0.5rem 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.dropdown-menu a {
  display: block; padding: 0.45rem 1rem;
  color: var(--text); font-size: 0.9375rem; text-decoration: none;
}
.dropdown-menu a:hover { background: var(--surface-2); }
.dropdown-menu a[aria-current="page"] { color: var(--accent); }

.nav-toggle {
  display: none; margin-left: auto; padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: transparent; color: var(--text); cursor: pointer;
}

@media (max-width: 58rem) {
  /* brand and menu button stay on one row; a long name truncates instead of pushing the button down */
  .header-inner { gap: 0.5rem 0.75rem; min-height: 0; padding-block: 0.6rem; }
  .header-inner > .brand { flex: 1 1 0; min-width: 0; }
  .header-inner > .brand .brand-name { min-width: 0; }
  .header-inner > .brand .brand-name, .header-inner > .brand .brand-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-toggle { flex: none; }
  .js .nav-toggle { display: inline-flex; }
  .js .site-nav { display: none; flex-basis: 100%; padding-bottom: 0.75rem; }
  .js .site-nav.is-open { display: flex; flex-direction: column; align-items: stretch; }
  .nav-list { flex-direction: column; align-items: stretch; }
  .nav-link, .dropdown > summary { padding: 0.55rem 0; font-size: 1rem; border-bottom: 1px solid var(--border); width: 100%; }
  .nav-tools { flex-direction: row; flex-wrap: wrap; gap: 0 1.5rem; padding-top: 0.25rem; }
  .nav-tools .nav-link { width: auto; border-bottom: 0; }
  .dropdown-menu { position: static; min-width: 0; margin: 0 0 0.5rem; padding: 0.25rem 0; border: 0; box-shadow: none; background: transparent; }
  .dropdown-menu a { padding-inline: 1rem 0; }
}

/* ---------- signal line: distance, delay and Mars time, filled by interimm.js ---------- */
.signal { border-block: 1px solid var(--border); color: var(--muted); }
.signal-inner {
  display: flex; flex-wrap: wrap; gap: 0.2rem 2rem; padding-block: 0.6rem;
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
}
.signal b { font-weight: 500; color: var(--text); }
.signal-item:first-child::before {
  content: ""; display: inline-block; width: 0.4rem; height: 0.4rem; margin-right: 0.55rem;
  border-radius: 50%; background: var(--accent); vertical-align: 0.08em;
}
@media (max-width: 30rem) { .signal-inner { gap: 0.1rem 1.25rem; font-size: 0.72rem; } }

/* ---------- buttons, chips, links ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6ch;
  padding: 0.55rem 1.1rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: transparent; color: var(--text); font: inherit; font-size: 0.9375rem; font-weight: 500; line-height: 1.4;
  white-space: nowrap; text-decoration: none; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--text); color: var(--bg); }
.btn span { transition: transform 0.15s; }
.btn:hover span { transform: translateX(3px); }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-ghost { border-color: var(--border); }
.btn-ghost:hover { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0 0 1.25rem; padding: 0; }
.chips li { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chips li:lang(zh), :lang(zh) .chips li { letter-spacing: 0.1em; }
.chips-small li { font-size: 0.7rem; }

.text-link { color: var(--text); font-weight: 500; text-decoration: none; border-bottom: 1px solid var(--border-strong); padding-bottom: 0.1rem; }
.text-link span { display: inline-block; transition: transform 0.15s; }
.text-link:hover { color: var(--accent); border-color: var(--accent); }
.text-link:hover span { transform: translateX(3px); }

/* ---------- sections ---------- */
.section { padding-block: clamp(3rem, 7vw, 5.5rem); }
.section + .section, .section-alt { border-top: 1px solid var(--border); }
.section-head { margin-bottom: clamp(1.75rem, 4vw, 2.5rem); }
.section-head-split { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem 2rem; }
.section-title { font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem); line-height: 1.12; margin-bottom: 0.4rem; }
.section-lede { max-width: var(--measure); margin: 0; color: var(--muted); font-size: 1.0625rem; }

/* A side label column and a main column, the document grid. */
.doc-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem 2rem; }
.doc-side { grid-column: span 3; }
.doc-main { grid-column: span 9; min-width: 0; }
@media (max-width: 52rem) { .doc-side, .doc-main { grid-column: 1 / -1; } }

/* tiles (archives and tools): an index of entries divided by rules */
.bento { display: grid; gap: 0 2.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); border-top: 1px solid var(--border); }
.tile {
  position: relative; display: flex; flex-direction: column;
  padding: 1.5rem 0 1.25rem; border-bottom: 1px solid var(--border);
}
.tile > :last-child { margin-bottom: 0; }
.tile-icon { display: inline-flex; margin-bottom: 0.9rem; color: var(--accent); }
.tile-title { font-size: 1.3rem; line-height: 1.25; margin-bottom: 0.4rem; }
.tile p { color: var(--muted); font-size: 0.97rem; }
.tile .card-cta { color: var(--text); }

/* generic cards (inner pages): a framed surface for forms, results and longer content */
.card-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column;
  padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card > :last-child { margin-bottom: 0; }
.card-title { font-size: 1.35rem; line-height: 1.25; margin-bottom: 0.5rem; }
.card-cta { margin: auto 0 0; padding-top: 0.75rem; color: var(--text); font-size: 0.9rem; font-weight: 500; }
.card-cta span { display: inline-block; color: var(--accent); transition: transform 0.15s; }
.card-wide { max-width: 54rem; margin-inline: auto; width: 100%; }

/* whole card is clickable through its title link */
.card-link-wrap { transition: border-color 0.2s; }
.card-link-wrap:hover .card-cta span { transform: translateX(4px); }
.card-link-wrap:hover .card-link { text-decoration: underline; text-decoration-color: var(--border-strong); }
.card.card-link-wrap:hover { border-color: var(--border-strong); }
.card-link { color: var(--text); text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 3px; }

.card-media { padding: 0; overflow: hidden; }
.card-media .card-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-alt); border-bottom: 1px solid var(--border); }
.card-media .card-body { padding: 1.25rem 1.5rem 1.5rem; }

.stack { display: grid; gap: 1.5rem; }

/* Figures are shown as plates: the image on white, a caption below. */
.figure, .plate { margin: 1rem 0 0; }
.figure { padding: clamp(0.75rem, 3vw, 1.5rem); background: #fff; border: 1px solid var(--border); text-align: center; }
.figure img { max-height: 32rem; width: auto; margin-inline: auto; }
.plate-frame { background: #fff; border: 1px solid var(--border); padding: clamp(0.75rem, 3vw, 2rem); }
.plate-frame img { display: block; width: 100%; height: auto; margin-inline: auto; }
.plate figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 2rem; margin-top: 0.75rem; color: var(--muted); font-size: 0.875rem; }

/* A record's metadata: label over value, ruled. */
.meta-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin: 2.5rem 0 0; border-top: 1px solid var(--border-strong); }
.meta-list > div { padding: 0.875rem 1.25rem 0.875rem 0; border-bottom: 1px solid var(--border); }
.meta-list dt { margin-bottom: 0.25rem; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.meta-list dd { margin: 0; }

/* ---------- inner pages ---------- */
.page-hero { padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2rem, 5vw, 3rem); }
.page-hero h1 { font-size: clamp(2.5rem, 1.4rem + 4vw, 4.5rem); font-weight: 300; line-height: 1.04; letter-spacing: -0.02em; margin-bottom: 0.35em; max-width: 20ch; }
.page-hero h1:lang(zh), :lang(zh) .page-hero h1 { font-weight: 400; letter-spacing: 0.04em; line-height: 1.15; }
.page-hero .lede { max-width: var(--measure); margin: 0 0 1rem; color: var(--muted); font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem); }
.page-hero .chips { margin: 1.5rem 0 0; }
.crumbs { margin: 0 0 1.75rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }

.prose { max-width: var(--measure); }
.prose > * { margin-inline: 0; }
.prose p, .prose li { font-family: var(--font-serif); font-size: 1.1875rem; line-height: 1.8; }
.prose :is(p, li):lang(zh), :lang(zh) .prose :is(p, li) { font-size: 1.125rem; line-height: 2; letter-spacing: 0.02em; }
.prose h2 { margin-top: 2em; font-size: 1.75rem; }
.prose h3 { margin-top: 1.6em; font-size: 1.3rem; }
.prose img, .prose video { display: block; }
.prose-wide { max-width: 66rem; }
.prose-wide > p, .prose-wide > h2, .prose-wide > h3, .prose-wide > ul, .prose-wide > ol { max-width: var(--measure); }
/* A page body inside .wrap lines up with the page header: text keeps the
   reading measure, figures and embeds use the full width. */
.wrap.prose { max-width: none; }
.wrap.prose > :is(p, h2, h3, h4, ul, ol, blockquote, dl) { max-width: var(--measure); }
:lang(zh) { line-height: 1.85; }

/* ---------- footer ---------- */
.site-footer { padding-block: 3rem 1.75rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.footer-brand { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 2rem; }
.footer-brand .kicker { margin: 0; }
.footer-grid { display: grid; gap: 2rem 3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); padding-top: 2rem; border-top: 1px solid var(--border); }
.footer-col h2 { margin-bottom: 0.8rem; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.footer-col p { max-width: 24rem; }
.footer-col ul { margin: 0; padding: 0; list-style: none; }
.footer-col li { margin-bottom: 0.3rem; }
.footer-col a { color: var(--muted); text-decoration: none; }
.footer-col a:hover { color: var(--text); text-decoration: underline; }
.footer-legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.75rem; }
.footer-legal a { color: var(--muted); text-decoration: none; }
.footer-legal a:hover { color: var(--text); }
.footer-legal-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }

/* ---------- motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .site-footer, .skip-link, .signal { display: none; }
  body { background: #fff; color: #000; }
}
