/*
 * BareDykk DiveSafe – design tokens (§6.4, design system v1.0).
 *
 * This file is a from-scratch reconstruction of the token layer described in
 * docs/spec/bare-dykk-design-system-v1.0.html for the DiveSafe PWA — the
 * design system's own `baredykk-system.css` is the shop's stylesheet and does
 * not ship in this repo. Every hex value below is taken verbatim from the
 * guide's "01 Colors"/"02 Dark mode" sections; values NOT explicitly listed
 * there (--bd-grey, --bd-line, --bd-deep, --bd-icon-stroke, --bd-text-inv,
 * --bd-muted-inv) are reasoned derivations, called out below (ASSUMPTION).
 *
 * No external CDN (§6.2): fonts are self-hosted from ../fonts/ (woff2,
 * SIL Open Font License — see the OFL-*.txt files alongside them).
 *
 * Load this file BEFORE any script that reads --bd-* custom properties, and
 * before the no-flash theme-init inline script (templates/pwa.php) so the
 * very first paint already has the right palette.
 */

/* ---- Self-hosted fonts (§6.2 "ingen eksterne CDN-avhengigheter") ---- */

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-900.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/ibm-plex-sans-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/ibm-plex-sans-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/ibm-plex-sans-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../fonts/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---- Light tokens (default) ---- */

:root {
  /* Brand (guide §01). */
  --bd-orange: #f6ac4d;
  --bd-orange-deep: #e0922e;
  /*
   * D-64 FASIT REFRESH (2026-07-21) — produkteier leverte oppdatert
   * docs/spec/baredykk-system.css som ny KANONISK tokenkilde og overstyrer
   * den tidligere design-vakt-avledede #9a5f14 (Gate E finding 13). Fasitens
   * egen verdi, #a46110, er allerede AA-trygg for liten tekst: 4.89:1 vs
   * --bd-card (#ffffff), 4.54:1 vs --bd-page (#f5f7f5) — begge ≥4.5:1, så
   * ingen egen justering er nødvendig her. Dark-mode-remappen under (#fbc172)
   * er UENDRET — fasiten oppgir samme verdi for mørk modus.
   */
  --bd-orange-text: #a46110;
  --bd-orange-light: #fbc172;

  /* Surfaces & text (guide §01). */
  --bd-dark: #181b1d;
  --bd-surface: #22262a;
  --bd-footer-bg: #0f1214;
  --bd-page: #f5f7f5;
  --bd-card: #ffffff;
  --bd-text: #102129;
  --bd-muted: #5d6469;

  /* Semantic (guide §01). */
  --bd-sale: #c9412b;
  --bd-ok: #2e7d5b;
  --bd-warn: #c98a2b;
  --bd-info: #2b6e8f;

  /*
   * DERIVED TOKEN (design-vakt Gate E finding 1, KRITISK) — white text
   * (--bd-text-inv) on --bd-sale is only 4.91:1 in light mode (comfortable)
   * but drops to 3.19:1 once --bd-sale is remapped to the lighter dark-mode
   * alert red (#e76a52), below the 4.5:1 floor — on RING 113 itself, the
   * single most safety-critical control in the app. `--bd-danger-btn-bg` is
   * therefore a SEPARATE token from `--bd-sale` (which stays the alert/border
   * colour): light value unchanged (#c9412b, ~4.91:1 vs #fff, already a
   * comfortable margin over 4.5:1); dark value is a materially darker red
   * fixed for BOTH themes (#b23320, 6.20:1 vs #fff) rather than remapped per
   * theme, so danger-button text contrast never depends on which alert-red
   * shade a given theme happens to use. `.bd-btn--danger` and every
   * `.bd-emergency-*` call-to-action button use this token, never --bd-sale.
   */
  --bd-danger-btn-bg: #c9412b;

  /*
   * DERIVED TOKEN (design-vakt Gate D finding, KRITISK) — `--bd-warn`
   * (#c98a2b) is only 2.94:1 against `--bd-card`/`--bd-page` in light mode,
   * below the WCAG 2.2 AA 4.5:1 text-contrast floor (CLAUDE.md "bruk
   * --bd-orange-text, ikke --bd-orange, for oransje tekst på lys bakgrunn" —
   * the same rule applies to warn). `--bd-warn` itself stays reserved for
   * borders/backgrounds (non-text UI, where the lower ratio is acceptable),
   * exactly mirroring the existing `--bd-orange` / `--bd-orange-text` split.
   *
   * D-64 FASIT REFRESH (2026-07-21) — value updated to the canonical
   * docs/spec/baredykk-system.css figure, #8a5a0a (was the design-vakt-
   * derived #8a5d12): 5.92:1 vs --bd-card (#ffffff), 5.49:1 vs --bd-page
   * (#f5f7f5) — both comfortably ≥4.5:1, used for BRØDTEKST/ikoner-som-
   * bærer-mening on warn surfaces.
   */
  --bd-warn-text: #8a5a0a;

  /*
   * ASSUMPTION — not published as a swatch in the guide, derived to fit
   * alongside --bd-page/--bd-card in light mode: a light neutral "raised"
   * surface (chips, code backgrounds, disabled fields) and a subtle hairline
   * border, both a shade darker than --bd-page so a --bd-line border remains
   * visible against a white --bd-card.
   */
  --bd-grey: #eceeec;
  --bd-line: #e2e6e4;

  /*
   * NEW TOKEN (WCAG-kapsten Gate G finding 1, HØY) — `--bd-line` is only
   * 1.26:1 vs `--bd-card` (#ffffff) / 1.17:1 vs `--bd-page` (#f5f7f5), far
   * below the WCAG 2.2 1.4.11 "non-text contrast" 3:1 floor for a border that
   * is the ONLY visual cue an element is an interactive control (input,
   * select, textarea, ghost button, PIN field, fit/confirm toggle, emergency
   * task row). `--bd-line-strong` is a separate, darker neutral reserved for
   * exactly that case — #7c828a: 3.88:1 vs --bd-card, 3.60:1 vs --bd-page,
   * both comfortably ≥3:1. `--bd-line` itself is UNCHANGED and stays scoped
   * to purely decorative boundaries (card outer edge, row/section dividers)
   * where the lower ratio is acceptable because nothing depends on the
   * border alone to convey "this is operable".
   */
  --bd-line-strong: #7c828a;

  /*
   * ASSUMPTION — the guide uses --bd-deep for the darkest stop of the
   * dark-surface gradient (`--bd-surface` → `--bd-deep`) and for the
   * guide-footer background; no distinct swatch is published, so it is
   * treated as equal to --bd-footer-bg (both are "near-black" chrome tones
   * in the guide's own hero/footer sections).
   */
  --bd-deep: #0f1214;

  /*
   * D-64 FASIT REFRESH (2026-07-21) — docs/spec/baredykk-system.css states
   * this token explicitly (§01 Brand: "stroke --bd-icon-stroke #B5731B"),
   * distinct from --bd-orange-text (#a46110) rather than equal to it as
   * previously assumed. Icon strokes are graphical (non-text) UI, so the
   * applicable WCAG 2.2 1.4.11 floor is 3:1, not the 4.5:1 text floor:
   * #b5731b is 3.87:1 vs --bd-card (#ffffff), comfortably clearing it —
   * every status icon ships with colour + text per UX-003, so the stroke is
   * never the sole carrier of meaning.
   */
  --bd-icon-stroke: #b5731b;

  /*
   * ASSUMPTION — "inverse" text tokens for content permanently on a dark
   * surface regardless of site theme (hero/footer bands in the guide use
   * these even while the rest of the page is light). Not theme-remapped.
   */
  --bd-text-inv: #ffffff;
  --bd-muted-inv: #b9c0be;

  /* Fonts (guide §03 "Three families, three jobs"). */
  --bd-font-head: 'Archivo', sans-serif;
  --bd-font-body: 'IBM Plex Sans', sans-serif;
  --bd-font-mono: 'IBM Plex Mono', monospace;

  /* Layout constants used across the PWA shell. */
  --bd-radius: 12px;
  --bd-radius-sm: 8px;
  --bd-touch-min: 48px;
  --bd-maxw-text: 72ch;
  --bd-focus-ring: 2px solid var(--bd-orange-text);

  color-scheme: light;
}

/* ---- Dark tokens (guide §02 "Dark mode isn't a second stylesheet") ---- */

html[data-theme='dark'] {
  --bd-page: #0f1315;
  --bd-card: #191d20;
  --bd-grey: #242a2e;
  --bd-text: #eef2f0;
  --bd-muted: #9aa1a5;
  --bd-orange-text: #fbc172;

  --bd-sale: #e76a52;
  --bd-ok: #52b282;
  --bd-warn: #e2a748;
  --bd-info: #63aace;
  /* See the light-mode --bd-danger-btn-bg comment above — deliberately a
     fixed darker red, NOT a remap of dark-mode --bd-sale (6.20:1 vs #fff). */
  --bd-danger-btn-bg: #b23320;
  /*
   * D-64 FASIT REFRESH (2026-07-21) — docs/spec/baredykk-system.css gives
   * --bd-warn-text its OWN dark-mode figure, #f1c57e (was #e2a748, kept
   * equal to --bd-warn for symmetry with the light-mode split before the
   * fasit distinguished them). 10.52:1 vs --bd-card (#191d20), 12.15:1 vs
   * --bd-page (#0f1315) — both comfortably ≥4.5:1.
   */
  --bd-warn-text: #f1c57e;

  /*
   * ASSUMPTION — --bd-line/--bd-deep have no explicit dark value in the
   * guide either; remapped in the same spirit as --bd-grey (raised a step
   * from --bd-page) and --bd-orange-text (lifted to the light tint for
   * contrast on dark surfaces, guide §02 "lifts --bd-orange-text to the
   * light tint").
   */
  --bd-line: #2c3236;
  /*
   * NEW TOKEN (WCAG-kapsten Gate G finding 1, HØY) — the dark-mode --bd-line
   * (#2c3236) is only 1.31:1 vs --bd-card (#191d20) / 1.44:1 vs --bd-page
   * (#0f1315), the same non-text-contrast failure as light mode. #6a7278:
   * 3.47:1 vs --bd-card, 3.82:1 vs --bd-page — both ≥3:1. See the light-mode
   * comment above for which selectors use this vs plain --bd-line.
   */
  --bd-line-strong: #6a7278;
  --bd-deep: #060708;
  /*
   * D-64 FASIT REFRESH (2026-07-21) — docs/spec/baredykk-system.css confirms
   * #fbc172 for dark mode explicitly (§13 Dark mode); value unchanged from
   * the prior assumption, now backed by the canonical source.
   */
  --bd-icon-stroke: #fbc172;

  color-scheme: dark;
}

/* ---- Base reset (minimal — component classes live in app/styles/app.css) ---- */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bd-page);
  color: var(--bd-text);
  font-family: var(--bd-font-body);
  font-size: 1rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--bd-font-head);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.14;
  margin: 0;
}

/* WCAG 2.2 AA: a visible focus indicator on every interactive element (§6.4). */
:focus-visible {
  outline: var(--bd-focus-ring);
  outline-offset: 2px;
}

img,
svg {
  max-width: 100%;
}
