/*
 * Variant A, Swiss Grammar (spec 5.5, docs/design/a-swiss-grammar/): tokens and base type.
 * One grid, one red, one sentence. Red (--signal) only ever marks grammar: brackets, S/V/O,
 * tag leaders and the full stop. It never paints a link, a button or an ornament.
 * Files, in cascade order (VARIANTS.a.css): site → layout → marks → hero → anatomy → sections
 * → results → news → contact.
 */

:root {
  color-scheme: light dark;

  /* Palette. On paper the signal is 3.4:1, so there it marks and never carries body text;
     on night it is 5.5:1 and may. */
  --paper: #F2F2EF;
  --ink: #0D0D0D;
  --signal: #FF3B14;
  --mute: #5E5E5A; /* secondary text on paper, 5.9:1 */
  --night: #0B0B0B;
  --night-text: #F2F2EF;
  --night-mute: #94948F; /* secondary text on night, 6.6:1 */
  --recede: #B9B9B4; /* modifiers stepping back, on night */

  /* Roles that change with the scheme. */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-mute: var(--mute);
  --rule: var(--ink);
  --hair: rgb(13 13 13 / 0.22);
  --guide: rgb(13 13 13 / 0.1); /* visible column lines */
  --focus: var(--ink);
  --faint: #9C9C97; /* decorative indices only (inside [data-decorative]) */

  /* The lens is the other ground: night on paper, paper on night. */
  --lens-bg: var(--night);
  --lens-fg: var(--night-text);
  --lens-recede: var(--recede);
  --lens-mute: var(--night-mute);
  --lens-guide: rgb(242 242 239 / 0.1);

  /* The darkroom (#anatomy) is night in both schemes. */
  --room-bg: var(--night);
  --room-fg: var(--night-text);
  --room-mute: var(--night-mute);
  --room-guide: rgb(242 242 239 / 0.085);
  --room-hair: rgb(242 242 239 / 0.28);

  /* Map roads, and the crop marks around the lens (corners of an 18px border-image slice). */
  --road: rgb(13 13 13 / 0.09);
  --crop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='54' height='54' fill='none' stroke='%230D0D0D'%3E%3Cpath d='M17.5 0V18M0 17.5H18M36.5 0V18M36 17.5H54M17.5 36V54M0 36.5H18M36.5 36V54M36 36.5H54'/%3E%3C/svg%3E");

  /* Type: Pretendard for Korean, Archivo (one family, many widths) for English, Fragment Mono
     for indices and labels (its Hangul falls back to Pretendard). */
  --font-ko: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-en: Archivo, var(--font-ko);
  --font-mono: "Fragment Mono", var(--font-ko), ui-monospace, monospace;

  /* Grid: no gutters, the column lines are the gutters; text sits --pad inside a line.
     --col is one column of the content width (main is the size container), --row the wall row. */
  --cols: 6;
  --m: 16px;
  --pad: 8px;
  --col: calc((100cqi - 2 * var(--m)) / var(--cols));
  --row: 36px;
  --head: 44px;
  /* The contact bar's height (phones and tablets; it is gone from 1200px). */
  --bar: 56px;
}

@media (min-width: 768px) {
  :root {
    --cols: 12;
    --m: 24px;
    --pad: 10px;
    --row: 40px;
    --head: 52px;
  }
}

@media (min-width: 1200px) {
  :root {
    --m: 32px;
    --row: 44px;
  }
}

/* Dark is its own night palette, not an inversion: the lens turns to a band of light. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--night);
    --fg: var(--night-text);
    --fg-mute: var(--night-mute);
    --rule: var(--night-text);
    --hair: rgb(242 242 239 / 0.22);
    --guide: rgb(242 242 239 / 0.085);
    --focus: var(--night-text);
    --faint: #5F5F5B;
    --lens-bg: var(--paper);
    --lens-fg: var(--ink);
    --lens-recede: var(--mute);
    --lens-mute: var(--mute);
    --lens-guide: rgb(13 13 13 / 0.1);
    --room-bg: #000;
    --road: rgb(242 242 239 / 0.12);
    --crop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='54' height='54' fill='none' stroke='%23F2F2EF'%3E%3Cpath d='M17.5 0V18M0 17.5H18M36.5 0V18M36 17.5H54M17.5 36V54M0 36.5H18M36.5 36V54M36 36.5H54'/%3E%3C/svg%3E");
  }
}

/* Word indices: W001, W002, … */
@counter-style w3 {
  system: extends decimal;
  pad: 3 "0";
}

/* Whatever scrolls into view (a focused link, an anchor) clears the running head, and below 1200px
   the contact bar too (WCAG 2.4.11). */
html {
  scroll-padding-top: var(--head);
  scroll-padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom, 0px) + 1rem);
}

@media (min-width: 1200px) {
  html {
    scroll-padding-bottom: 0;
  }
}

body {
  font-family: var(--font-ko);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--fg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Size container for --col, so the grid math ignores the scrollbar. Fixed layers live outside main. */
main {
  container-type: inline-size;
}

[lang="en"] {
  font-family: var(--font-en);
}

ol,
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

figure {
  margin: 0;
}

address {
  font-style: normal;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

/* Focused skip link (shared/base.css positions it): an ink block in the corner. */
.skip-link {
  margin: 8px;
  padding: 0.75rem 1rem;
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.2;
  text-decoration: none;
}
