/*
 * normal is dead: Design Tokens
 * Single source of truth for color, type, and grid system.
 * Import this in your app's root stylesheet:
 *   @import "@normalisdead/brand-tokens/tokens.css";
 */

:root {
  /* ─── 12-color palette (Rosy Blush set) ─── */
  --c-cream:   #FCF0DD;   /* Creamsicle Dream: frame chrome */
  --c-sky:     #D7FFE9;   /* Minty Frost */
  --c-mustard: #EEBE55;   /* Sunlit Amber */
  --c-teal:    #96AA9F;   /* Sage Stone */
  --c-lav:     #9DA7EA;   /* Misty Mauve */
  --c-moss:    #1C423E;   /* Forest Shadow */
  --c-peach:   #F4B6C3;   /* Rosy Blush */
  --c-brick:   #EC5E52;   /* Scarlet Ember */
  --c-earth:   #530E36;   /* Midnight Plum */
  --c-lavlt:   #DEDDFC;   /* Ethereal Lavender */
  --c-copper:  #974320;   /* Rustic Copper */
  --c-indigo:  #383154;   /* Twilight Indigo */

  /* ─── Semantic tokens ─── */
  --bg:        var(--c-cream);
  --ink:       #1A1A1A;
  --ink-soft:  #5B5B5B;
  --link:      var(--c-lav);
  --link-hover:var(--c-peach);
  --accent:    var(--c-peach);
  --accent-fg: var(--c-earth);

  /* ─── Status palette ───
   * `--<name>`     inline text colour for status messages
   * `--<name>-rgb` space-separated channels for rgb()/alpha use
   * `--<name>-fg`  readable foreground when `--<name>` is a solid fill
   * all pairs target WCAG AA: verified by scripts/check-contrast.ts */
  --success:     #2F6B36;   --success-rgb: 47 107 54;   --success-fg: #FCF0DD;
  --error:       #BE3B27;   --error-rgb:   190 59 39;   --error-fg:   #FCF0DD;
  --warn:        #8A5A0C;   --warn-rgb:    138 90 12;   --warn-fg:    #FCF0DD;
  --info:        #383154;   --info-rgb:    56 49 84;    --info-fg:    #FCF0DD;

  /* ─── Radius scale ─── */
  --r-button:  9999px;   /* pills, cta */
  --r-card:    16px;     /* cards, panels, modals */
  --r-input:   12px;     /* text fields, selects */
  --r-menu:    8px;      /* dropdowns, popovers */
  --r-control: 6px;      /* chips, small toggles, swatches */

  /* ─── Grid system ─── */
  --cols: 32;
  --rows: 20;
  --cell-w: calc(100vw / 32);
  --cell-h: calc(100vh / 20);
  --cell:   min(var(--cell-w), var(--cell-h));

  --bar-rows: 2;
  --rail-cols: 3;
  --bar-h:  calc(var(--cell-h) * var(--bar-rows));
  --rail-w: calc(var(--cell-w) * var(--rail-cols));

  /* ─── Typography ─── */
  --font-display: "All Round Gothic", "General Sans",
                  ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body:    "General Sans",
                  ui-sans-serif, system-ui, -apple-system, sans-serif;

  --fw-thin:    200;
  --fw-medium:  500;
  --fw-bold:    700;
  /* italic-bold sits alongside fw-bold; use `font-style: italic` */

  /* ─── Motion ─── */
  --ease-out:    cubic-bezier(.16,1,.3,1);
  --ease-in-out: cubic-bezier(.4,0,.2,1);
  --t-fast:   .2s;
  --t-base:   .35s;
  --t-slow:   .9s;

  /* light is the default scheme */
  color-scheme: light;
}

/* ─── Dark theme ───
 * The 12 brand colors (--c-*) never change: they ARE the brand.
 * Only the semantic surface tokens flip. Apply with
 *   <html data-theme="dark">
 * or rely on the prefers-color-scheme block below. */
[data-theme="dark"] {
  --bg:        #14101A;   /* deep plum-black ground */
  --ink:       #F2ECDD;
  --ink-soft:  #A99FB0;
  --link:      var(--c-lav);
  --link-hover:var(--c-peach);
  --accent:    var(--c-peach);
  --accent-fg: #14101A;

  /* status stays legible on the dark ground */
  --success:     #6FBF7B;   --success-rgb: 111 191 123;  --success-fg: #14101A;
  --error:       #F08A7C;   --error-rgb:   240 138 124;  --error-fg:   #14101A;
  --warn:        #E0AE4E;   --warn-rgb:    224 174 78;   --warn-fg:    #14101A;
  --info:        #B7BEF0;   --info-rgb:    183 190 240;  --info-fg:    #14101A;

  color-scheme: dark;
}

/* auto dark when the visitor has no explicit theme set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14101A;
    --ink:       #F2ECDD;
    --ink-soft:  #A99FB0;
    --accent-fg: #14101A;
    --success:   #6FBF7B;   --success-rgb: 111 191 123;  --success-fg: #14101A;
    --error:     #F08A7C;   --error-rgb:   240 138 124;  --error-fg:   #14101A;
    --warn:      #E0AE4E;   --warn-rgb:    224 174 78;   --warn-fg:    #14101A;
    --info:      #B7BEF0;   --info-rgb:    183 190 240;  --info-fg:    #14101A;
    color-scheme: dark;
  }
}

/* ─── Opens Fridays: page styles ───
 * Light only: html carries data-theme="light", so the dark block above
 * never applies. Every radius is 0. No shadows, no gradients.
 * The sheet and the door card are black on white. */

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); font: 400 1rem/1.5 var(--font-body); }
main { max-width: 34rem; margin: 0 auto; padding: 20px 16px 72px; }
p, h1, ol { margin: 0; }
a { color: var(--ink); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.mark { display: inline-block; }
.mark img { display: block; width: 104px; height: auto; }

/* The posted-hours plate, with the wordmark's underline under it */
.posted { display: inline-block; margin-top: 44px; }
.plate {
  border: 2px solid var(--ink); padding: 10px 18px 9px;
  color: var(--c-earth); font-size: min(1.625rem, 6vw); line-height: 1.2; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.posted .rule { display: block; width: 43%; height: 4px; margin-top: 6px; background: var(--c-brick); }
.count { margin-top: 22px; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.stamp { margin-top: 1px; font-size: .8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* The form */
.put { margin-top: 34px; }
.put label { display: block; margin-bottom: 6px; font-weight: 500; }
.put textarea {
  display: block; width: 100%; min-height: 8.5rem; resize: vertical; padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--ink);
}
button {
  margin-top: 12px; padding: 9px 18px; cursor: pointer;
  font: inherit; font-weight: 500; color: var(--bg); background: var(--ink); border: 2px solid var(--ink);
}
.small { margin-top: 26px; font-size: .8125rem; color: var(--ink-soft); }

/* Received and error pages */
.line { margin-top: 44px; font-size: 1.125rem; }
.line.error { padding-left: 12px; border-left: 4px solid var(--error); }

/* The opened sheet: a parish notice, black on white */
.sheet { margin-top: 34px; padding: 26px 24px 20px; background: #fff; color: #000; }
.sheet-head { font-weight: 700; }
.total { margin-top: 2px; }
.notes { margin-top: 16px; padding-left: 2.4em; font-variant-numeric: tabular-nums; }
.notes li { margin-bottom: .3em; padding-left: .3em; overflow-wrap: anywhere; break-inside: avoid; }
.treatment { margin-top: 16px; padding-top: 8px; border-top: 1px solid #000; font-size: .85em; }
.print button { margin-top: 14px; }
.has-sheet .box { margin-top: 30px; }

/* Conditions: a warranty card */
.terms-card { margin-top: 34px; padding: 18px 20px 6px; border: 1px solid var(--ink); }
.terms-card h1 { font-size: 1.0625rem; line-height: 1.35; font-weight: 700; }
.terms { margin-top: 14px; padding: 0; list-style: none; counter-reset: term; }
.terms li {
  display: grid; grid-template-columns: 2em 1fr; padding: 10px 0;
  border-top: 1px solid var(--ink); counter-increment: term; font-size: .9375rem;
}
.terms li::before { content: counter(term) "."; font-variant-numeric: tabular-nums; }

/* The door card, A6 */
.card {
  display: flex; flex-direction: column; width: min(105mm, 100%); aspect-ratio: 105 / 148;
  margin: 12px auto 0; padding: 10mm 9mm 9mm; background: #fff; color: #000;
}
.card .plate { align-self: flex-start; color: #000; border-color: #000; font-size: 16pt; padding: 3mm 4mm 2.6mm; white-space: nowrap; }
.card-url { margin-top: auto; font-size: 15pt; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-mark { display: block; width: 32mm; height: auto; margin-top: 9mm; }

@page { size: A4; margin: 15mm; }
/* A6 by measure: Chromium drops the A6 keyword and prints on its default paper */
@page card { size: 105mm 148mm; margin: 0; }
@media print {
  html, body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .mark, .print, .put, .small { display: none; }
  .has-sheet main > :not(.sheet) { display: none; }
  .sheet { margin: 0; padding: 0; font-size: 9.5pt; line-height: 1.3; }
  .notes { margin-top: 4mm; column-count: 2; column-gap: 8mm; }
  .plate-page { page: card; }
  .card { width: 105mm; height: 148mm; aspect-ratio: auto; margin: 0; overflow: hidden; }
}
