/* =============================================================================
   03 — Design System Tokens (docs/03-design-system.md)
   ============================================================================= */

/* Self-hosted Variable Fonts */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  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;
}





:root {
  /* Surfaces */
  --bg-page: #ffffff;
  --bg-sidebar: #f7f6f3;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(43, 42, 39, 0.06);
  --bg-active: rgba(43, 42, 39, 0.1);
  --bg-selected: rgba(180, 55, 46, 0.08);

  /* Text */
  --text-primary: #2b2a27;
  --text-secondary: #6b6a65;
  --text-tertiary: #706e68;
  --text-on-accent: #ffffff;

  /* Lines */
  --border: rgba(43, 42, 39, 0.09);
  --border-strong: rgba(43, 42, 39, 0.16);

  /* Brand + Status */
  --accent: #b4372e;
  --accent-hover: #9c2f27;
  --focus-ring: #b4372e;
  --success: #2f7d4f;
  --warning: #a8620a;
  --danger: #b4372e;
  --info: #2b6cb0;

  /* Shadows (popovers, menus, modals) */
  --shadow-popover:
    0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1),
    0 9px 24px rgba(15, 15, 15, 0.16);
  --shadow-modal: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 12px 32px rgba(15, 15, 15, 0.22);

  /* Radius */
  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-full: 9999px;

  /* Spacing (4px base grid) */
  --space-0: 0px;
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-6: 12px;
  --space-8: 16px;
  --space-12: 24px;
  --space-16: 32px;
  --space-24: 48px;
  --space-32: 64px;

  /* Motion */
  --duration-fast: 100ms;
  --duration-normal: 150ms;
  --duration-slow: 200ms;
  --ease-default: cubic-bezier(0.2, 0, 0, 1);

  /* Typography Font Families */
  --font-ui:
    "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --font-serif: "Source Serif 4", Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Block & Highlight Colors (Light mode: 4.5:1 text/bg contrast) */
  --hl-gray-bg: #efeeeb;
  --hl-gray-text: #5f5e5a;
  --hl-gray-pdf: rgba(95, 94, 90, 0.2);

  --hl-brown-bg: #f1e9e3;
  --hl-brown-text: #7a5a43;
  --hl-brown-pdf: rgba(122, 90, 67, 0.2);

  --hl-orange-bg: #fbebdb;
  --hl-orange-text: #a8570f;
  --hl-orange-pdf: rgba(168, 87, 15, 0.2);

  --hl-yellow-bg: #fbf1c7;
  --hl-yellow-text: #8a6a05;
  --hl-yellow-pdf: rgba(138, 106, 5, 0.22);

  --hl-green-bg: #e3f2e8;
  --hl-green-text: #2f6b47;
  --hl-green-pdf: rgba(47, 107, 71, 0.2);

  --hl-blue-bg: #e1edf8;
  --hl-blue-text: #2b5f94;
  --hl-blue-pdf: rgba(43, 95, 148, 0.2);

  --hl-purple-bg: #ebe5f6;
  --hl-purple-text: #5f4a8f;
  --hl-purple-pdf: rgba(95, 74, 143, 0.2);

  --hl-pink-bg: #f8e3ec;
  --hl-pink-text: #9b3a66;
  --hl-pink-pdf: rgba(155, 58, 102, 0.2);

  --hl-red-bg: #f9e2df;
  --hl-red-text: #a33a33;
  --hl-red-pdf: rgba(163, 58, 51, 0.2);
}

/* System Dark Mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #191918;
    --bg-sidebar: #202020;
    --bg-elevated: #252525;
    --bg-hover: rgba(255, 255, 255, 0.07);
    --bg-active: rgba(255, 255, 255, 0.11);
    --bg-selected: rgba(224, 98, 88, 0.16);

    --text-primary: #e8e6e1;
    --text-secondary: #a9a7a0;
    --text-tertiary: #928f88;
    --text-on-accent: #191918;

    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.17);

    --accent: #ee7f75;
    --accent-hover: #f39088;
    --focus-ring: #e06258;
    --success: #5cc189;
    --warning: #e0a14b;
    --danger: #e06258;
    --info: #6aa8e8;

    --shadow-popover:
      0 0 0 1px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.4), 0 9px 24px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.6);

    /* Block & Highlight Colors (Dark mode) */
    --hl-gray-bg: #2b2a28;
    --hl-gray-text: #d1cfc7;
    --hl-gray-pdf: rgba(209, 207, 199, 0.22);

    --hl-brown-bg: #382a20;
    --hl-brown-text: #e2c2a8;
    --hl-brown-pdf: rgba(226, 194, 168, 0.22);

    --hl-orange-bg: #3b2614;
    --hl-orange-text: #f0ab6a;
    --hl-orange-pdf: rgba(240, 171, 106, 0.22);

    --hl-yellow-bg: #383114;
    --hl-yellow-text: #e8c858;
    --hl-yellow-pdf: rgba(232, 200, 88, 0.25);

    --hl-green-bg: #1a3324;
    --hl-green-text: #78cc97;
    --hl-green-pdf: rgba(120, 204, 151, 0.22);

    --hl-blue-bg: #192e44;
    --hl-blue-text: #7bb0e6;
    --hl-blue-pdf: rgba(123, 176, 230, 0.22);

    --hl-purple-bg: #2d2342;
    --hl-purple-text: #bfa4ee;
    --hl-purple-pdf: rgba(191, 164, 238, 0.22);

    --hl-pink-bg: #3d1d2c;
    --hl-pink-text: #e88cb7;
    --hl-pink-pdf: rgba(232, 140, 183, 0.22);

    --hl-red-bg: #3c1b18;
    --hl-red-text: #eb7c73;
    --hl-red-pdf: rgba(235, 124, 115, 0.22);
  }
}

/* Explicit data-theme="dark" override */
:root[data-theme="dark"] {
  --bg-page: #191918;
  --bg-sidebar: #202020;
  --bg-elevated: #252525;
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-active: rgba(255, 255, 255, 0.11);
  --bg-selected: rgba(224, 98, 88, 0.16);

  --text-primary: #e8e6e1;
  --text-secondary: #a9a7a0;
  --text-tertiary: #928f88;
  --text-on-accent: #191918;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);

  --accent: #ee7f75;
  --accent-hover: #f39088;
  --focus-ring: #e06258;
  --success: #5cc189;
  --warning: #e0a14b;
  --danger: #e06258;
  --info: #6aa8e8;

  --shadow-popover:
    0 0 0 1px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.4), 0 9px 24px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.6);

  /* Block & Highlight Colors */
  --hl-gray-bg: #2b2a28;
  --hl-gray-text: #d1cfc7;
  --hl-gray-pdf: rgba(209, 207, 199, 0.22);

  --hl-brown-bg: #382a20;
  --hl-brown-text: #e2c2a8;
  --hl-brown-pdf: rgba(226, 194, 168, 0.22);

  --hl-orange-bg: #3b2614;
  --hl-orange-text: #f0ab6a;
  --hl-orange-pdf: rgba(240, 171, 106, 0.22);

  --hl-yellow-bg: #383114;
  --hl-yellow-text: #e8c858;
  --hl-yellow-pdf: rgba(232, 200, 88, 0.25);

  --hl-green-bg: #1a3324;
  --hl-green-text: #78cc97;
  --hl-green-pdf: rgba(120, 204, 151, 0.22);

  --hl-blue-bg: #192e44;
  --hl-blue-text: #7bb0e6;
  --hl-blue-pdf: rgba(123, 176, 230, 0.22);

  --hl-purple-bg: #2d2342;
  --hl-purple-text: #bfa4ee;
  --hl-purple-pdf: rgba(191, 164, 238, 0.22);

  --hl-pink-bg: #3d1d2c;
  --hl-pink-text: #e88cb7;
  --hl-pink-pdf: rgba(232, 140, 183, 0.22);

  --hl-red-bg: #3c1b18;
  --hl-red-text: #eb7c73;
  --hl-red-pdf: rgba(235, 124, 115, 0.22);
}

/* Explicit data-theme="light" override */
:root[data-theme="light"] {
  --bg-page: #ffffff;
  --bg-sidebar: #f7f6f3;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(43, 42, 39, 0.06);
  --bg-active: rgba(43, 42, 39, 0.1);
  --bg-selected: rgba(180, 55, 46, 0.08);

  --text-primary: #2b2a27;
  --text-secondary: #6b6a65;
  --text-tertiary: #706e68;
  --text-on-accent: #ffffff;

  --border: rgba(43, 42, 39, 0.09);
  --border-strong: rgba(43, 42, 39, 0.16);

  --accent: #b4372e;
  --accent-hover: #9c2f27;
  --focus-ring: #b4372e;
  --success: #2f7d4f;
  --warning: #a8620a;
  --danger: #b4372e;
  --info: #2b6cb0;

  --shadow-popover:
    0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1),
    0 9px 24px rgba(15, 15, 15, 0.16);
  --shadow-modal: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 12px 32px rgba(15, 15, 15, 0.22);

  --hl-gray-bg: #efeeeb;
  --hl-gray-text: #5f5e5a;
  --hl-gray-pdf: rgba(95, 94, 90, 0.2);

  --hl-brown-bg: #f1e9e3;
  --hl-brown-text: #7a5a43;
  --hl-brown-pdf: rgba(122, 90, 67, 0.2);

  --hl-orange-bg: #fbebdb;
  --hl-orange-text: #a8570f;
  --hl-orange-pdf: rgba(168, 87, 15, 0.2);

  --hl-yellow-bg: #fbf1c7;
  --hl-yellow-text: #8a6a05;
  --hl-yellow-pdf: rgba(138, 106, 5, 0.22);

  --hl-green-bg: #e3f2e8;
  --hl-green-text: #2f6b47;
  --hl-green-pdf: rgba(47, 107, 71, 0.2);

  --hl-blue-bg: #e1edf8;
  --hl-blue-text: #2b5f94;
  --hl-blue-pdf: rgba(43, 95, 148, 0.2);

  --hl-purple-bg: #ebe5f6;
  --hl-purple-text: #5f4a8f;
  --hl-purple-pdf: rgba(95, 74, 143, 0.2);

  --hl-pink-bg: #f8e3ec;
  --hl-pink-text: #9b3a66;
  --hl-pink-pdf: rgba(155, 58, 102, 0.2);

  --hl-red-bg: #f9e2df;
  --hl-red-text: #a33a33;
  --hl-red-pdf: rgba(163, 58, 51, 0.2);
}

/* Global Reset & Accessible Focus defaults */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Account pages. Colours, fonts and spacing come from the design tokens (tokens.css), which
   handle light and dark. Form boundaries use --text-tertiary so they meet 3:1 against the page. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg-page);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: var(--space-8);
  top: -48px;
  padding: var(--space-4) var(--space-8);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 2px solid var(--focus-ring);
  border-radius: var(--r-md);
  z-index: 10;
}

.skip-link:focus {
  top: var(--space-8);
}

.site-header {
  padding: var(--space-8) var(--space-12);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 650;
  font-size: 17px;
}

main {
  max-width: 460px;
  margin: 0 auto;
  padding: var(--space-24) var(--space-8) var(--space-32);
}

main:focus {
  outline: none;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0 0 var(--space-12);
}

h2 {
  font-size: 17px;
  margin: var(--space-16) 0 var(--space-4);
}

section {
  border-top: 1px solid var(--border);
  margin-top: var(--space-12);
  padding-top: var(--space-4);
}

p {
  margin: 0 0 var(--space-8);
}

.field {
  margin: 0 0 var(--space-8);
}

label {
  display: block;
  font-weight: 550;
  margin-bottom: var(--space-2);
}

input {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--text-tertiary);
  border-radius: var(--r-md);
  min-height: 38px;
}

.hint {
  margin: var(--space-2) 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

button {
  font: inherit;
  min-height: 38px;
  padding: var(--space-3) var(--space-8);
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid var(--text-tertiary);
  background: var(--bg-page);
  color: var(--text-primary);
}

button:hover {
  background: var(--bg-hover);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 550;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.link-button {
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  padding-left: 0;
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

a {
  color: var(--accent);
}

/* A 2 px ring that is always visible when something has keyboard focus. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.message {
  margin: 0 0 var(--space-8);
}

.message:empty {
  display: none;
}

.message.error {
  color: var(--danger);
  font-weight: 550;
}

.message.notice {
  color: var(--text-primary);
}

.alternatives {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-12) 0 var(--space-8);
}

.links {
  margin-top: var(--space-12);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

ul.plain {
  list-style: none;
  margin: 0 0 var(--space-8);
  padding: 0;
}

ul.plain li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

ul.codes li {
  display: block;
  font-family: var(--font-mono);
}

code {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  button {
    transition: background var(--duration-fast) var(--ease-default);
  }
}
