/* Web admin design tokens ("the labelled shelf"; docs/admin-ui-audit.md §7).
   Loaded only by admin pages (base.html, login.html), before webadmin.css.
   Everything is prefixed --st- so it can't collide with the landing page. */

/* Cascade layers, lowest first. webadmin.css is the low "legacy" layer (page
   basics and older rules); component and page styles go in the later layers,
   so they win over it without specificity fights. */
@layer tokens, base, legacy, components, pages;

/* ---------- fonts ----------
   Copies of the landing page's self-hosted brand fonts (SIL Open Font License,
   see fonts/OFL-*.txt). "Familjen Fallback" is Arial scaled to Familjen
   Grotesk's metrics, so text doesn't jump when the real font arrives. */

@font-face {
  font-family: "Familjen Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/familjen-grotesk-latin.c5d0fcda30d9.woff2") format("woff2");
  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: "Familjen Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/familjen-grotesk-latin-ext.1df2b918923e.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 75% 112.5%;
  font-display: swap;
  src: url("fonts/martian-mono-latin.9fc94a3d1ad7.woff2") format("woff2");
  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: "Martian Mono";
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 75% 112.5%;
  font-display: swap;
  src: url("fonts/martian-mono-latin-ext.be309b3ebb4c.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Familjen Fallback";
  font-weight: 400 600;
  src: local("Arial"), local("ArialMT");
  size-adjust: 94.5%;
  ascent-override: 108.5%;
  descent-override: 23.8%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Familjen Fallback";
  font-weight: 700;
  src: local("Arial Bold"), local("Arial-BoldMT");
  size-adjust: 92.2%;
  ascent-override: 111.2%;
  descent-override: 24.4%;
  line-gap-override: 0%;
}

@layer tokens {
  :root {
    color-scheme: light dark;

    /* Colour: neutrals (warm, faintly brown, matching the phone theme). */
    --st-canvas: #f5f2ee;          /* page background */
    --st-surface: #fcfbfa;         /* cards, tables, inputs */
    --st-surface-sunken: #ece7e1;  /* table header, hover row, code wells */
    --st-ink: #211c18;             /* text */
    --st-ink-muted: #5f564e;       /* secondary text */
    --st-line: #ddd6ce;            /* decorative dividers only */
    --st-field: #8a8077;           /* input and checkbox borders (3:1) */

    /* Colour: brand and status */
    --st-accent: #6f5345;
    --st-accent-hover: #5a4337;
    --st-accent-soft: #ebe7e4;
    --st-on-accent: #ffffff;
    --st-danger: #b42318;
    --st-danger-soft: #fdecea;
    --st-warning-ink: #7a4b00;
    --st-warning-soft: #fdf1d8;
    --st-success-ink: #1d6b45;
    --st-success-soft: #e3f3ea;
    --st-tape: #ffffff;            /* code chip ("label tape") */
    --st-tape-ink: #211c18;        /* stays dark: the tape is light in both themes */
    --st-tape-edge: rgb(33 28 24 / 0.18);
    --st-focus: var(--st-accent);

    /* Colour: charts (categorical, in this order; checked for colour
       blindness and contrast on --st-surface, light and dark) and the
       Overview's health levels (always shown with an icon and a word). */
    --st-chart-1: #2F6FA8;
    --st-chart-2: #C4622D;
    --st-chart-3: #1E8A6E;
    --st-chart-4: #A87A00;
    --st-chart-5: #B04F7E;
    --st-chart-6: #5B4BA0;
    --st-good: #2E7D45;
    --st-good-soft: #e3f1e7;
    --st-fair: #B07400;
    --st-fair-soft: #f8edd6;
    --st-poor: #C0392B;
    --st-poor-soft: #f8e1de;

    /* Type */
    --st-font: "Familjen Grotesk", "Familjen Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --st-font-code: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --st-text-xs: 0.75rem;
    --st-text-sm: 0.875rem;
    --st-text-md: 1rem;
    --st-text-lg: 1.25rem;
    --st-text-xl: 1.625rem;
    --st-leading-body: 1.5;
    --st-leading-tight: 1.2;
    --st-weight-regular: 400;
    --st-weight-medium: 500;
    --st-weight-bold: 650;

    /* Space: 4 px base */
    --st-space-1: 0.25rem;
    --st-space-2: 0.5rem;
    --st-space-3: 0.75rem;
    --st-space-4: 1rem;
    --st-space-5: 1.5rem;
    --st-space-6: 2rem;
    --st-space-7: 3rem;
    --st-space-8: 4rem;

    /* Shape */
    --st-radius-sm: 6px;
    --st-radius-md: 10px;
    --st-radius-lg: 14px;
    --st-radius-pill: 999px;

    /* Depth: only for things that float */
    --st-shadow-menu: 0 8px 24px -8px rgb(40 30 22 / 0.22);
    --st-shadow-dialog: 0 24px 48px -16px rgb(40 30 22 / 0.32);

    /* Sizing */
    --st-control-h: 2.75rem;
    --st-content-max: 72rem;

    /* Motion */
    --st-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --st-duration: 180ms;

    /* Layers */
    --st-z-sticky: 10;
    --st-z-menu: 20;
    --st-z-dialog: 30;
    --st-z-toast: 40;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --st-canvas: #24211e;
      --st-surface: #2e2b28;
      --st-surface-sunken: #1b1916;
      --st-ink: #ede8e2;
      --st-ink-muted: #b3a99f;
      --st-line: #433e3a;
      --st-field: #7d736a;
      --st-accent: #b89784;
      --st-accent-hover: #c9ab9a;
      --st-accent-soft: #473e39;
      --st-on-accent: #1d1814;
      --st-danger: #ff8f80;
      --st-danger-soft: #3b1b18;
      --st-warning-ink: #f5c76b;
      --st-warning-soft: #3a2d12;
      --st-success-ink: #7fd8a6;
      --st-success-soft: #16362a;
      --st-tape: #e9e5db;
      --st-tape-edge: rgb(0 0 0 / 0.4);
      --st-chart-1: #4F8CCB;
      --st-chart-2: #D06B36;
      --st-chart-3: #2A9C7C;
      --st-chart-4: #B98E12;
      --st-chart-5: #CC5F87;
      --st-chart-6: #7A6CD0;
      --st-good: #4FAE6C;
      --st-good-soft: #1f3a29;
      --st-fair: #D69A2A;
      --st-fair-soft: #3d3016;
      --st-poor: #E2675B;
      --st-poor-soft: #452420;
    }
  }

  @media (min-width: 1024px) {
    :root { --st-control-h: 2.5rem; }
  }

  @media (prefers-reduced-motion: reduce) {
    :root { --st-duration: 0ms; }
  }
}

/* Breakpoints (media queries can't read custom properties), min-width,
   mobile-first: sm 480px, md 768px, lg 1024px, xl 1280px. */

@layer base {
  /* Always wins (important in the lowest layer beats every later layer), so a
     component's own `display` can never show something marked hidden. */
  [hidden] { display: none !important; }

  input[type=checkbox], input[type=radio] { accent-color: var(--st-accent); }

  /* Codes are what people print and stick on boxes: they get the brand mono. */
  code, kbd, samp, pre {
    font-family: var(--st-font-code);
    font-stretch: 87.5%;
    font-size: 0.875em;
  }

  h3 { font-size: var(--st-text-md); }

  main:focus { outline: none; }
}

/* Reduced motion: components animate with var(--st-duration), which is 0ms
   then; the import spinner keeps its own slower spin (webadmin.css). */
