/* ===== /key: the redeem flow (key.php + assets/js/redeem.js) =====
   The B system, as on home's "Get your upgrade key" and /status: a poster panel with the
   key entry, then the site .container split in two: the state title + key facts pinned
   left, B cards right (cream / green / purple / dark #141416, radius 28px, pill controls).
   Every text field and picker on this page is the same 56px pill (--key-field-h). */

.key-poster {
  --cream: #f3f1ec;
  --plum: #1d1530;
  --card-dark: #141416;
  --field-bg: #0b0b0d;
  --line: rgba(255, 255, 255, 0.08);
  --muted: #a1a1aa;
  --key-field-h: 56px;
  --poster-tint: #1a4a75;
  padding-bottom: clamp(4rem, 9vw, 7.5rem);
}
.key-poster.is-renew { --poster-tint: #3b2a6b; }
.key-poster .icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Alerts (redeem.js notice(), api.js checkApiKey()). redeem.js uses <p> titles instead of
   api.js's <h3>, to keep heading order. */
.sp-alert {
  --alert: var(--green);
  background: color-mix(in srgb, var(--alert) 10%, #0d0d10);
  border: 1px solid color-mix(in srgb, var(--alert) 35%, transparent);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: #fff;
  scroll-margin-top: 90px;
}
.sp-alert-success { --alert: var(--green); }
.sp-alert-error   { --alert: #f87171; }
.sp-alert-warning { --alert: #fbbf24; }
.sp-alert-info    { --alert: #60a5fa; }
.key-poster .sp-alert { border-radius: 20px; padding: 0.9rem 1.1rem; margin: 0; }
.sp-alert-body { display: flex; align-items: flex-start; gap: 0.75rem; }
.sp-alert svg, .sp-alert .icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; color: var(--alert); }
.sp-alert h3,
.sp-alert-title { margin: 0 0 0.2rem; font-size: 0.9375rem; font-weight: 700; color: var(--alert); }
.sp-alert .api-message-content { margin: 0; font-size: 0.9375rem; line-height: 1.6; color: var(--text-secondary); overflow-wrap: anywhere; }
.sp-alert a { text-decoration: underline; font-weight: 600; }

/* ---------- Poster panel: title + key entry ---------- */
.key-poster .poster-panel {
  --poster-scrim: linear-gradient(180deg, rgba(6, 6, 9, 0.38) 0%, rgba(6, 6, 9, 0.2) 55%, rgba(6, 6, 9, 0.32) 100%);
  display: grid;
  align-content: center;
  min-height: clamp(440px, 62svh, 600px);
  margin: 0 var(--poster-gutter);
  padding: clamp(2.5rem, 7vh, 4.5rem) clamp(1.5rem, 4.5vw, 5rem);
}
.key-poster-col { width: 100%; max-width: 760px; }
.key-title {
  margin: 0 0 clamp(1.75rem, 4vh, 2.5rem);
  font-family: var(--font-display);
  font-weight: 900;
  font-synthesis: none;
  font-size: clamp(2.6rem, 11vw, 5.75rem);
  line-height: 0.86;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: #fff;
}
@media (min-width: 821px) { .key-title { font-size: clamp(3.5rem, 7.4vw, 5.75rem); } }
.key-entry-label { display: block; margin: 0 0 0.75rem 1.25rem; font-size: 1rem; font-weight: 600; color: rgba(255, 255, 255, 0.9); }

/* One frosted pill holding the field and the Check key button. */
.key-form-row {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(8, 8, 12, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.key-form-row:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }
.key-input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 0 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.key-input:focus { outline: none; }
.key-input::placeholder { color: rgba(255, 255, 255, 0.45); }

/* Pills: Check key (panel) and the form's submit. Text first, arrow after, like .poster-btn. */
.key-check-btn,
.key-submit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 54px;
  padding: 0 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #0a0a0a;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, gap 0.3s var(--ease-out), transform 0.2s var(--ease-out);
}
.key-check-btn:hover,
.key-submit:hover { background: var(--green-hover); gap: 0.75rem; }
.key-check-btn:active,
.key-submit:active { transform: scale(0.98); }
.key-check-btn:focus-visible,
.key-submit:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.key-check-btn:disabled,
.key-submit:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.key-buy-link { margin: 1rem 0 0 1.25rem; font-size: 0.9375rem; color: #fff; }
.key-buy-link a { color: #fff; font-weight: 600; text-decoration: underline; }

.key-alerts { margin-top: 1rem; }
.key-alerts:empty { display: none; }
.key-alerts .sp-alert {
  background: rgba(8, 8, 12, 0.55);
  border-color: color-mix(in srgb, var(--alert) 55%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.key-alerts .sp-alert .api-message-content { color: rgba(255, 255, 255, 0.82); }

/* ---------- Result: state pinned left, cards right (home .offers / status .status-split) ---------- */
.key-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 680px);
  gap: clamp(2rem, 5vw, 6rem);
  align-items: start;
  padding-top: clamp(3rem, 7vw, 6rem);
  outline: none;
  scroll-margin-top: var(--nav-clear);
}
.key-side { position: sticky; top: calc(var(--nav-clear) + 20px); min-width: 0; }
.key-state-title {
  margin: 0;
  max-width: 9em;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 900;
  font-synthesis: none;
  line-height: 0.9;
  letter-spacing: -0.015em;
  word-spacing: -0.06em;
  text-transform: uppercase;
  color: #fff;
}
.key-side-code { margin: 1.5rem 0 0; }
.key-side-code code {
  padding: 0;
  background: none;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

/* Key facts: quiet label / value rows on hairlines. */
.key-details { margin: 1.25rem 0 0; max-width: 26rem; }
.key-detail {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}
.key-detail:last-child { border-bottom: 1px solid var(--line); }
.key-detail dt { color: var(--muted); }
.key-detail dd { margin: 0; display: flex; align-items: center; gap: 0.5rem; min-width: 0; color: #fff; font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.key-copy {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.key-copy:hover { color: #fff; border-color: rgba(255, 255, 255, 0.32); }
.key-copy:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.key-main { display: grid; gap: 12px; min-width: 0; }

/* ---------- B cards ---------- */
.key-card {
  --ink: #fff;
  --ink-2: var(--muted);
  min-width: 0;
  padding: 26px 30px 30px;
  border-radius: 28px;
  background: var(--card-dark);
  border: 1px solid var(--line);
  color: var(--ink);
}
.key-card-title {
  display: block;
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 0.9vw, 1.75rem);
  font-weight: 900;
  font-synthesis: none;
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--ink);
}

/* Status card colour by state: green = done, purple = live, cream = needs you. */
.key-status { --ink: #0c0c0d; --ink-2: #57534a; --line-in: rgba(12, 12, 13, 0.12); background: var(--cream); border-color: transparent; }
.key-result:is([data-state="done"], [data-state="submitted"]) .key-status { --ink: #03170a; --ink-2: #0a3a1b; --line-in: rgba(3, 23, 10, 0.18); background: var(--green); }
.key-result:is([data-state="tracking"], [data-state="backorder"]) .key-status { --ink: #fff; --ink-2: #c9bfe0; --line-in: rgba(255, 255, 255, 0.12); background: var(--plum); }

.key-result-text { max-width: 52ch; color: var(--ink-2); font-size: 1.0625rem; line-height: 1.55; }
.key-result-text:empty { display: none; }
.key-result-text p { margin: 0; }
.key-result-text p + p { margin-top: 0.75rem; }
.key-result-text strong { color: var(--ink); }
.key-status a { color: var(--ink); font-weight: 600; text-decoration: underline; }
.key-result-note { margin: 0; color: var(--ink); font-weight: 600; }
.key-result-text:not(:empty) + .key-result-note { margin-top: 0.75rem; }

/* Live facts: big numbers, like the /status tiles. */
.tracker-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.25rem 1.5rem;
  margin: 1.5rem 0 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--line-in);
  list-style: none;
}
.tracker-facts li { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.fact-label { font-size: 0.875rem; color: var(--ink-2); }
.fact-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  font-weight: 900;
  font-synthesis: none;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.live-updated { display: flex; align-items: center; gap: 0.5rem; margin: 1.25rem 0 0; font-size: 0.875rem; color: var(--ink-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.key-result:is([data-state="done"], [data-state="submitted"]) .live-dot { background: #03170a; }

/* Card actions: the offer-card pill (ink on the card colour). */
.key-result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.5rem; }
.key-action {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s var(--ease-out);
}
.key-action::after { content: "\2192"; margin-left: 8px; transition: transform 0.3s var(--ease-out); }
.key-action:hover::after { transform: translateX(3px); }
.key-action:active { transform: scale(0.98); }
.key-action:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.key-result:is([data-state="tracking"], [data-state="backorder"]) .key-action { background: #fff; color: var(--plum); }
.key-action.is-danger { background: transparent !important; color: #ffb3b3 !important; box-shadow: inset 0 0 0 1.5px rgba(255, 179, 179, 0.55); }
.key-action.is-danger::after { content: none; }
.key-action.is-danger:hover { background: rgba(255, 120, 120, 0.12) !important; }
.key-action:disabled { opacity: 0.55; cursor: progress; }

/* ---------- The redeem form: a sequence of cards, no wrapper card ---------- */
.redeem-form { display: grid; gap: 12px; }

.key-field,
.key-poster .cdd-button {
  width: 100%;
  min-height: var(--key-field-h);
  padding: 0 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: var(--field-bg);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.key-field::placeholder { color: #71717a; }
.key-field:hover,
.key-poster .cdd-button:hover { border-color: rgba(255, 255, 255, 0.24); background: var(--field-bg); }
.key-field:focus,
.key-poster .cdd-button:focus-visible,
.key-poster .cdd.is-open .cdd-button {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 28%, transparent);
  background: var(--field-bg);
}
.key-poster .cdd-menu { top: calc(100% + 8px); border-radius: 22px; background: #1a1a1d; }
.key-poster .cdd-search { min-height: 44px; margin: 0.6rem; padding: 0 1rem; border-radius: 999px; }

.key-field-label { display: block; margin: 0 0 0.6rem; font-size: 0.9375rem; font-weight: 600; color: var(--ink); }
.form-label-optional { font-weight: 400; color: var(--ink-2); }
.form-hint { max-width: 62ch; margin: 0.75rem 0 0; font-size: 0.875rem; line-height: 1.55; color: var(--muted); }
.key-card-lead { margin: -0.25rem 0 1rem; font-size: 0.9375rem; color: var(--ink-2); }
.form-hint code { padding: 0.1em 0.35em; border-radius: 4px; background: rgba(255, 255, 255, 0.08); color: #e4e4e7; font-size: 0.9em; }
.redeem-form a { color: var(--green); text-decoration: underline; }

.cookie-check { display: block; margin-top: 0.5rem; font-size: 0.875rem; }
.cookie-check:empty { display: none; }
.cookie-check[data-state="ok"] { color: #4ade80; }
.cookie-check[data-state="warn"] { color: #fbbf24; }

.redeem-form .fs-disclosure { margin-top: 1rem; border-radius: 22px; border-color: var(--line); }
.redeem-form .fs-disclosure > summary { min-height: 48px; border-radius: 22px; }
.redeem-form .fs-disclosure > summary > span { font-size: 0.9375rem; }
.redeem-form .fs-disclosure-body { max-width: 62ch; color: #c4c4c8; font-size: 0.9rem; }
.redeem-form .fs-disclosure ul { margin: 0; padding-left: 1.1rem; list-style: disc; display: grid; gap: 0.35rem; line-height: 1.5; }

/* Backorder card: dark until it's on (or stock is out), then purple. The whole head is the hit area. */
.bo-card { padding: 0; transition: background-color 0.25s ease, border-color 0.25s ease; }
.bo-card:is(.is-soldout, :has(.bo-switch:checked)) { --ink-2: #c9bfe0; background: var(--plum); border-color: transparent; }
.bo-head { display: flex; align-items: center; gap: 1.25rem; padding: 26px 30px; cursor: pointer; }
.bo-text { flex: 1; min-width: 0; display: grid; gap: 0.5rem; font-size: 0.9375rem; line-height: 1.5; color: var(--ink-2); }
.bo-text .key-card-title { margin: 0; }
.bo-options { padding: 0 30px 28px; }

/* The switch: a 56x32 pill drawn on a bare checkbox. */
.key-poster input.bo-switch {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 56px;
  height: 32px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.key-poster input.bo-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  transform: none;
  transition: transform 0.25s var(--ease-out);
}
.key-poster input.bo-switch:checked { background: var(--green); }
.key-poster input.bo-switch:checked::after { transform: translateX(24px); }
.key-poster input.bo-switch:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.form-alert:empty { display: none; }
.key-submit { justify-self: start; min-height: var(--key-field-h); margin-top: 0.5rem; padding: 0 2rem; }
.key-submit svg { width: 18px; height: 18px; }

/* ---------- Narrow: stack, nothing sticky ---------- */
@media (max-width: 900px) {
  .key-result { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
  .key-side { position: static; }
  .key-state-title { max-width: none; }
  .key-details { max-width: none; }
}
@media (max-width: 560px) {
  .key-poster .poster-panel { min-height: 0; padding: 2.5rem 1.25rem 2rem; align-content: start; }
  .key-form-row { flex-direction: column; gap: 10px; padding: 0; border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .key-form-row:focus-within { box-shadow: none; }
  .key-input {
    flex: none;
    padding: 0 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 8, 12, 0.42);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .key-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }
  .key-check-btn,
  .key-submit { width: 100%; }
  .key-buy-link { margin-left: 0; text-align: center; }
  .key-entry-label { margin-left: 0; }
  .key-card { padding: 22px 20px 24px; border-radius: 24px; }
  .bo-card { padding: 0; }
  .bo-head { padding: 22px 20px; gap: 1rem; }
  .bo-options { padding: 0 20px 22px; }
  .key-action { flex: 1 1 auto; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .key-form-row, .key-check-btn, .key-submit, .key-action, .key-action::after,
  .bo-card, .key-poster input.bo-switch, .key-poster input.bo-switch::after { transition: none; }
}
