/* ==========================================================
   UnderGroundOps – styles
   Tokens first: re-skin the whole site by editing :root.
   ========================================================== */
:root {
  --bg: #0b0a0d;
  --surface: #141217;
  --surface-2: #1d1a21;
  --border: #2e2a33;
  --text: #ece6e0;
  --muted: #a69fa6;
  --accent: #d4161f;
  --accent-ink: #ffffff;
  --wordmark-red: #ef2a33;  /* brighter red for the store name (4.7:1 on the page background) */
  --accent-text: #ff5a5f;  /* red for text and focus rings on dark surfaces (6:1) */
  --good: #3ecf8e;
  --warn: #f5b84b;
  --bad: #ff8a5c;

  --radius-card: 10px;
  --radius-control: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --container: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font);
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul[role="list"], ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent-text); }
code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }

.container { width: min(100% - 2 * var(--s4), var(--container)); margin-inline: auto; }
.narrow { max-width: 760px; }
.section { padding-block: var(--s7); }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .9rem; }
.notice { padding: var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s4); border-radius: var(--radius-control);
}
.skip-link:focus { top: var(--s2); }

h1 { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.1; letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; margin-bottom: var(--s4); }
h3 { font-size: 1.1rem; margin: var(--s5) 0 var(--s2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s4); border-radius: var(--radius-control);
  border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background-color .15s, border-color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #e0222b; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-block { width: 100%; margin-top: var(--s4); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
label { font-weight: 600; font-size: .95rem; }
input[type="text"], input[type="email"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 40px; padding: var(--s2) var(--s3);
  background: var(--bg); color: var(--text); font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-control);
}
textarea { resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
.field-check { grid-template-columns: auto 1fr; align-items: start; column-gap: var(--s2); }
.field-check input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); }
.field-check label { font-weight: 400; }
.field-check .field-error { grid-column: 1 / -1; }
.field-error, .form-error { color: var(--bad); font-size: .9rem; }
.form-status { font-size: .9rem; color: var(--muted); min-height: 1.4em; margin-top: var(--s2); }
.form-status.ok { color: var(--good); }
.inline { display: flex; gap: var(--s2); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form { margin-top: var(--s4); }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.header-inner { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "brand wallet cart" "search search search"; gap: var(--s2) var(--s3); align-items: center; padding-block: var(--s3); }
.brand { grid-area: brand; justify-self: start; position: relative; display: inline-block; font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.2rem; letter-spacing: .01em; color: var(--text); text-decoration: none; }
.brand-ops { color: var(--wordmark-red); margin-left: .25em; }
.brand::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px; background: var(--wordmark-red); transform: skewX(-35deg); }
.search { grid-area: search; min-width: 0; }
.nav { display: none; }
.wallet-btn { grid-area: wallet; }
.cart-btn { grid-area: cart; }
.count { display: inline-block; min-width: 22px; padding: 0 var(--s2); border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; line-height: 22px; text-align: center; }
@media (max-width: 479px) {
  .header-inner { column-gap: var(--s1); }
  .brand { font-size: 1.1rem; }
  .wallet-btn, .cart-btn { padding-inline: var(--s2); }
}
@media (max-width: 399px) {
  .stats { grid-template-columns: 1fr; }
}
@media (max-width: 359px) {
  .brand { font-size: .95rem; letter-spacing: 0; }
  .wallet-btn, .cart-btn { font-size: .85rem; }
  .count { font-size: .75rem; }
}
@media (max-width: 519px) {
  .header-inner { grid-template-columns: 1fr auto; grid-template-areas: "brand cart" "search wallet"; column-gap: var(--s2); }
}
@media (min-width: 960px) {
  .header-inner { grid-template-columns: auto minmax(180px, 1fr) auto auto auto; grid-template-areas: "brand search nav wallet cart"; }
  .nav { display: flex; gap: var(--s4); grid-area: nav; }
  .nav a { color: var(--text); text-decoration: none; }
  .nav a:hover { color: var(--accent-text); }
}

/* ---------- Hero ---------- */
.hero { padding-block: var(--s7) var(--s6); background: radial-gradient(800px 320px at 8% -10%, rgba(212,22,31,.30), transparent 70%); border-bottom: 1px solid var(--border); }
.hero-layout { display: grid; gap: var(--s5); align-items: center; }
.hero-wordmark { order: -1; width: min(100%, 280px); height: auto; }
@media (min-width: 900px) {
  .hero-layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 440px); gap: var(--s6); }
  .hero-wordmark { order: 0; width: 100%; }
}
.hero-inner > * + * { margin-top: var(--s4); }
.eyebrow { color: var(--accent-text); font-weight: 700; font-size: .95rem; }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 56ch; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s6) !important; max-width: 640px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--s4); }
.stat dt { color: var(--muted); font-size: .85rem; }
.stat dd { font-size: 1.5rem; font-weight: 800; }

/* ---------- Steps ---------- */
.steps { display: grid; gap: var(--s3); counter-reset: step; }
.steps li { counter-increment: step; display: grid; gap: var(--s1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--s4) var(--s4) var(--s4) 64px; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: var(--s4); top: var(--s4); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.steps span { color: var(--muted); }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Promo + wallet promo ---------- */
.promo { background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius-card); padding: var(--s3) var(--s4); }
.wallet-promo { display: grid; gap: var(--s4); align-items: center; background: linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--s5); margin-top: var(--s5); }
.wallet-promo h2 { margin-bottom: var(--s2); font-size: 1.3rem; }
.wallet-promo p { color: var(--muted); }
@media (min-width: 640px) { .wallet-promo { grid-template-columns: 1fr auto; } }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); align-items: end; padding: var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.filters .field { margin: 0; }
.filters .field-check { align-self: center; }
@media (min-width: 1024px) { .filters { grid-template-columns: repeat(4, 1fr) auto auto; } }
.result-count { margin-block: var(--s4); color: var(--muted); min-height: 1.5em; }

/* ---------- Product grid ---------- */
.grid { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cover { aspect-ratio: 16 / 9; display: grid; place-content: center; justify-items: center; gap: var(--s1); font-size: 2.2rem; line-height: 1.1; font-weight: 800; letter-spacing: .04em; color: rgba(255,255,255,.92);
  background: linear-gradient(135deg, hsl(calc(350 + var(--hue) / 30) 40% 22%), hsl(220 22% 9%)); cursor: pointer; }
.card-body { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); flex: 1; }
.card-title { font-size: 1.1rem; margin: 0; }
.card-title .link-btn { font-weight: 700; }
.meta { color: var(--muted); font-size: .9rem; }
.badges { display: flex; flex-wrap: wrap; gap: var(--s1); }
.badge { font-size: .75rem; font-weight: 700; padding: 2px var(--s2); border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, var(--border)); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.badge-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.badge-sale { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.price-row { display: flex; align-items: baseline; gap: var(--s2); margin-top: auto; padding-top: var(--s2); }
.price { font-size: 1.3rem; font-weight: 800; }
.price-was { color: var(--muted); font-size: .9rem; }
.card .btn { margin-top: var(--s2); }
.empty { text-align: center; padding: var(--s6); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-card); }
.empty .btn { margin-top: var(--s3); }

.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s5); }
.pager .btn { min-width: 40px; background: var(--surface); border-color: var(--border); }
.pager .btn[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Trust strip ---------- */
.trust { background: var(--surface); border-block: 1px solid var(--border); padding-block: var(--s5); }
.trust-list { display: grid; gap: var(--s4); }
.trust-list li { display: grid; gap: 2px; }
.trust-list span { color: var(--muted); font-size: .9rem; }
@media (min-width: 640px) { .trust-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .trust-list { grid-template-columns: repeat(4, 1fr); } }

/* ---------- FAQ ---------- */
details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control); margin-bottom: var(--s2); }
summary { cursor: pointer; padding: var(--s3) var(--s4); font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: var(--s3); }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--accent-text); font-size: 1.25rem; line-height: 1; }
details[open] > summary::after { content: "–"; }
details > p { padding: 0 var(--s4) var(--s4); color: var(--muted); }

/* ---------- Legal ---------- */
.legal { background: var(--surface); border-block: 1px solid var(--border); }
.legal h3 { margin-top: var(--s5); }
.legal p, .legal li { color: var(--muted); }
.legal ul { padding-left: var(--s5); }
.details { display: grid; gap: var(--s2); }
.details div { display: grid; grid-template-columns: 140px 1fr; gap: var(--s3); }
.details dt { font-weight: 600; }
.details dd { color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { padding-block: var(--s6) var(--s5); border-top: 1px solid var(--border); }
.footer-grid { display: grid; gap: var(--s5); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.footer-title { font-size: .95rem; color: var(--muted); margin-bottom: var(--s2); }
.site-footer li { margin-bottom: var(--s1); }
.site-footer a { color: var(--text); text-decoration: none; }
.site-footer a:hover { color: var(--accent-text); }
.fineprint { margin-top: var(--s5); color: var(--muted); font-size: .85rem; }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0; width: min(100% - 2 * var(--s4), 720px); max-height: calc(100dvh - 2 * var(--s4)); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.dialog-inner { position: relative; padding: var(--s5); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.dialog-head h2 { margin: 0; }
.dialog-close { position: absolute; top: var(--s3); right: var(--s3); z-index: 1; }
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(100%, 420px); border-radius: 0; border-block: 0; border-right: 0; }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: pop .15s ease-out; }
  .drawer[open] { animation: slide .2s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(8px); } }
  @keyframes slide { from { transform: translateX(24px); opacity: 0; } }
}

/* Product dialog body */
.pd-grid { display: grid; gap: var(--s5); }
@media (min-width: 640px) { .pd-grid { grid-template-columns: 1fr 1fr; } }
.pd-grid .cover { border-radius: var(--radius-card); font-size: 3rem; }
.pd-facts { display: grid; gap: var(--s1); margin-block: var(--s3); font-size: .95rem; }
.pd-facts div { display: flex; gap: var(--s2); }
.pd-facts dt { color: var(--muted); min-width: 90px; }
.pd-buy { display: grid; gap: var(--s3); margin-top: var(--s4); padding: var(--s4); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-card); }
.pd-buy .field { margin: 0; }
.pd-notice { font-size: .9rem; color: var(--muted); }

/* Cart + checkout */
.cart-lines { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }
.cart-line .meta { grid-column: 1; }
.cart-line .price { font-size: 1rem; grid-row: 1; grid-column: 2; }
.qty { display: inline-flex; align-items: center; gap: var(--s1); }
.qty output { min-width: 28px; text-align: center; font-weight: 700; }
.qty .btn { min-height: 32px; min-width: 32px; padding: 0; border-color: var(--border); }
.promo-form { margin-block: var(--s4); }
.totals { display: grid; gap: var(--s1); margin-block: var(--s3); }
.totals div { display: flex; justify-content: space-between; }
.totals dt { color: var(--muted); }
.totals .grand { font-size: 1.15rem; font-weight: 800; padding-top: var(--s2); border-top: 1px solid var(--border); }
.totals .grand dt { color: var(--text); }
.totals .credit dd { color: var(--good); }
.payment { border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--s3) var(--s4) var(--s4); margin: 0 0 var(--s4); }
.payment legend { padding: 0 var(--s2); font-weight: 600; }
.payment-placeholder { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-control); padding: var(--s3) var(--s4); color: var(--muted); font-size: .9rem; margin-bottom: var(--s4); }
.payment .payment-placeholder { margin-bottom: 0; }
.summary { display: grid; gap: var(--s1); }
.summary li { display: flex; justify-content: space-between; gap: var(--s3); color: var(--muted); font-size: .95rem; }
.summary-title { margin-top: var(--s2); }

/* Wallet dialog */
.balance { font-size: 2.5rem; font-weight: 800; line-height: 1.1; margin-bottom: var(--s3); }
.balance-label { font-size: .9rem; }
.code-box { background: var(--bg); border: 1px solid var(--accent); border-radius: var(--radius-card); padding: var(--s3) var(--s4); margin-bottom: var(--s4); }
.code-box code { font-size: 1.05rem; user-select: all; }
.amounts { border: 0; padding: 0; margin: 0 0 var(--s3); }
.amounts legend { font-weight: 600; padding: 0; margin-bottom: var(--s2); }
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.amount { position: relative; }
.amount input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.amount span { display: grid; place-items: center; min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--bg); font-weight: 700; }
.amount input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg)); }
.amount input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.ledger { display: grid; gap: var(--s2); }
.ledger li { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--s3); padding-block: var(--s2); border-bottom: 1px solid var(--border); font-size: .95rem; }
.ledger time { color: var(--muted); font-size: .85rem; }
.ledger .plus { color: var(--good); font-weight: 700; }
.ledger .minus { font-weight: 700; }

/* Confirmation keys */
.key-group { margin-block: var(--s4); }
.key-group h4 { margin: 0 0 var(--s2); }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-control); margin-bottom: var(--s2); }
.key-row code { flex: 1; background: none; font-size: 1rem; user-select: all; word-break: break-all; }
.key-label { color: var(--muted); font-size: .9rem; min-width: 76px; }
.note .link-btn { color: var(--accent-text); text-decoration: underline; }

/* Toast */
/* The toast is a manual popover so it renders in the top layer, above open dialogs.
   Screen readers get the same message from the hidden #live region. */
.toast { position: fixed; inset: auto auto var(--s5) 50%; margin: 0; width: max-content; height: auto; max-width: min(92vw, 420px);
  transform: translate(-50%, 24px); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); padding: var(--s3) var(--s4); border-radius: var(--radius-control);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.cover small { font-size: .9rem; font-weight: 700; letter-spacing: .02em; opacity: .8; }
#co-done .note { margin-block: var(--s3); }

/* Shown when the catalog cannot be loaded from the store API */
.catalog-error { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border: 1px solid var(--bad); border-radius: var(--radius-control); background: var(--bg); }
.catalog-error[hidden] { display: none; }
.catalog-error p { margin: 0; color: var(--bad); flex: 1 1 16rem; min-width: 0; }

/* Headings that are focused by script (so screen readers announce them) are not controls: no ring */
h3[tabindex="-1"]:focus-visible { outline: none; }
