/* The touch of the site: controls, fields and the light in the hall. Loaded last on every page.
   The world is a chalkboard in a wooden frame, so controls are raised keys with a real edge that
   sinks when pressed: slabs of board green, brass for the main action, paper keys for the rest. */
:root {
  --brass-hi: #fbe6b0;
  --brass: #ecc47d;
  --brass-lo: #c99b49;
  --brass-edge: #8a6221;
  --slab-top: #335648;
  --slab-bot: #1b322b;
  --slab-edge: #0b1914;
  --key-top: #fffdf6;
  --key-bot: #ebe5d2;
  --key-edge: #c5bda4;
  --key-line: #bdb59c;
  --field-bg: #fbf8ee;
  --field-line: #8f9a8b;
  --field-inset: inset 0 2px 4px #2a33282e;
  --focus-ring: #a35a27;
  /* How each variant paints the shared button. */
  --p-top: var(--slab-top); --p-bot: var(--slab-bot); --p-edge: var(--slab-edge); --p-ink: #f5f0dc; --p-rim: #d9b36a66;
}
@media (prefers-color-scheme: dark) {
  :root {
    --key-top: #2b3f36;
    --key-bot: #1c2b25;
    --key-edge: #0a110e;
    --key-line: #45594e;
    --field-bg: #131f1a;
    --field-line: #5b7165;
    --field-inset: inset 0 2px 5px #000a;
    --focus-ring: #f3d594;
    --p-top: var(--brass-hi); --p-bot: var(--brass-lo); --p-edge: var(--brass-edge); --p-ink: #1f2b28; --p-rim: #fff5;
  }
}

/* A strong, two-part focus ring that shows on light paper, dark board and brass alike. */
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; border-radius: 8px; }
.stage :focus-visible, .board :focus-visible, .st-win :focus-visible { outline-color: var(--chalk); }

/* ---------- Buttons ---------- */
.button {
  --lift: 3px;
  --b-top: var(--key-top); --b-bot: var(--key-bot); --b-edge: var(--key-edge); --b-line: var(--key-line); --b-ink: var(--ink);
  --b-hi: #fff; --b-shade: #2a33281c; --b-drop: #2a332855; --b-glow: 0 0 #0000;
  position: relative; isolation: isolate; overflow: hidden; min-height: 48px; padding: 10px 22px; border-radius: 14px;
  border: 1px solid var(--b-line); background: linear-gradient(var(--b-top), var(--b-bot)); color: var(--b-ink);
  font-weight: 700; letter-spacing: .005em; text-shadow: var(--b-text, none);
  box-shadow: inset 0 1px 0 var(--b-hi), inset 0 -2px 3px var(--b-shade), 0 var(--lift) 0 var(--b-edge), 0 12px 16px -10px var(--b-drop), var(--b-glow);
  transform: translateY(0);
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 150ms ease, filter 160ms ease, background 160ms ease;
}
.button:enabled:hover, a.button:hover { --lift: 4px; transform: translateY(-1px); filter: brightness(1.04); }
.button:enabled:active, a.button:active { --lift: 0px; transform: translateY(3px); filter: none; box-shadow: inset 0 2px 5px var(--b-shade), inset 0 1px 0 #0000, 0 var(--lift) 0 var(--b-edge), 0 4px 6px -4px var(--b-drop); }
.button:focus-visible { outline-offset: 5px; border-radius: 14px; }
/* A sheen that sweeps across when the pointer arrives. */
.button::after {
  content: ""; position: absolute; z-index: -1; inset: -2px; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, transparent 38%, #ffffff66 50%, transparent 62%); transform: translateX(-110%);
}
.button:enabled:hover::after, a.button:hover::after { opacity: 1; transform: translateX(110%); transition: transform 650ms ease, opacity 200ms ease; }
.button .arrow { display: inline-block; transition: transform 240ms cubic-bezier(.34, 1.56, .64, 1); }
.button:hover .arrow { transform: translateX(6px); }

.button.primary {
  --b-top: var(--p-top); --b-bot: var(--p-bot); --b-edge: var(--p-edge); --b-ink: var(--p-ink); --b-line: var(--p-edge);
  --b-hi: var(--p-rim); --b-shade: #0005; --b-drop: #0b191480; --b-text: 0 1px 0 #0004;
}
.button.primary:hover { background: linear-gradient(var(--p-top), var(--p-bot)); }
@media (prefers-color-scheme: dark) { .button.primary { --b-text: 0 1px 0 #fff6; --b-shade: #8a622166; } }

.button.gold {
  --b-top: var(--brass-hi); --b-bot: var(--brass-lo); --b-edge: var(--brass-edge); --b-line: var(--brass-edge); --b-ink: #1f2b28;
  --b-hi: #fffbe8; --b-shade: #8a622180; --b-drop: #0009; --b-text: 0 1px 0 #fff7;
  --b-glow: 0 0 26px #efcb8655;
  background: linear-gradient(var(--brass-hi), var(--brass) 45%, var(--brass-lo));
}
.button.gold:hover { background: linear-gradient(var(--brass-hi), var(--brass) 45%, var(--brass-lo)); --b-glow: 0 0 34px #efcb8699; }

.button.ghost {
  --b-top: #ffffff14; --b-bot: #ffffff08; --b-edge: #0b1914; --b-line: #f5f0dc88; --b-ink: var(--chalk);
  --b-hi: #ffffff30; --b-shade: #0004; --b-drop: #0008;
}
.button.ghost:hover { background: linear-gradient(#ffffff26, #ffffff10); }

.button.secondary:enabled:hover, a.button.secondary:hover { background: linear-gradient(var(--key-top), var(--key-bot)); }
.button.danger {
  --b-top: #b5503f; --b-bot: #8a3324; --b-edge: #561b11; --b-line: #561b11; --b-ink: #fff6ef;
  --b-hi: #ffffff40; --b-shade: #0005; --b-drop: #561b1166; --b-text: 0 1px 0 #0005;
}
.button.danger:enabled:hover { background: linear-gradient(#b5503f, #8a3324); }
.button.google-button { --b-top: #fff; --b-bot: #f1f3f4; --b-edge: #a9acb0; --b-line: #747775; --b-ink: #1f1f1f; }
.button.google-button:enabled:hover { background: linear-gradient(#fff, #f1f3f4); }
.button.button:disabled {
  --lift: 0px; transform: none; filter: none; cursor: default; opacity: .62;
  background: var(--sunken); color: var(--muted); border-color: var(--rule); box-shadow: none; text-shadow: none;
}
.button.button:disabled::after { display: none; }
/* The main action on the hero shines once in a while, like brass catching light from the hall. */
@media (prefers-reduced-motion: no-preference) {
  .hero-actions .button.gold::after { opacity: 1; animation: sheen 7s ease-in-out 2.4s infinite; }
  @keyframes sheen { 0%, 72% { transform: translateX(-110%); } 92%, 100% { transform: translateX(110%); } }
}

/* ---------- Navigation and links ---------- */
.site-nav a, .site-footer a { text-decoration: none; }
.site-nav a, .site-footer a {
  background: linear-gradient(var(--gold), var(--gold)) no-repeat 12px calc(100% - 6px) / 0 2px; transition: background-size 260ms cubic-bezier(.3, .7, .2, 1), color 160ms ease;
}
.site-nav a { border-radius: 10px; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background-color: transparent; background-size: calc(100% - 24px) 2px; }
.site-nav a[aria-current="page"] { font-weight: 650; }
.site-footer a {
  background-image: linear-gradient(#c98a3b, #c98a3b), linear-gradient(var(--muted), var(--muted));
  background-position: 0 calc(100% - 3px), 0 calc(100% - 4px); background-size: 0 3px, 100% 1px;
}
.site-footer a:hover { color: var(--ink); background-size: 100% 3px, 100% 1px; }
@media (prefers-color-scheme: dark) { .site-footer a { background-image: linear-gradient(var(--gold), var(--gold)), linear-gradient(var(--muted), var(--muted)); } }
@media (prefers-color-scheme: light) {
  .site-nav a { background-image: linear-gradient(#c98a3b, #c98a3b); }
}
.language {
  min-width: 46px; min-height: 46px; border-radius: 14px; font-weight: 700; border: 1px solid var(--key-line);
  background: linear-gradient(var(--key-top), var(--key-bot)); color: inherit;
  box-shadow: inset 0 1px 0 #fff4, 0 3px 0 var(--key-edge);
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 150ms ease;
}
.language:hover { background: linear-gradient(var(--key-top), var(--key-bot)); transform: translateY(-1px); box-shadow: inset 0 1px 0 #fff4, 0 4px 0 var(--key-edge); }
.language:active { transform: translateY(3px); box-shadow: inset 0 2px 4px #0003, 0 0 0 var(--key-edge); }
/* A rail of wood under the page, like the tray of a blackboard. */
.site-footer { position: relative; border-top: 0; padding-top: 8px; }
.site-footer::before {
  content: ""; display: block; height: 7px; margin-bottom: 4px; background: linear-gradient(#d2b685, var(--wood) 45%, var(--wood-deep));
  box-shadow: 0 1px 0 #ffffff55 inset, 0 2px 5px #0003;
}

/* ---------- Chips and switches ---------- */
.st-subjects button, .st-replay, .tax-switch button, .filters .button {
  min-height: 38px; border-radius: 12px; border: 1px solid var(--key-line); font-weight: 650;
  background: linear-gradient(var(--key-top), var(--key-bot)); color: var(--ink);
  box-shadow: inset 0 1px 0 #fff5, 0 3px 0 var(--key-edge);
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 150ms ease, background 160ms ease, color 160ms ease;
}
.st-subjects button:hover:not([aria-pressed="true"]), .st-replay:hover, .filters .button:hover:not([aria-pressed="true"]) {
  color: var(--ink); border-color: var(--key-line); transform: translateY(-1px); box-shadow: inset 0 1px 0 #fff5, 0 4px 0 var(--key-edge);
}
.st-subjects button:active, .st-replay:active, .tax-switch button:active, .filters .button:active { transform: translateY(3px); box-shadow: inset 0 2px 4px #0004, 0 0 0 var(--key-edge); }
/* A pressed chip stays sunk, with a brass tick under its label. */
.st-subjects button[aria-pressed="true"], .filters .button[aria-pressed="true"] {
  transform: translateY(2px); border-color: #0b1914; background: linear-gradient(#162a23, var(--board)); color: var(--chalk);
  box-shadow: inset 0 3px 6px #0008, inset 0 -3px 0 var(--gold), 0 1px 0 #ffffff33;
}
.tax-switch button { --key-top: #2c473d; --key-bot: #1d352d; --key-edge: #0b1914; --key-line: #cadbc255; color: var(--chalk); }
.tax-switch button:hover { background: linear-gradient(#35564a, #24413a); transform: translateY(-1px); box-shadow: inset 0 1px 0 #ffffff22, 0 4px 0 var(--key-edge); }
.tax-switch button[aria-pressed="true"] {
  transform: translateY(2px); border-color: #8a6221; background: linear-gradient(var(--brass), var(--brass-lo)); color: #1f2b28;
  box-shadow: inset 0 3px 6px #8a622199, 0 1px 0 #ffffff33;
}

/* ---------- Story controls ---------- */
.st-ask {
  min-height: 34px; padding: 4px 16px; border-radius: 12px; font-weight: 650;
  border: 1px solid #f5f0dc66; background: linear-gradient(#ffffff1c, #ffffff08); color: var(--chalk);
  box-shadow: inset 0 1px 0 #ffffff30, 0 3px 0 #0b1914;
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 150ms ease, background 160ms ease;
}
.st-ask:not(:disabled) { border-color: #8a6221; background: linear-gradient(var(--brass-hi), var(--brass-lo)); color: #1f2b28; box-shadow: inset 0 1px 0 #fffbe8, 0 3px 0 var(--brass-edge), 0 0 18px #efcb8644; }
.st-ask:not(:disabled):hover { background: linear-gradient(var(--brass-hi), var(--brass-lo)); transform: translateY(-1px); box-shadow: inset 0 1px 0 #fffbe8, 0 4px 0 var(--brass-edge), 0 0 24px #efcb8677; }
.st-ask:not(:disabled):active { transform: translateY(3px); box-shadow: inset 0 2px 4px #8a622199, 0 0 0 var(--brass-edge); }
.st-ask:disabled { opacity: .55; box-shadow: none; }
.st-questions button {
  padding: 8px 14px; border-radius: 12px; border: 1px solid #f5f0dc77; font-weight: 600;
  background: linear-gradient(#22372f, #0f1d18); color: var(--chalk); box-shadow: inset 0 1px 0 #ffffff22, 0 3px 0 #050c09, 0 8px 12px -8px #000;
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 150ms ease, color 160ms ease, border-color 160ms ease;
}
.st-questions button:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-1px); box-shadow: inset 0 1px 0 #ffffff22, 0 4px 0 #050c09, 0 8px 12px -8px #000; }
.st-questions button:active { transform: translateY(3px); box-shadow: inset 0 2px 4px #000a, 0 0 0 #050c09; }

/* ---------- The tax slider: a groove in the board and a brass knob ---------- */
.tax-slider input[type="range"] { -webkit-appearance: none; appearance: none; height: 30px; background: transparent; cursor: pointer; }
.tax-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 6px; border: 1px solid #08120f; background: linear-gradient(#0c1a15, #183128); box-shadow: inset 0 2px 3px #000b, 0 1px 0 #ffffff26;
}
.tax-slider input[type="range"]::-moz-range-track { height: 10px; border-radius: 6px; border: 1px solid #08120f; background: linear-gradient(#0c1a15, #183128); box-shadow: inset 0 2px 3px #000b, 0 1px 0 #ffffff26; }
.tax-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; border: 1px solid var(--brass-edge);
  background: radial-gradient(circle at 36% 28%, #fff6d8, var(--brass) 48%, var(--brass-lo)); box-shadow: 0 3px 0 var(--brass-edge), 0 6px 10px #0009, inset 0 -3px 4px #8a622180;
  transition: transform 150ms cubic-bezier(.34, 1.56, .64, 1);
}
.tax-slider input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--brass-edge);
  background: radial-gradient(circle at 36% 28%, #fff6d8, var(--brass) 48%, var(--brass-lo)); box-shadow: 0 3px 0 var(--brass-edge), 0 6px 10px #0009;
}
.tax-slider input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.08); }
.tax-slider input[type="range"]:active::-webkit-slider-thumb { transform: scale(.94) translateY(2px); }
.tax-slider input[type="range"]:focus-visible { outline: 0; }
.tax-slider input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--chalk); outline-offset: 3px; }
.tax-slider input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--chalk); outline-offset: 3px; }

/* ---------- Form fields: sunk into the paper ---------- */
input:not([type="checkbox"], [type="radio"], [type="range"]), select, textarea {
  border: 1px solid var(--field-line); border-radius: 12px; background: var(--field-bg); color: var(--ink); box-shadow: var(--field-inset);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:not([type="checkbox"], [type="radio"], [type="range"]):hover, select:hover, textarea:hover { border-color: var(--brass-lo); }
input:not([type="checkbox"], [type="radio"], [type="range"]):focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--brass-lo); outline: 3px solid var(--focus-ring); outline-offset: 2px; box-shadow: var(--field-inset), 0 0 0 5px #ecc47d33;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--board); }
@media (prefers-color-scheme: dark) { input[type="checkbox"], input[type="radio"] { accent-color: var(--brass); } }
.field select { background: var(--field-bg); border: 1px solid var(--field-line); border-radius: 12px; }

/* ---------- Cards lift a little under the pointer ---------- */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card, .steps li, .cases li, .application-list li { transition: transform 240ms cubic-bezier(.3, .8, .3, 1), box-shadow 240ms ease; }
  .card:hover, .steps li:hover, .cases li:hover, .application-list li:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
}

/* ---------- The hall: grain on the boards, light from the windows ---------- */
.stage::before, .board::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; border-radius: inherit; opacity: .55;
  background-image:
    linear-gradient(106deg, transparent 8%, #fff2 13%, #fff0 21%, transparent 32%, #fff1 38%, #fff0 46%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 .92 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}
.board { position: relative; isolation: isolate; }
.board::before { opacity: .4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 .92 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E"); }
.board > * { position: relative; }
/* Slow, soft colour drifting in the page background beside the board. Never on the board itself.
   Transform only, so it costs the compositor, not the page. It stops with the hero's pause button. */
@media (prefers-reduced-motion: no-preference) {
  body:has(.stage)::before {
    content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
    background:
      radial-gradient(38% 34% at 14% 30%, rgb(63 143 111 / .26), transparent 70%),
      radial-gradient(34% 30% at 88% 22%, rgb(239 203 134 / .22), transparent 70%),
      radial-gradient(40% 34% at 80% 82%, rgb(106 165 200 / .18), transparent 70%),
      radial-gradient(30% 28% at 10% 88%, rgb(176 147 104 / .18), transparent 70%);
    animation: drift 48s ease-in-out infinite alternate;
  }
  @keyframes drift {
    0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    50% { transform: translate3d(3%, -4%, 0) rotate(7deg) scale(1.08); }
    100% { transform: translate3d(-3%, 3%, 0) rotate(-6deg) scale(1.04); }
  }
}
/* The hero's pause button also stills the background drift. */
body:has(.stage .hero-pause > :nth-child(2):not([hidden]))::before { animation-play-state: paused; }
/* Reduced motion keeps the colour and shadow changes but drops the movement. */
@media (prefers-reduced-motion: reduce) {
  .button:enabled:hover, a.button:hover, .language:hover, .st-subjects button:hover, .st-replay:hover, .st-ask:hover,
  .st-questions button:hover, .tax-switch button:hover, .filters .button:hover { transform: none; }
  .button::after { display: none; }
}
