/* css/layers.css */
/* Cascade layer order for the overhaul.
 *
 * `legacy` comes early on purpose: it holds the pre-overhaul stylesheet, and every layer declared after it wins without
 * needing `!important`. That turns the existing 55 `!important` declarations into a shrinking island rather than a
 * permanent ceiling — each surface rebuilt in a later task simply writes normal rules in `shell`, `canvas`, `panels` or
 * `components` and outranks what it replaces.
 *
 * The one thing this file must not do is reorder after a browser has started matching: layer order is fixed by the
 * first declaration of each name, so this list is the single place the priority is decided.
 */
@layer tokens, legacy, base, shell, canvas, panels, components;

/* css/tokens.css */
/* Design tokens — the single source of colour, type, spacing, radius, elevation and motion.
 *
 * Two layers live here and they must not be confused:
 *
 *   raw     the palette and scales themselves (`--bb-*`). Nothing else in the app may declare a hex, a radius or a
 *           duration; new components read these.
 *   bridge  the mapping from the *existing* stylesheet's variable names (`--green`, `--line`, `--paper`, the
 *           `--theme-*` slots the appearance engine writes) onto those tokens. The bridge is scoped to
 *           `html[data-shell="v2"]` so the new identity arrives with the new shell, surface by surface, instead of
 *           repainting production the moment this file is linked.
 *
 * The appearance engine remains the only writer of `--theme-*` at runtime (inline style on <html>); the values below
 * are the defaults it starts from, so a board with no theme and a board with the default theme look the same.
 *
 * Choosing a variable:
 *   chrome that must keep the product identity whatever board theme is on   → `--bb-*`  (top bar, rail, dock, sheets)
 *   anything that belongs to the board and should follow its theme          → `--theme-*` (canvas, grid, objects,
 *                                                                            selection, in-canvas text)
 * `--bb-surface: #fff` is raw chrome white; it is NOT "the themed surface". Reading `--bb-surface` for a board
 * colour is the mistake this comment exists to prevent.
 */
@layer tokens {
  :root {
    /* ---- raw palette: warm paper studio, one accent ---- */
    --bb-paper: #FAF8F2;
    --bb-paper-sunk: #F3F0E7;
    --bb-surface: #FFFFFF;
    --bb-surface-soft: #FBF9F3;
    --bb-ink: #1F1B16;
    --bb-ink-2: #514B42;
    --bb-ink-3: #8A8378;
    --bb-hairline: #E6E1D5;
    --bb-hairline-strong: #D5CFC0;
    --bb-accent: #B23A2E;
    --bb-accent-ink: #FFFFFF;
    --bb-accent-soft: #F6E3DF;
    --bb-live: #2E7D5B;
    --bb-warn: #B4761C;
    --bb-danger: #A3282F;
    --bb-grid-dot: #DFD9CB;
    --bb-grid-line: #E9E4D8;
    --bb-tint-yellow: #F7E7A8;
    --bb-tint-peach: #F3D3C3;
    --bb-tint-green: #D8E6CB;
    --bb-tint-blue: #CFE0EA;
    --bb-tint-lilac: #DED8EC;

    /* ---- type ---- */
    --bb-font: Inter, ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
    --bb-display: 26px;
    --bb-display-line: 1.15;
    --bb-title: 15px;
    --bb-body: 13px;
    --bb-small: 11.5px;
    --bb-micro: 9.5px;
    --bb-weight-body: 450;
    --bb-weight-strong: 600;
    --bb-weight-label: 700;
    --bb-track-display: -0.9px;
    --bb-track-label: 0.08em;

    /* ---- space ---- */
    --bb-s1: 2px;
    --bb-s2: 4px;
    --bb-s3: 6px;
    --bb-s4: 8px;
    --bb-s5: 12px;
    --bb-s6: 16px;
    --bb-s7: 20px;
    --bb-s8: 24px;
    --bb-s9: 32px;

    /* ---- radius, elevation ---- */
    --bb-r-xs: 6px;
    --bb-r-sm: 10px;
    --bb-r-md: 14px;
    --bb-r-lg: 20px;
    --bb-r-pill: 999px;
    --bb-e1: 0 1px 2px #1f1b1610;
    --bb-e2: 0 6px 18px #1f1b1614;
    --bb-e3: 0 18px 48px #1f1b1624;

    /* ---- motion ---- */
    --bb-t-fast: 120ms;
    --bb-t: 180ms;
    --bb-t-slow: 260ms;
    --bb-ease: cubic-bezier(.2, .7, .3, 1);
    --bb-ease-out: cubic-bezier(.16, 1, .3, 1);
    --bb-focus-width: 2px;
    --bb-focus-offset: 3px;

    /* ---- canvas ---- */
    --bb-grid-space: 24px;
  }

}

/* ---------------------------------------------------------------------------------------------------------------
   Unlayered on purpose. An unlayered declaration beats every cascade layer regardless of specificity, and the legacy
   sheet is entirely unlayered — so a bridge inside `@layer tokens` would lose to `:root{--green:#20594a}` and the new
   identity would silently never apply. These two rules are the only unlayered things in this file.
   --------------------------------------------------------------------------------------------------------------- */

/* The new shell opts into the deck's identity; the old shell keeps its own colours until it is retired.
   The theme slots are set here too: the legacy sheet hard-codes `:root{--theme-accent:#20594a}` and, being unlayered,
   outranks anything in `@layer tokens`. These declarations are only the default — the appearance engine writes the
   board's theme as an inline style on <html>, which wins over any stylesheet rule, so a themed board keeps its theme. */
html[data-shell="v2"] {
  --theme-accent: var(--bb-accent);
  --theme-accent-text: var(--bb-accent-ink);
  --theme-surface: var(--bb-surface);
  --theme-canvas: var(--bb-paper);
  --theme-text: var(--bb-ink);
  --theme-selection: var(--bb-accent);
  --theme-border: var(--bb-hairline);
  --green: var(--theme-accent);
  --line: var(--theme-border);
  --paper: var(--theme-canvas);
  --muted: var(--bb-ink-3);
}

/* Reduced motion is a token change, not a per-component decision. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --bb-t-fast: 1ms;
    --bb-t: 1ms;
    --bb-t-slow: 1ms;
  }
}

/* css/shell.css */
/* Shell styles — the first surface written *above* the legacy layer.
 *
 * Being in `@layer shell` (declared after `legacy` in layers.css) these rules win over `style.css` without touching it
 * and without `!important`. That is the mechanism T1.2a was built for; this file is its first use.
 */
@layer shell {
  /* AA contrast on the sign-in card. Measured before: #748278 / #778179 / #79847C on the #E9EDE4 panel = 3.4–3.9:1,
     below the 4.5:1 floor for text this size. #5E6860 keeps the muted look at 4.88:1. */
  #auth .eyebrow,
  #auth-subtitle,
  #auth small,
  #auth .auth-story p,
  #auth .auth-story .eyebrow {
    color: #5E6860;
  }

  /* Pointer targets under the 24×24 minimum: grow the box, not the glyph. */
  #zoom-in,
  #zoom-out,
  #boards {
    min-width: 24px;
    min-height: 24px;
  }

  @media (max-width: 760px) {
    /* Belt and braces with board-name-fit.js: the overlay must never sit on the control at phone widths. */
    .name-echo #boards {
      color: inherit;
    }

    #board-name-echo {
      display: none;
    }

    /* Something in the compact header paints over the bottom of the select (axe: only 8.5 px unobscured).
       Lifting the control above its neighbours also makes it the element that receives the tap, which is correct. */
    #boards {
      position: relative;
      z-index: 3;
    }
  }

  /* A 30×10 tick is not a pointer target. The rail scrolls, so a real 24 px row costs height it can absorb, and the
     visible line stays 7×2 because the span is centred in it. */
  .timeline-tick {
    flex: 0 0 24px;
    min-width: 24px;
    min-height: 24px;
    position: relative;
  }

  /* The board surface stays unpainted-visible until the first render has placed its objects. */
  #world:not([data-painted]) {
    visibility: hidden;
  }

  /* The caret is drawn, not typed: a visible glyph excluded from the accessible name fails label-in-name. */
  .lang-switch::after {
    content: '▾';
    font-size: 9px;
    opacity: .55;
    margin-left: -2px;
  }

  /* The toast action sat in dark ink on the deep red error toast — 2.07:1. */
  #toast .text-button,
  #toast .text-button:hover {
    color: #FFFFFF;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  /* Legible type on phones: the public page had three runs of copy under 12px (a 9px eyebrow and two 11px lines),
     which Lighthouse scores as illegible. Desktop keeps its hierarchy. */
  @media (max-width: 760px) {
    #auth .eyebrow,
    #auth-toggle,
    #auth small {
      font-size: 12px;
    }
  }
}

/* fonts.css */
/* Self-hosted, freely licensed text fonts (SIL Open Font License 1.1, except Bebas Neue,
   Fredoka and Poppins which are also OFL). Each file is the latin subset of the upstream WOFF2,
   vendored here so the platform needs no third-party font CDN and works offline.
   The browser downloads a file only when text actually uses that family (font-display:swap).
   Licences: see public/fonts/OFL.txt. Adding a family means: the file here, a @font-face below,
   an entry in textStyleFamilies (public/text-style.js) and in canvas_rules.TEXT_FAMILIES. */
@font-face{font-family:'Caveat';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/caveat.woff2') format('woff2')}
@font-face{font-family:'Patrick Hand';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/patrick-hand.woff2') format('woff2')}
@font-face{font-family:'Kalam';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/kalam.woff2') format('woff2')}
@font-face{font-family:'Indie Flower';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/indie-flower.woff2') format('woff2')}
@font-face{font-family:'Shadows Into Light';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/shadows-into-light.woff2') format('woff2')}
@font-face{font-family:'Permanent Marker';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/permanent-marker.woff2') format('woff2')}
@font-face{font-family:'Dancing Script';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/dancing-script.woff2') format('woff2')}
@font-face{font-family:'Gloria Hallelujah';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/gloria-hallelujah.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/inter.woff2') format('woff2')}
@font-face{font-family:'Nunito';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/nunito.woff2') format('woff2')}
@font-face{font-family:'Poppins';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/poppins.woff2') format('woff2')}
@font-face{font-family:'Lora';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/lora.woff2') format('woff2')}
@font-face{font-family:'Merriweather';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/merriweather.woff2') format('woff2')}
@font-face{font-family:'Playfair Display';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/playfair-display.woff2') format('woff2')}
@font-face{font-family:'Bebas Neue';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/bebas-neue.woff2') format('woff2')}
@font-face{font-family:'Fredoka';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/fredoka.woff2') format('woff2')}
@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:400 700;font-display:swap;src:url('/fonts/jetbrains-mono.woff2') format('woff2')}
