/* Gold Shop Sites · base system "Crucible" (tokens, type, controls, data display).
   Every screen reads this file: public site (site.css on top), member, admin and console (admin.css on top).
   Same language as the approved landing page: warm black, real gold, ivory, Archivo variable,
   square cuts, 1px hairlines, full-bleed bands with a thin gutter. No shadows on cards, no pills.
   Themes: html[data-theme] = night (default) | ivory (shop option) | day (admin daylight surface). */

:root {
  --gold: #d9a84e;          /* set from the shop's metal colour by shop.js */
  --gold-hi: #f4d58d;
  --gold-lo: #8a6420;
  --pad: clamp(16px, 2.4vw, 44px);
  --font: "Archivo", "Helvetica Neue", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --head: 68px;
  --ok: #7fb685; --warn: #e3b25a; --bad: #e0806b;
}
html, html[data-theme="night"] {
  --ground: #0c0907; --ground-2: #15100b; --ground-3: #1d1610; --ground-glass: rgba(12, 9, 7, 0.82);
  --ink: #f1e9da; --ink-dim: #b9ad99; --ink-faint: #8a7f6e; --accent: var(--gold-hi);
  --line: rgba(217, 168, 78, 0.22); --line-2: rgba(217, 168, 78, 0.12); --line-ink: rgba(241, 233, 218, 0.4);
  --glow: rgba(217, 168, 78, 0.12);
  --field: radial-gradient(80% 90% at 30% 40%, #f1cf83, #e2b863 55%, #c79237);
  --on-field: #0c0907; --on-field-dim: #4a3416;
  --on-gold: #0c0907;
  --ok-ink: #9fd0a4; --warn-ink: #f0c879; --bad-ink: #f0a08c;
  color-scheme: dark;
}
html[data-theme="ivory"], html[data-theme="day"] {
  --ground: #f3ece0; --ground-2: #ebe2d3; --ground-3: #e2d7c5; --ground-glass: rgba(243, 236, 224, 0.86);
  --ink: #1b130b; --ink-dim: #5f5040; --ink-faint: #6c5c48; --accent: #855610;
  --line: rgba(138, 90, 18, 0.28); --line-2: rgba(138, 90, 18, 0.14); --line-ink: rgba(27, 19, 11, 0.42);
  --glow: rgba(214, 160, 70, 0.22);
  --field: radial-gradient(80% 90% at 30% 40%, #2a1e12, #140e09 60%, #0a0705);
  --on-field: #f1e9da; --on-field-dim: #c5b79f;
  --on-gold: #1b130b;
  --ok-ink: #2f6b3a; --warn-ink: #8a5a00; --bad-ink: #a2361f;
  color-scheme: light;
}
/* day = the admin's daylight surface: same ivory, a touch brighter for counters by a window */
html[data-theme="day"] { --ground: #f7f2e9; --ground-2: #eee6d8; }

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 420ms; animation-timing-function: var(--ease); }

* { box-sizing: border-box; }
html { background: var(--ground); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--head) + 16px); }
body { margin: 0; min-height: 100dvh; background: var(--ground); font: 400 17px/1.6 var(--font); font-variation-settings: "wdth" 100; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--gold); color: var(--on-gold); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: fixed; left: var(--pad); top: -60px; z-index: 60; background: var(--gold); color: var(--on-gold); padding: 10px 16px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ---------- type ---------- */
.display { margin: 0; font-weight: 300; line-height: 0.94; letter-spacing: -0.035em; font-variation-settings: "wdth" 118; text-wrap: balance; font-size: clamp(2.6rem, 6vw, 7rem); }
.display.xl { font-size: clamp(3rem, 9vw, 11rem); line-height: 0.88; }
.display.md { font-size: clamp(2rem, 3.8vw, 4.2rem); }
.display.sm { font-size: clamp(1.6rem, 2.6vw, 2.8rem); line-height: 1; }
.display em { font-style: normal; color: var(--accent); }
.h2 { margin: 0; font-weight: 300; font-size: clamp(1.5rem, 2.3vw, 2.4rem); line-height: 1.05; letter-spacing: -0.02em; font-variation-settings: "wdth" 116; }
.h3 { margin: 0; font-weight: 500; font-size: 1.04rem; line-height: 1.3; }
.eyebrow { display: block; margin: 0 0 18px; font-size: 0.78rem; font-weight: 500; letter-spacing: 0.16em; line-height: 1.5; text-transform: uppercase; color: var(--ink-dim); }
.eyebrow::before { content: ""; display: inline-block; vertical-align: middle; width: 28px; height: 1px; margin: -2px 12px 0 0; background: var(--gold); }
.eyebrow b { color: var(--accent); font-weight: 500; }
.lede { margin: 18px 0 0; max-width: 44ch; font-size: clamp(1.02rem, 0.95rem + 0.35vw, 1.24rem); line-height: 1.55; color: var(--ink-dim); }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 0.88rem; }
.fine { font-size: 0.8rem; line-height: 1.55; color: var(--ink-dim); }
.num, .tbl td.n, .tbl th.n { font-variant-numeric: tabular-nums; }
.gold { color: var(--accent); }
.wide { font-variation-settings: "wdth" 125; }
.narrow { font-variation-settings: "wdth" 80; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

/* ---------- buttons: square-cut bars, arrow travels on hover ---------- */
.btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; min-height: 52px; padding: 0 18px 0 22px; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 500 0.98rem/1 var(--font); background: var(--gold); color: var(--on-gold);
  transition: transform 450ms var(--ease), background-color 350ms var(--ease), color 350ms var(--ease), box-shadow 350ms var(--ease); }
.btn svg { width: 20px; height: 20px; flex: none; transition: transform 450ms var(--ease); }
.btn:hover { background: var(--gold-hi); }
.btn:hover svg { transform: translateX(4px); }
.btn:active { transform: scale(0.98); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-ink); }
.btn-line:hover { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn-ink { background: var(--ink); color: var(--ground); }
.btn-ink:hover { background: var(--accent); color: var(--ground); }
.btn-quiet { background: transparent; color: var(--ink-dim); padding: 0 12px; }
.btn-quiet:hover { background: var(--ground-2); color: var(--ink); }
.btn-bad { background: transparent; color: var(--bad-ink); box-shadow: inset 0 0 0 1px currentColor; }
.btn-bad:hover { background: transparent; color: var(--bad); }
.btn-sm { min-height: 40px; padding: 0 12px 0 14px; gap: 12px; font-size: 0.9rem; }
.btn-sm svg { width: 18px; height: 18px; }
.btn-lg { min-height: 68px; padding: 0 24px 0 28px; font-size: 1.12rem; }
.btn-block { display: flex; width: 100%; }
.btn-ico { width: 44px; min-height: 44px; padding: 0; justify-content: center; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.lnk { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.lnk:hover { color: var(--ink); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-sb { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 8px; }
.field > label, .field > .lbl, legend.lbl { font-size: 0.86rem; font-weight: 500; color: var(--ink); }
.field .hint { font-size: 0.8rem; color: var(--ink-dim); }
.field .err { font-size: 0.82rem; color: var(--bad-ink); }
.inp, .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; background: transparent; color: var(--ink); border: 0; border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line-ink); font-size: 1rem; transition: box-shadow 300ms var(--ease), background-color 300ms var(--ease); }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field select option { background: var(--ground); color: var(--ink); }
.inp:hover, .field input:hover, .field select:hover, .field textarea:hover { box-shadow: inset 0 0 0 1px var(--ink-dim); }
.inp:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--gold); background: var(--ground-2); }
.field [aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--bad); }
.affix { display: flex; align-items: stretch; box-shadow: inset 0 0 0 1px var(--line-ink); }
.affix:focus-within { box-shadow: inset 0 0 0 2px var(--gold); }
.affix > span { display: flex; align-items: center; padding: 0 12px; color: var(--ink-dim); font-size: 0.92rem; white-space: nowrap; }
.affix > input { box-shadow: none !important; background: transparent !important; }
.grid-f { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px 24px; }
/* segmented choice: a hairline bar split into cells */
.seg { display: inline-flex; flex-wrap: wrap; box-shadow: inset 0 0 0 1px var(--line); }
.seg label, .seg button, .seg a { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; font-size: 0.92rem; color: var(--ink-dim); background: none; border: 0; cursor: pointer; text-decoration: none; transition: color 300ms var(--ease), background-color 300ms var(--ease); }
.seg label + label, .seg button + button, .seg a + a { box-shadow: -1px 0 0 var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover, .seg button:hover, .seg a:hover { color: var(--ink); }
.seg label:has(input:checked), .seg button[aria-pressed="true"], .seg a[aria-current] { background: var(--gold); color: var(--on-gold); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg-block { display: flex; } .seg-block > * { flex: 1; }
/* checkbox and radio rows */
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 0.94rem; cursor: pointer; }
.check input { appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; box-shadow: inset 0 0 0 1px var(--line-ink); display: grid; place-content: center; cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input::after { content: ""; width: 10px; height: 10px; background: var(--gold); transform: scale(0); transition: transform 250ms var(--ease); }
.check input[type="radio"]::after { border-radius: 50%; }
.check input:checked { box-shadow: inset 0 0 0 1px var(--gold); }
.check input:checked::after { transform: scale(1); }
/* switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.92rem; min-height: 44px; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--line); position: relative; cursor: pointer; transition: background-color 300ms var(--ease); flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); transition: transform 350ms var(--ease); }
.switch input:checked { background: var(--gold); }
.switch input:checked::after { transform: translateX(18px); background: var(--on-gold); }
/* range: thin gold track */
input[type="range"].rng { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; cursor: pointer; margin: 0; }
input[type="range"].rng::-webkit-slider-runnable-track { height: 1px; background: linear-gradient(90deg, var(--gold) var(--fill, 50%), var(--line-ink) var(--fill, 50%)); }
input[type="range"].rng::-moz-range-track { height: 1px; background: var(--line-ink); }
input[type="range"].rng::-moz-range-progress { height: 1px; background: var(--gold); }
input[type="range"].rng::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -11px; background: var(--gold); border: 0; transform: rotate(45deg); transition: transform 250ms var(--ease); }
input[type="range"].rng::-moz-range-thumb { width: 18px; height: 18px; background: var(--gold); border: 0; border-radius: 0; transform: rotate(45deg); }
input[type="range"].rng:active::-webkit-slider-thumb { transform: rotate(45deg) scale(1.2); }

/* ---------- data ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.tbl caption { text-align: left; padding: 0 0 12px; font-size: 0.86rem; color: var(--ink-dim); }
.tbl th { text-align: left; font-weight: 500; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl .n { text-align: right; }
.tbl tbody tr { transition: background-color 250ms var(--ease); }
.tbl tbody tr:hover { background: var(--ground-2); }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 500; }
.tbl a { text-decoration: none; }
.tbl a:hover { color: var(--accent); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kv { display: grid; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-2); font-size: 0.94rem; }
.kv dt { color: var(--ink-dim); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv > div.total { border-top: 1px solid var(--line); border-bottom: 0; padding-top: 16px; font-size: 1.1rem; }
.kv > div.total dd { color: var(--accent); font-weight: 500; }
/* a big number with its label and change */
.stat { display: grid; gap: 6px; align-content: start; }
.stat .k { font-size: 0.82rem; color: var(--ink-dim); display: flex; gap: 8px; align-items: center; }
.stat .v { white-space: nowrap; font-weight: 300; font-size: clamp(2rem, 3.4vw, 3.4rem); line-height: 1; letter-spacing: -0.03em; font-variation-settings: "wdth" 112; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 0.4em; letter-spacing: 0; color: var(--ink-dim); margin-left: 4px; }
.stat .d { font-size: 0.84rem; color: var(--ink-dim); }
.stat .d b { color: var(--ink); font-weight: 500; }
.up { color: var(--ok-ink); } .down { color: var(--bad-ink); }
/* square tags */
.tag { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 9px; font-size: 0.76rem; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-dim); }
.tag::before { content: ""; width: 6px; height: 6px; background: currentColor; display: none; }
.tag.ok { color: var(--ok-ink); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ok-ink) 45%, transparent); }
.tag.warn { color: var(--warn-ink); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn-ink) 45%, transparent); }
.tag.bad { color: var(--bad-ink); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--bad-ink) 45%, transparent); }
.tag.gold { background: var(--gold); color: var(--on-gold); box-shadow: none; }
.tag.ok::before, .tag.warn::before, .tag.bad::before { display: block; }
.tag.live::before { display: block; border-radius: 50%; animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
/* 11 month marks: one cell per month, filled when paid */
.months { display: grid; grid-template-columns: repeat(var(--n, 11), 1fr); gap: 3px; }
.months i { height: 34px; box-shadow: inset 0 0 0 1px var(--line); position: relative; }
.months i.paid, .months i.p { background: var(--gold); box-shadow: none; }
.months i.w { box-shadow: inset 0 0 0 2px var(--warn); background: repeating-linear-gradient(90deg, transparent 0 3px, color-mix(in oklab, var(--warn) 30%, transparent) 3px 4px); }
.months.sm i { height: 14px; }
.months i.skip, .months i.s { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6px); }
.months i.now { box-shadow: inset 0 0 0 2px var(--accent); }
.months-k { display: grid; grid-template-columns: repeat(var(--n, 11), 1fr); gap: 3px; margin-top: 8px; font-size: 0.72rem; color: var(--ink-faint); text-align: center; font-variant-numeric: tabular-nums; }
/* thin progress line */
.meter { height: 3px; background: var(--line-2); position: relative; overflow: hidden; }
.meter > i { position: absolute; inset: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); transform: scaleX(var(--p, 0.5)); transform-origin: left; transition: transform 900ms var(--ease); }

/* ---------- gold pieces (renders from the landing scene) with a glow; label for sample art ---------- */
.piece { position: relative; display: grid; place-items: center; isolation: isolate; }
.piece::before { content: ""; position: absolute; inset: 8%; z-index: -1; background: radial-gradient(closest-side, var(--glow), transparent); }
.piece img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.35)); }
html[data-theme="ivory"] .piece img, html[data-theme="day"] .piece img { filter: drop-shadow(0 24px 30px rgba(80, 50, 10, 0.22)); }
.sample { position: absolute; left: 10px; bottom: 10px; z-index: 2; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
canvas.dust { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* ---------- dialogs and sheets ---------- */
dialog.sheet { border: 0; padding: 0; margin: auto 0 0 auto; width: min(560px, 100vw); height: 100dvh; max-height: 100dvh; max-width: 100vw; background: var(--ground); color: var(--ink); box-shadow: -1px 0 0 var(--line); }
dialog.sheet[open] { animation: sheet-in 520ms var(--ease); }
dialog.sheet::backdrop { background: rgba(6, 4, 3, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } }
.sheet-in { display: flex; flex-direction: column; height: 100%; }
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px var(--pad); border-bottom: 1px solid var(--line); }
.sheet-h h2 { margin: 0; font-weight: 300; font-size: 1.7rem; line-height: 1.05; font-variation-settings: "wdth" 116; }
.sheet-h p { margin: 6px 0 0; font-size: 0.88rem; color: var(--ink-dim); }
.sheet-b { flex: 1; overflow-y: auto; padding: 24px var(--pad); display: grid; gap: 22px; align-content: start; }
.sheet-f { padding: 16px var(--pad) calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 700px) {
  dialog.sheet { width: 100vw; height: auto; max-height: 92dvh; margin: auto 0 0; box-shadow: 0 -1px 0 var(--line); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
}
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; display: flex; gap: 12px; align-items: center; padding: 14px 18px; background: var(--ink); color: var(--ground); font-size: 0.92rem; max-width: calc(100vw - 32px); transition: transform 500ms var(--ease), opacity 400ms var(--ease); }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- reveal on enter (transform + opacity only) ---------- */
.rv { opacity: 0; transform: translate3d(0, 28px, 0); transition: opacity 900ms var(--ease), transform 900ms var(--ease); transition-delay: calc(var(--i, 0) * 60ms); }
.rv.in { opacity: 1; transform: none; }
/* split headlines: each word rises out of its own line mask */
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.04em 0.02em 0.1em; margin: -0.04em -0.02em -0.1em; }
.split .w > span { display: inline-block; transform: translate3d(0, 110%, 0); transition: transform 1000ms var(--ease); transition-delay: calc(var(--d, 0) * 70ms + 80ms); }
.split.in .w > span { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .rv, .split .w > span { opacity: 1 !important; transform: none !important; transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
