/* Themes: the pieces each palette needs beyond its colour tokens (see palettes.css), and the theme picker in Settings.
   Loaded last. Palettes: emerald (default), sapphire, gold; each comes in data-theme=dark and light. */

/* ---------- Illustrations were painted in emerald, so tint them to match ---------- */
/* Sapphire uses the #tone-sapphire SVG filter; that rule sits in the page's own <style> so the reference resolves in every browser. */
:root[data-palette=gold] :is(.hero-art,.hc-art img){filter:grayscale(1) sepia(.66) saturate(1.45) brightness(.94) contrast(1.08)}
:root[data-palette=gold][data-theme=dark] :is(.hero-art,.hc-art img){filter:grayscale(1) sepia(.75) saturate(1.7) brightness(1.04) contrast(1.06)}
:root[data-palette=emerald] :is(.hero-art,.hc-art img){filter:saturate(1.2) contrast(1.06)}

/* ---------- Gold-family accents: richer antique gold with bronze depth ---------- */
/* ---------- Bright, luminous gold for the emerald and sapphire themes ---------- */
:root[data-theme=dark]{--au:#ecc163;--au-2:#ffe29a;--au-3:#b8832c;--au-line:#ecc16360;--au-faint:#ecc1632e;
  --gold:#ecc163;--gold-ink:#f7d283;--gold-line:#ecc16370;--line:#ecc16330;--line-2:#ecc1634d}
:root[data-theme=light]{--gold:#b8862a;--gold-ink:#875c10;--gold-line:#e0be78;--au:#c99434;--au-2:#ecc163;--au-3:#9a6a1e}

/* ---------- Gold-family accents: richer antique gold with bronze depth ---------- */
:root[data-palette=gold][data-theme=dark]{--gold:#f2c665;--gold-ink:#ffd889;--gold-line:#b48a3c;--gold-soft:#4a3613;--au:#f2c665;--au-2:#ffe6a6;--au-3:#c48c38;
  --au-line:#f2c66570;--au-faint:#f2c66538;--line:#f2c6653a;--line-2:#f2c66558}
:root[data-palette=gold][data-theme=light]{--gold:#b07f28;--gold-ink:#7f5512;--gold-line:#dbb66c;--gold-soft:#f7e6c0;--au:#c08a2e;--au-2:#e6b85a;--au-3:#94621c}

/* ---------- Depth: a crisp top highlight, a soft inner shade and a longer, deeper drop shadow ---------- */
:root[data-theme=dark]{
  --shadow:0 1px 0 #ffffff1c inset,0 -12px 24px -18px #000b inset,0 16px 34px -18px #000e;
  --shadow-lift:0 1px 0 #ffffff24 inset,0 28px 54px -24px #000,0 0 0 1px color-mix(in srgb,var(--gold) 22%,transparent);
  --em-shadow:0 1px 0 #ffffff30 inset,0 -16px 28px -14px #000b inset,0 22px 44px -20px #000;
  --em-glow:0 0 0 1px color-mix(in srgb,var(--au-2) 50%,transparent),0 0 30px -6px var(--c-3fd19c66)}
:root[data-theme=light]{
  --shadow:0 1px 0 #ffffffd0 inset,0 1px 2px #3a2c100d,0 14px 32px -16px #3a2c1045;
  --shadow-lift:0 1px 2px #3a2c1014,0 26px 50px -22px var(--c-0a2c2380)}

/* ---------- Smooth switching ---------- */
::view-transition-old(root),::view-transition-new(root){animation-duration:.45s;animation-timing-function:cubic-bezier(.2,.7,.2,1)}
html.theme-fade,html.theme-fade *,html.theme-fade *::before,html.theme-fade *::after{
  transition:background-color .45s ease,border-color .45s ease,color .45s ease,fill .45s ease,stroke .45s ease,box-shadow .45s ease!important}
@media (prefers-reduced-motion:reduce){::view-transition-old(root),::view-transition-new(root){animation:none}}

/* ---------- Theme picker (Settings → Appearance) ---------- */
.theme-field{margin:4px 0 18px}
.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.th-opt{position:relative;display:flex;flex-direction:column;gap:9px;padding:8px 8px 11px;border-radius:var(--r-sm,14px);text-align:start;
  border:1px solid var(--line-2);background:color-mix(in srgb,var(--paper) 70%,transparent);color:var(--ink);
  transition:border-color .2s,box-shadow .25s,transform .15s var(--ease,ease),background-color .3s}
.th-opt:hover{border-color:var(--gold-line)}
.th-opt:active{transform:scale(.97)}
.th-opt[aria-checked=true]{border-color:var(--gold);background:color-mix(in srgb,var(--gold) 9%,var(--paper));
  box-shadow:0 0 0 1px var(--gold),0 10px 24px -16px color-mix(in srgb,var(--gold) 80%,transparent)}
.th-opt:focus-visible{outline:2px solid var(--gold);outline-offset:2px}

/* Mini preview: page background, a card with its accent line, a diamond and a primary button. */
.th-pv{position:relative;display:block;height:68px;border-radius:10px;overflow:hidden;background:var(--pv-bg);
  box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--pv-ink) 14%,transparent)}
.th-half{position:absolute;inset:0;background:var(--pv-bg)}
.th-half+.th-half{clip-path:polygon(100% 0,100% 100%,0 100%)}
.th-card{position:absolute;inset:12px 30% 14px 10px;border-radius:7px;background:var(--pv-card);
  border:1px solid color-mix(in srgb,var(--pv-accent) 45%,transparent);box-shadow:0 6px 12px -8px #0008}
.th-card::before,.th-card::after{content:"";position:absolute;inset-inline-start:8px;height:4px;border-radius:2px}
.th-card::before{top:9px;width:42%;background:var(--pv-ink);opacity:.85}
.th-card::after{top:19px;width:24%;height:2px;background:var(--pv-accent)}
.th-dia{position:absolute;inset-inline-start:calc(70% - 26px);top:8px;width:9px;height:9px;transform:rotate(45deg);
  border:1.5px solid var(--pv-accent);background:radial-gradient(var(--pv-accent) 35%,transparent 40%)}
.th-btn{position:absolute;inset-inline-end:8px;bottom:10px;width:30%;height:14px;border-radius:999px;background:var(--pv-btn);
  box-shadow:0 0 0 1px color-mix(in srgb,var(--pv-accent) 70%,transparent)}
.th-txt{display:grid;gap:1px;padding-inline:3px}
.th-name{font-weight:600;font-size:13.5px;line-height:1.25}
.th-sub{font-size:11.5px;color:var(--muted);line-height:1.3}
.th-check{position:absolute;top:13px;inset-inline-end:13px;width:22px;height:22px;border-radius:50%;display:grid;place-items:center;
  background:var(--gold);color:#1a1405;box-shadow:0 2px 6px -2px #0009;opacity:0;transform:scale(.6);transition:opacity .2s,transform .25s var(--ease,ease)}
.th-check .ic{width:13px;height:13px;stroke-width:2.6}
.th-opt[aria-checked=true] .th-check{opacity:1;transform:none}
@media (max-width:420px){.theme-grid{grid-template-columns:1fr 1fr}.th-pv{height:60px}}
