/* TRACE IN THE DARK — MARK 002 / SECOND MARK.
   Loaded last on every public page. Colours only; layout and checkout logic stay in their own files.
   Contrast (WCAG AA): text #EFEFE5 on #0B0A09 ≈ 17:1, muted #BDB6A6 ≈ 9.6:1, cream on maroon #7A1F2B ≈ 8:1,
   maroon-light #E0707F on #0B0A09 ≈ 6:1, input text #161616 on #F2EEE3 ≈ 16:1. */
:root {
  color-scheme: dark;
  --td-bg: #0b0a09;
  --td-surface: #14110f;
  --td-surface-2: #1d1916;
  --td-line: #efefe538;
  --td-text: #efefe5;
  --td-muted: #bdb6a6;
  --td-cream: #e9dfc8;
  --td-maroon: #7a1f2b;
  --td-maroon-light: #e0707f;
  --td-coffee: #6b4a32;
  --td-coffee-light: #c99a74;
  --td-broken: #f2eee3;
  --trace-editorial-rule: var(--td-line);
  --trace-control-ink: #161616;
  --trace-control-paper: var(--td-broken);
  background: var(--td-bg);
  color: var(--td-text);
}
html, body { background: var(--td-bg); color: var(--td-text); }
::selection { background: var(--td-maroon); color: var(--td-cream); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--td-cream); outline-offset: 3px; }

/* Header, footer, shared bands */
.masthead.shell { background: #070605; color: var(--td-text); border-bottom-color: var(--td-line); }
.statement, .phase-about, .trace-contact-footer, .track-order-band { background: var(--td-surface); color: var(--td-text); }
.footer { background: var(--td-bg); color: var(--td-muted); border-top: 1px solid var(--td-line); }
.timeline { background: var(--td-bg); color: var(--td-text); }
.timeline dl, .timeline dl > div { border-color: var(--td-line); }
.trace-contact-link { background: var(--td-bg); color: var(--td-text); border-color: var(--td-line); }
.trace-contact-link:hover { border-color: var(--td-cream); }
.social-link:hover, .social-link:focus-visible { background-color: var(--td-cream); color: var(--td-bg); }
.masthead-bag:hover, .masthead-bag:focus-visible { border-color: var(--td-cream); }

/* Home */
.campaign-hero { background: radial-gradient(120% 90% at 70% 10%, #2a0f14 0%, var(--td-bg) 58%); color: var(--td-text); }
.campaign-caption { background: #0b0a09d9; color: var(--td-text); }
.trace-puzzle { background: var(--td-bg); color: var(--td-text); }

/* Shop */
.shop-page, .first-drop-shop { background: var(--td-bg); color: var(--td-text); }
.first-drop-shop .shop-atmosphere {
  background: radial-gradient(90% 70% at 20% 0%, #3a121a99, transparent 70%),
    radial-gradient(80% 60% at 90% 30%, #4a32228c, transparent 70%), var(--td-bg);
  opacity: 1;
}
.first-drop-shop .shop-heading { border-color: var(--td-line); }
.first-drop-shop .shop-heading .first-drop-edition { color: var(--td-maroon-light); }
.first-drop-dates { color: var(--td-muted); }
.first-drop-stage { --photo-tone: var(--td-broken); }
.first-drop-variant { color: var(--td-muted); }
.first-drop-price { color: var(--td-cream); }
.po1-campaign { color: var(--td-text); }
.po1-campaign .po1-issue { color: var(--td-maroon-light); }
.po1-time span, .po1-time i { color: var(--td-cream); }
.shop-order-button, .trace-primary {
  background: var(--td-maroon); color: var(--td-cream); border-color: var(--td-maroon);
}
.shop-order-button:disabled, .trace-primary:disabled { background: var(--td-surface-2); color: var(--td-muted); border-color: var(--td-line); }

/* Featured card: twice as wide on desktop, full row on mobile */
.first-drop-cards > li.is-featured { grid-column: span 2; }
.first-drop-cards > li.is-featured .first-drop-stage { aspect-ratio: 1.6; --photo-tone: var(--td-cream); }
.first-drop-cards > li.is-featured .first-drop-details h2 { font-size: clamp(1.4rem, 2.6vw, 2.4rem); }
.first-drop-cards > li.is-featured .first-drop-card { outline: 1px solid var(--td-maroon); outline-offset: 6px; }
[data-product-id="brown-double-sleeve-shirt"] .first-drop-stage { --photo-tone: #d9c8b4; }
@media (max-width: 600px) {
  .first-drop-cards > li.is-featured { grid-column: 1 / -1; }
  .first-drop-cards > [data-product-id="sweatshorts"] { grid-column: auto; }
  [data-product-id="sweatshorts"] .first-drop-stage { aspect-ratio: 1; }
  [data-product-id="sweatshorts"] .first-drop-stage img { width: auto; }
}

/* Badges */
.product-badge {
  display: inline-block; width: fit-content; padding: .3rem .5rem; margin: 0;
  background: var(--td-coffee); color: var(--td-broken); font-size: 11px; letter-spacing: .08em;
}
.product-badge-primary { background: var(--td-maroon); color: var(--td-cream); }
.product-badge-new { background: var(--td-coffee); color: var(--td-broken); }
.first-drop-stage .product-badge { position: absolute; z-index: 2; inset: .6rem auto auto .6rem; }
.image-slot {
  display: grid; place-items: center; width: 100%; height: 100%;
  background: repeating-linear-gradient(135deg, #d9c8b4, #d9c8b4 12px, #cdb9a2 12px, #cdb9a2 24px);
  color: var(--td-coffee); font-size: 12px; letter-spacing: .1em;
}

/* Product page, cart, checkout, order */
.trace-product-background, .trace-timeline-background {
  background: linear-gradient(#0b0a09ee, #0b0a09f2), url("/assets/bp-timeline.webp") top center / 94px auto repeat fixed;
  color: var(--td-text);
}
.product-page .item-details, .trace-timeline-background :is(.cart-summary, .checkout-items),
.trace-timeline-background #checkout, .test-panel, .cart-summary {
  background: var(--td-surface); color: var(--td-text); border-color: var(--td-line);
}
.item-details p, .trace-muted, .form-note { color: var(--td-muted); }
.commerce button { background: var(--td-maroon); color: var(--td-cream); }
.commerce button:disabled { background: var(--td-surface-2); color: var(--td-muted); }
.commerce :is(input, select, textarea), .trace-timeline-background :is(input, select, textarea) {
  background: var(--td-broken); color: #161616; border: 1px solid #efefe5aa;
}
.commerce :is(input, select, textarea)::placeholder { color: #5c574e; }
.commerce .product-swatch, #size-options button { background: var(--td-surface-2); color: var(--td-text); border: 1px solid var(--td-line); }
#size-options button[aria-pressed="true"], .product-swatch[aria-pressed="true"] { background: var(--td-cream); color: var(--td-bg); }
.commerce .gallery-image { background: var(--td-broken); }
.trace-test-bar { background: var(--td-maroon); color: var(--td-cream); }
.trace-checkout-steps { border-color: var(--td-line); }
.trace-order-code { background: var(--td-surface-2); border: 1px solid var(--td-maroon); color: var(--td-text); }
.receipt-drop { background: var(--td-surface-2); border-color: var(--td-cream); color: var(--td-text); }
.trace-payment-qr img { background: #fff; padding: .4rem; }
.trace-transfer-details { display: grid; gap: .4rem; margin: .8rem 0; }
.trace-transfer-details div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--td-line); padding-bottom: .3rem; }
.trace-transfer-details dt { color: var(--td-muted); }
.trace-transfer-details dd { margin: 0; color: var(--td-cream); }
.trace-qris-link { display: grid; gap: .4rem; color: var(--td-cream); text-decoration: none; }
.tracking-result, .track-order-form input { color: inherit; }
.track-order-form input { background: var(--td-broken); color: #161616; }
.track-order-form button { background: var(--td-maroon); color: var(--td-cream); }
dialog { background: var(--td-surface); color: var(--td-text); border-color: var(--td-line); }
.drop-notice { background: var(--td-surface); color: var(--td-text); }
.drop-notice-status { background: var(--td-maroon); color: var(--td-cream); }

/* Countdown strip on shop, product, cart, checkout and order pages */
.trace-strip {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem 1rem;
  padding: .45rem var(--edge, 1rem);
  background: var(--td-maroon); color: var(--td-cream); text-decoration: none; font-size: 11px;
}
.trace-strip .clock-unit small { display: none; }
.trace-strip-clock { display: inline-flex; gap: .2rem; font-variant-numeric: tabular-nums; }
.trace-strip-clock b { font-weight: 400; }
html[data-po2-phase="closed"] .trace-strip-clock { display: none; }

/* Shared clock units (home hero, Market Day) */
.trace-clock { display: flex; align-items: flex-start; gap: clamp(.35rem, 1.4vw, .9rem); font-variant-numeric: tabular-nums; }
.trace-clock .clock-unit { display: grid; justify-items: center; gap: .25rem; }
.trace-clock b { font: 900 clamp(2.2rem, 7vw, 5.5rem)/.9 Archivo, Arial, sans-serif; letter-spacing: -.04em; color: var(--td-cream); }
.trace-clock small { font: 400 10px/1 "Geist Pixel", monospace; letter-spacing: .12em; color: var(--td-muted); }
.trace-clock i { font: 900 clamp(1.6rem, 5vw, 4rem)/1 Archivo, sans-serif; color: var(--td-maroon-light); font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .trace-strip, .trace-clock { transition: none; }
}

/* Group badges: NEW ITEMS (Second Mark) and BACK FOR THE SECOND MARK (returning First Mark pieces) */
.product-badge-new, .product-badge-returning {
  display: inline-flex; flex-direction: column; gap: .15rem; width: fit-content;
  font: 900 clamp(.78rem, 1.2vw, 1rem)/1 Archivo, Arial, sans-serif; letter-spacing: .02em; text-transform: uppercase;
  padding: .45rem .6rem;
}
.product-badge-new { background: var(--td-maroon); color: var(--td-cream); }
.product-badge-returning {
  background: var(--td-cream); color: var(--td-maroon);
  border: 2px solid var(--td-maroon); box-shadow: 4px 4px 0 var(--td-maroon); transform: rotate(-2deg);
}
.product-badge-note { font: 400 10px/1.1 "Geist Pixel", monospace; letter-spacing: .08em; opacity: .85; }
.first-drop-stage .product-badge-returning { inset: .7rem auto auto .7rem; }
.first-drop-stage img { position: relative; z-index: 1; }
.shop-order-cta .shop-order-button:not(:disabled) { background: var(--td-maroon); color: var(--td-cream); border-color: var(--td-maroon); }
.shop-order-cta .shop-order-button:not(:disabled):hover { background: var(--td-cream); color: var(--td-maroon); }

/* Sticky header on every page; sits below the countdown strip where there is one. */
.masthead.shell { position: sticky; top: 0; z-index: 35; }
body:has(.trace-strip) .masthead.shell { top: var(--strip-h, 30px); }
.trace-strip { z-index: 36; }

/* Header bag, proportional to the masthead */
.masthead-bag {
  display: inline-grid; place-items: center; position: relative;
  inline-size: 42px; block-size: 42px; border-radius: 50%;
  color: var(--td-cream); border: 1px solid var(--td-line); background: transparent; text-decoration: none;
}
.masthead-bag svg { width: 22px; height: 22px; }
.masthead-bag span {
  position: absolute; top: -4px; right: -4px; min-inline-size: 18px; padding: 1px 5px; border-radius: 9px;
  background: var(--td-maroon); color: var(--td-cream); font: 800 11px/16px Archivo, sans-serif; text-align: center;
}

/* Large floating bag, bottom right */
.floating-cart {
  position: fixed; z-index: 45;
  right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid; place-items: center; align-content: center; gap: 2px;
  inline-size: clamp(64px, 7vw, 78px); block-size: clamp(64px, 7vw, 78px); border-radius: 50%;
  background: var(--td-maroon); color: var(--td-cream); border: 2px solid var(--td-cream);
  box-shadow: 0 10px 30px #000a, 0 0 0 4px #0b0a0966; text-decoration: none;
  transition: transform 180ms ease, background-color 180ms ease;
}
.floating-cart svg { width: 28px; height: 28px; }
.floating-cart-label { font-size: 10px; letter-spacing: .12em; }
.floating-cart span {
  position: absolute; top: -2px; right: -2px; min-inline-size: 24px; padding: 2px 6px; border-radius: 12px;
  background: var(--td-cream); color: var(--td-maroon); font: 900 13px/20px Archivo, sans-serif; text-align: center;
}
.floating-cart:hover { transform: translateY(-2px); background: #8f2533; }
.floating-cart:focus-visible { outline: 3px solid var(--td-cream); outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .floating-cart { transition: none; } }

.bag-closed-note { margin: .6rem 0; color: var(--td-maroon-light); font-weight: 800; }

/* ---------- Payment page ---------- */
/* Larger QRIS */
.payment-page .trace-payment-qr { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.payment-page .trace-qris-link { justify-items: center; }
.payment-page .trace-qris-link img, .payment-page .trace-payment-qr > img {
  width: min(100%, 420px); height: auto; background: #fff; padding: .6rem; border-radius: 6px;
}
/* 15-minute timer */
.payment-timer {
  display: grid; justify-items: start; gap: .2rem; margin: 1.2rem 0 .6rem; padding: .9rem 1rem;
  border: 1px solid var(--td-line); border-left: 4px solid var(--td-cream); background: var(--td-surface-2);
}
.payment-timer strong { font: 900 clamp(2rem, 7vw, 3rem)/1 Archivo, sans-serif; letter-spacing: -.03em; color: var(--td-cream); font-variant-numeric: tabular-nums; }
.payment-timer small { color: var(--td-muted); }
.payment-timer.is-urgent { border-left-color: #e0303f; }
.payment-timer.is-urgent strong { color: #ff6b77; animation: timer-pulse 1s ease-in-out infinite; }
.payment-timer.is-expired { border-left-color: #e0303f; }
.payment-timer.is-expired strong { color: var(--td-muted); animation: none; }
.payment-timer a { color: var(--td-cream); }
@keyframes timer-pulse { 50% { opacity: .55; } }
/* Receipt received: green check */
.receipt-drop.is-done { border-color: #3ccf7a; }
.receipt-success {
  display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border-radius: 6px;
  background: #0f2a1b; border: 1px solid #3ccf7a; color: #d9ffe8; animation: success-in 320ms ease-out both;
}
.receipt-success[hidden] { display: none; }
.receipt-success strong { display: block; font-size: 1.05rem; }
.receipt-success small { color: #a6e8c2; }
.receipt-check svg { width: 46px; height: 46px; fill: none; stroke: #3ccf7a; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.receipt-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 600ms ease-out forwards; }
.receipt-check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 360ms 480ms ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes success-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
/* "I Have Made the Payment" 1.75× */
body.payment-page .payment-main #report #submit-payment {
  min-height: 77px; padding: 1.2rem 1.6rem; font-size: 1.75em; font-weight: 900; width: 100%;
  background: var(--td-maroon); color: var(--td-cream); border: 2px solid var(--td-cream);
}
body.payment-page .payment-main #report #submit-payment:disabled { opacity: .45; border-color: var(--td-line); }
body.payment-page .payment-main #report #submit-payment svg { width: 1.1em; height: 1.1em; }

/* ---------- After payment: ORDER SUBMITTED + comet ---------- */
.order-submitted { display: grid; justify-items: center; gap: .6rem; text-align: center; padding: clamp(1.4rem, 5vw, 2.6rem) 1rem; margin-bottom: 1rem;
  background: radial-gradient(80% 90% at 50% 0%, #2a0f14, var(--td-surface)); border: 1px solid var(--td-line); }
.order-submitted h2 { margin: 0; font: 900 clamp(2.4rem, 9vw, 4.8rem)/.9 Archivo, sans-serif; letter-spacing: -.06em; color: var(--td-cream); }
.order-submitted p { max-width: 30rem; color: var(--td-muted); }
.comet-stage { position: relative; width: 120px; height: 120px; }
.comet-star { position: absolute; left: 50%; top: 50%; width: 76px; transform: translate(-50%, -50%);
  filter: invert(1) drop-shadow(0 0 12px #e9dfc8aa); animation: comet-fly 1.1s cubic-bezier(.2,.7,.2,1) both, comet-fade .35s 1.25s ease forwards; }
.comet-tail { position: absolute; left: 50%; top: 50%; width: 180px; height: 3px; transform-origin: right center;
  transform: translate(-100%, -50%) rotate(-28deg); background: linear-gradient(90deg, transparent, #e9dfc8);
  border-radius: 3px; opacity: 0; animation: tail 1.1s ease-out both; }
.comet-check { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; fill: none; stroke: #3ccf7a; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; animation: comet-fade-in .2s 1.35s forwards; }
.comet-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s 1.4s ease-out forwards; }
.comet-check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s 1.9s ease-out forwards; }
@keyframes comet-fly { from { transform: translate(-260%, 120%) rotate(-40deg) scale(.6); opacity: 0; } 30% { opacity: 1; } to { transform: translate(-50%, -50%) rotate(0) scale(1); } }
@keyframes tail { 0% { opacity: 0; } 25% { opacity: .9; } 100% { opacity: 0; transform: translate(-100%, -50%) rotate(-28deg) scaleX(.2); } }
@keyframes comet-fade { to { opacity: 0; transform: translate(-50%, -50%) scale(.6); } }
@keyframes comet-fade-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .comet-star, .comet-tail { display: none; }
  .comet-check, .comet-check circle, .comet-check path, .receipt-check circle, .receipt-check path { animation: none; opacity: 1; stroke-dashoffset: 0; }
  .payment-timer.is-urgent strong { animation: none; }
}

/* Labschool role / grade / class selects */
.cohort-fields { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); grid-column: 1 / -1; }
.cohort-fields[hidden] { display: none; }

/* Bag page: dark sheet and a normal-sized Secure Checkout button (not a full-width sticky bar) */
.trace-checkout-ui .bag-sheet { background: var(--td-surface); color: var(--td-text); --bag-rule: var(--td-line); --bag-muted: var(--td-muted); border: 1px solid var(--td-line); }
.trace-checkout-ui .bag-sheet :is(.bag-preorder, .bag-extras, .bag-summary, .bag-suggestion, .bag-line) { background: transparent; color: inherit; border-color: var(--td-line); }
.trace-checkout-ui .bag-sheet .bag-suggestion { background: var(--td-surface-2); }
.trace-checkout-ui .bag-sheet .bag-thumbnail, .trace-checkout-ui .bag-sheet .bag-suggestion img { background: var(--td-broken); }
.trace-checkout-ui .bag-sheet .bag-count { color: var(--td-text); border-color: var(--td-line); background: transparent; }
.trace-checkout-ui .bag-sheet .bag-close, .trace-checkout-ui .bag-sheet a { color: var(--td-cream); }
.trace-checkout-ui .bag-stepper button { background: var(--td-surface-2); color: var(--td-text); border-color: var(--td-line); }
.trace-checkout-ui .bag-action {
  position: static; display: flex; justify-content: flex-end; padding: 1rem clamp(.65rem, 3vw, 2.1rem) 1.4rem;
  background: transparent; border-top: 1px solid var(--td-line);
}
.trace-checkout-ui .bag-action a {
  width: auto; min-height: 48px; padding: .75rem 1.4rem; gap: .5rem;
  background: var(--td-maroon); color: var(--td-cream); border: 1px solid var(--td-maroon);
  font-size: .95rem; letter-spacing: .02em; text-decoration: none;
}
.trace-checkout-ui .bag-action a:hover { background: var(--td-cream); color: var(--td-maroon); text-decoration: none; }
.trace-checkout-ui .bag-action a svg { width: 18px; height: 18px; }
@media (max-width: 600px) { .trace-checkout-ui .bag-action a { width: 100%; justify-content: center; } }

/* ---------- Checkout language choice ---------- */
.lang-choice { width: min(420px, calc(100vw - 32px)); padding: 28px 24px 24px; border: 1px solid var(--td-line); border-radius: 4px; background: var(--td-surface); color: var(--td-text); text-align: center; }
.lang-choice::backdrop { background: #000c; backdrop-filter: blur(4px); }
.lang-choice .pixel { margin: 0; color: var(--td-maroon-light); font-size: 11px; letter-spacing: .16em; }
.lang-choice h2 { margin: 10px 0 22px; font-size: 34px; font-weight: 900; line-height: 1; text-transform: uppercase; }
.lang-choice h2 span { display: block; margin-top: 6px; font-size: 16px; font-weight: 600; text-transform: none; color: var(--td-muted); }
.lang-options { display: grid; gap: 10px; }
.lang-options button { min-height: 56px; border: 1px solid var(--td-maroon); border-radius: 2px; background: var(--td-maroon); color: var(--td-cream); font: 800 15px Archivo, sans-serif; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.lang-options button + button { background: transparent; border-color: var(--td-line); color: var(--td-text); }
.lang-options button:hover { background: var(--td-cream); color: var(--td-maroon); border-color: var(--td-cream); }
.lang-switch { position: fixed; z-index: 40; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; padding: 3px; border: 1px solid var(--td-line); border-radius: 20px; background: var(--td-surface); }
.lang-switch button { min-width: 44px; min-height: 36px; border: 0; border-radius: 17px; background: transparent; color: var(--td-muted); font: 800 12px Archivo, sans-serif; letter-spacing: .08em; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--td-cream); color: #161616; }

/* Floating SHOP / HOME side tab removed: the header links and the BAG button cover navigation. */
.shop-edge-tab { display: none !important; }
