/* ---------- Colour tokens (use ONLY these variables in components) ---------- */
:root {
  color-scheme: dark;
  --bg: #070a08;  --bg-2: #0b100d;  --surface: #101712;  --surface-2: #151e18;
  --line: rgba(217,183,121,.13);  --line-strong: rgba(217,183,121,.28);
  --text: #eeeae1;  --muted: #bcc0b6;  --dim: #8d9389;
  --emerald: #10b981;  --emerald-l: #4ade80;
  --gold: #d9b779;  --gold-l: #f1ddb0;  --gold-d: #a8864a;
  --grad-gold: linear-gradient(120deg, #f1ddb0, #d9b779 45%, #a8864a);

  /* Semantic aliases matching application components */
  --tp-bg-primary: var(--bg);
  --tp-bg-secondary: var(--bg-2);
  --tp-bg-surface: var(--surface);
  --tp-text-primary: var(--text);
  --tp-text-muted: var(--muted);
  --tp-border-color: var(--line);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f0e7;  --bg-2: #ece6d9;  --surface: #fbf8f1;  --surface-2: #f7f2e7;
  --line: rgba(70,52,18,.13);  --line-strong: rgba(70,52,18,.26);
  --text: #14120d;  --muted: #3d3a33;  --dim: #66625a;
  --emerald: #0f9f70;  --emerald-l: #07694a;
  --gold: #85601d;  --gold-l: #6b4c12;  --gold-d: #a8864a;

  /* Semantic aliases */
  --tp-bg-primary: var(--bg);
  --tp-bg-secondary: var(--bg-2);
  --tp-bg-surface: var(--surface);
  --tp-text-primary: var(--text);
  --tp-text-muted: var(--muted);
  --tp-border-color: var(--line);
}
body { background: var(--bg); color: var(--text); }

/* ---------- Sun / moon slider switch ---------- */
.theme-toggle { border: 0; background: none; padding: 0; cursor: pointer; flex: none; border-radius: 999px; }
.theme-toggle:focus-visible { outline: 2px solid var(--emerald); outline-offset: 3px; }
.tt-track { position: relative; display: flex; align-items: center; justify-content: space-between;
  width: 74px; height: 40px; padding: 0 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.25); transition: border-color .3s, background .3s; }
.theme-toggle:hover .tt-track { border-color: var(--gold); }
.tt-track svg { position: relative; z-index: 2; width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: color .35s; }
.tt-track .sun { color: var(--dim); }
.tt-track .moon { color: #17140c; }
.tt-knob { position: absolute; z-index: 1; top: 3px; left: 3px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad-gold); box-shadow: 0 4px 12px -3px rgba(0,0,0,.45);
  transform: translateX(34px); transition: transform .45s cubic-bezier(.5,1.6,.4,1); }
[data-theme="light"] .tt-knob { transform: translateX(0); }
[data-theme="light"] .tt-track .sun { color: #17140c; }
[data-theme="light"] .tt-track .moon { color: var(--dim); }
[data-theme="light"] .tt-track { box-shadow: inset 0 2px 6px rgba(60,45,15,.12); }
@media (max-width: 600px) { .tt-track { width: 66px; height: 36px; } .tt-knob { width: 28px; height: 28px; transform: translateX(30px); } }

/* ---------- Ink transition (mask image comes from ink.css) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) {
  z-index: 999999;
  -webkit-mask-size: 3000% 100%; mask-size: 3000% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: ink-spread 1.15s steps(30, jump-none) forwards;
}
@keyframes ink-spread {
  from { -webkit-mask-position: 0% 0; mask-position: 0% 0; }
  to   { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
@media (prefers-reduced-motion: reduce) { ::view-transition-new(root) { animation: none; } }
