/*
 * Ported from docs/checkout-project/prototypes/v1-wizard.html.
 *
 * One thing was deliberately left out of the port, per the V1 plan:
 *   - The .screen/.visible JS-driven display toggle: in Rails each wizard
 *     step is a full page, so a screen just renders (kept the .screen
 *     entrance animation, dropped the show/hide rule).
 *
 * The #dock mobile bottom-drawer (stepper/basket reparented by the dock
 * Stimulus controller into a fixed footer with a proxied CTA) is ported
 * below, alongside the responsive .layout rule it replaces at ≤880px.
 */

:root {
  --blue: #4a6ff0;        /* action blue */
  --blue-dark: #b9c8ff;   /* periwinkle emphasis: headings, prices */
  --blue-tint: #1b2650;
  --ink: #e8ebf6;
  --muted: #97a1c3;
  --hairline: #27325c;
  --paper: #0a112b;
  --card: #111b3e;
  --gold: #c9a76a;
  --green: #52c48d;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(3,6,20,.5), 0 10px 34px rgba(3,6,20,.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; color-scheme: dark; }
body {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: radial-gradient(1100px 520px at 50% -120px, #152150, var(--paper) 62%) fixed;
  line-height: 1.55;
}
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
h1 { font-weight: 650; }

/* ---------- Header ---------- */
/* Light masthead carrying the brand logo as-is, over the dark page */
header {
  background: #f7f6f1;
  border-bottom: 1px solid #e4e1d8;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo img { height: 54px; display: block; }
.secure { font-size: 12px; color: #6b6b76; display: flex; align-items: center; gap: 6px; }
.secure svg { flex: none; }

/* ---------- Stepper ---------- */
.stepper {
  max-width: 1080px; margin: 0 auto; padding: 22px 24px 0;
  display: flex; gap: 8px; align-items: center;
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
.step .dot {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--hairline);
  display: grid; place-items: center; font-size: 11px; background: var(--card);
}
.step.active { color: var(--blue-dark); font-weight: 600; }
.step.active .dot { background: var(--blue); border-color: var(--blue); color: #fff; }
.step.done { color: var(--blue-dark); cursor: pointer; }
.step.done .dot { background: var(--blue-tint); border-color: var(--blue); color: var(--blue); }
.step-rule { flex: 1; height: 1px; background: var(--hairline); min-width: 14px; }
@media (max-width: 640px) { .step span.label { display: none; } .step.active span.label { display: inline; } }

/* ---------- Layout ---------- */
.layout {
  max-width: 1080px; margin: 0 auto; padding: 26px 24px 80px;
  display: grid; grid-template-columns: 1fr 340px; gap: 32px; align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto, letting content min-width blow the
   track out past the viewport on narrow screens. */
.layout > main, .layout > .basket { min-width: 0; }

.screen { animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.screen h1 { font-size: 34px; line-height: 1.15; margin-bottom: 6px; color: var(--blue-dark); }
.lede { color: var(--muted); margin-bottom: 26px; max-width: 52ch; }

.panel {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
}
.panel h2 { font-size: 21px; margin-bottom: 14px; color: var(--ink); }

/* ---------- Invoice hero ---------- */
.invoice-hero { display: flex; justify-content: space-between; gap: 18px; align-items: baseline; flex-wrap: wrap; }
.invoice-hero .desc { font-family: var(--serif); font-size: 20px; font-weight: 500; max-width: 40ch; }
.invoice-hero .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.invoice-hero .amount { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--blue-dark); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; margin-bottom: 5px; color: var(--ink); }
input[type=text], input[type=email], input[type=tel], select {
  width: 100%; padding: 11px 12px; font: inherit; font-size: 14px;
  border: 1px solid #303c6f; border-radius: 7px; background: #0d1636; color: var(--ink);
}
input::placeholder { color: #5a6591; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }

/* Dims the address fields when "Collect from our office" is chosen — driven
   entirely by :has(), no JS. #address-fields lives in an earlier panel than the
   collect radio, so the :has() has to be rooted at their common ancestor, the form. */
form:has(#delivery_info_fulfilment_collect:checked) #address-fields { opacity: .45; }

/* ---------- Option cards (shipping / payment) ---------- */
.opt {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; cursor: pointer; background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.opt:hover { border-color: #3d4d8f; }
.opt.selected, .opt:has(> input:checked) { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; background: var(--blue-tint); }
.opt input { margin-top: 3px; accent-color: var(--blue); width: 16px; height: 16px; flex: none; }
.opt .opt-body { flex: 1; }
.opt .opt-title { font-weight: 600; font-size: 15px; }
.opt .opt-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.opt .opt-price { font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--blue-dark); white-space: nowrap; margin-left: auto; }
.opt .opt-price.free { color: var(--green); }

.badge {
  display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; vertical-align: 2px; margin-left: 8px;
}
.badge.rec { background: var(--blue); color: #fff; }
.badge.save { background: rgba(82,196,141,.14); color: var(--green); }

.hint-zone { font-size: 13px; color: var(--muted); margin: -4px 0 14px; }

/* Insurance tier pills inside the insured-shipping option */
.tiers { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tier {
  position: relative;
  font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--hairline); border-radius: 99px; padding: 8px 16px;
  background: #0d1636; color: var(--muted);
  display: flex; gap: 9px; align-items: baseline;
}
/* The pill is a label around a real radio input, styled entirely via :has() —
   the input itself is stretched invisibly over the pill for a full-pill click target. */
.tier input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tier b { font-family: var(--serif); font-size: 14.5px; color: var(--blue-dark); }
.tier:hover { border-color: #3d4d8f; }
.tier.on, .tier:has(> input:checked) { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; background: var(--blue-tint); color: var(--ink); }

/* Demoted secondary payment option */
.opt-compact { padding: 11px 16px; opacity: .7; }
.opt-compact .opt-title { font-size: 13.5px; font-weight: 500; }
.opt-compact .opt-sub { font-size: 12px; }
.opt-compact.selected, .opt-compact:hover { opacity: 1; }

/* ---------- Buttons ---------- */
.actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; }
.btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: 13px 26px; border: 1px solid transparent;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #3a5cd8; }
.btn-primary:disabled { background: #2a3565; color: #7b85ad; cursor: not-allowed; }
.btn-big { padding: 16px 34px; font-size: 16px; }
.btn-ghost { background: none; border: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 13px 4px; cursor: pointer; font: inherit; font-size: 14px; }
.btn-ghost:hover { color: var(--ink); }
.err { color: #ff8b81; font-size: 13px; margin-top: 10px; display: none; }
.err.visible { display: block; }

.paid-warning {
  grid-column: 1 / -1; padding: 14px 18px;
  background: rgba(201, 167, 106, .12); border: 1px solid var(--gold); border-radius: var(--radius);
  color: var(--gold); font-size: 13.5px;
}

/* ---------- Invoice gate (root landing page) ---------- */
/* No stepper, no basket, one job: verify the invoice/email pair. The card
   floats alone, so .layout is re-centred on a narrower single track rather
   than the wizard's content+basket grid — scoped to :has(.gate) so the
   wizard steps are untouched. */
.layout:has(.gate) {
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
  padding-top: clamp(48px, 12vh, 120px);
}
.gate-card { padding: 36px 32px; margin-bottom: 0; }
.gate-card h1 { text-align: center; }

/* Reserves a line's height above the fields whether or not there's a
   message, so a failed attempt never pushes the fields down. */
.gate-alert {
  min-height: 1.4em;
  margin-bottom: 14px;
  color: #ff8b81;
  font-size: 13px;
  text-align: center;
}

/* The SI prefix reads as the input's own leading segment: the wrapper
   carries the border/background the input normally would, the input itself
   goes bare, and :focus-within highlights the pair as one control. */
.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid #303c6f;
  border-radius: 7px;
  background: #0d1636;
  overflow: hidden;
}
.input-prefix .prefix {
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.input-prefix input[type=text] {
  border: none;
  border-radius: 0;
  background: none;
  padding-left: 3px;
}
.input-prefix input[type=text]:focus { outline: none; }
.input-prefix:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
  border-color: var(--blue);
}

.gate-submit { width: 100%; margin-top: 22px; }

@media (max-width: 880px) {
  /* The wizard reserves space here for the mobile dock drawer, which this
     screen never renders — give the card the ordinary bottom padding back. */
  .layout:has(.gate) { padding-bottom: 80px; }
}

/* ---------- Accessories ---------- */
.promo {
  display: flex; gap: 12px; align-items: center;
  background: linear-gradient(100deg, #223c9e, #4a6ff0);
  color: #fff; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px;
}
.promo .serif { font-size: 17px; }
.promo small { opacity: .85; display: block; font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s;
}
.tile:hover { box-shadow: var(--shadow); }
.tile.added { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f2f0eb; }
.tile .tile-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tile .tile-name { font-family: var(--serif); font-size: 16.5px; font-weight: 600; line-height: 1.25; }
.tile .tile-price { font-size: 14px; }
.tile .tile-price s { color: var(--muted); margin-right: 6px; }
.tile .tile-price b { color: var(--blue-dark); }
.tile .tile-opt { font-size: 12px; color: var(--muted); }
.tile button, .tile .tile-action {
  margin-top: auto; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 9px; border-radius: 7px; border: 1px solid var(--blue); background: transparent; color: var(--blue-dark);
  text-align: center; text-decoration: none; display: block;
}
.tile button:hover, .tile .tile-action:hover { background: var(--blue-tint); }
.tile.added button { background: var(--blue); color: #fff; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22, 25, 40, .5); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: #131e44; border-radius: 14px; max-width: 640px; width: 100%;
  display: grid; grid-template-columns: 260px 1fr; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.25);
  animation: rise .25s ease;
}
@media (max-width: 600px) { .modal { grid-template-columns: 1fr; max-height: 90vh; overflow-y: auto; } }
.modal img { width: 100%; height: 100%; object-fit: cover; background: #f2f0eb; }
.modal .modal-body { padding: 24px; display: flex; flex-direction: column; }
.modal h3 { font-size: 22px; margin-bottom: 4px; }
.modal .modal-price { margin-bottom: 12px; }
.modal .modal-price s { color: var(--muted); margin-right: 8px; }
.modal .modal-price b { font-family: var(--serif); font-size: 20px; color: var(--blue-dark); }
.modal p.desc { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }
.modal .close {
  position: absolute; margin: 10px; background: none; border: none; cursor: pointer;
}
.modal-actions { margin-top: auto; display: flex; gap: 10px; }

/* ---------- Payment screen ---------- */
.pay-opt { position: relative; padding: 20px; }
.pay-opt .benefits { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 13px; color: var(--ink); }
.pay-opt .benefits span { display: flex; gap: 6px; align-items: center; }
.pay-opt .benefits svg { color: var(--green); flex: none; }
.terms {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink);
  padding: 14px 2px 0;
}
.terms input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.terms a { color: var(--blue); }
details.terms-detail { margin-top: 10px; font-size: 13px; color: var(--muted); }
details.terms-detail summary { cursor: pointer; color: var(--blue); }
details.terms-detail ul { margin: 8px 0 0 18px; display: grid; gap: 4px; }

/* ---------- Mock payment ---------- */
.bank-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
@media (max-width: 560px) { .bank-list { grid-template-columns: 1fr; } }
.bank {
  border: 1px solid var(--hairline); border-radius: 8px; padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-weight: 500; background: var(--card); font-size: 14px;
}
.bank.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; background: var(--blue-tint); }
.bank .bank-dot { width: 26px; height: 26px; border-radius: 6px; flex: none; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--blue-tint); border-top-color: var(--blue);
  animation: spin .8s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing { text-align: center; padding: 40px 20px; }
.processing .serif { font-size: 20px; }
.mock-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; }

/* ---------- Confirmation ---------- */
.confirm { text-align: center; padding: 30px 20px 10px; }
.confirm .tick {
  width: 64px; height: 64px; border-radius: 50%; background: rgba(82,196,141,.13); color: var(--green);
  display: grid; place-items: center; margin: 0 auto 18px;
}
.confirm h1 { margin-bottom: 10px; }
.confirm .ref { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin-bottom: 18px; }
.confirm p { max-width: 48ch; margin: 0 auto 12px; color: var(--muted); }
.confirm p b { color: var(--ink); }
.contact-card {
  display: inline-flex; gap: 24px; margin-top: 14px; padding: 16px 26px;
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius); font-size: 14px;
}
.contact-card b { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }

/* ---------- Basket ---------- */
.basket {
  background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; position: sticky; top: 20px;
}
.basket h2 { font-size: 19px; padding-bottom: 12px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px; }
.bline { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; }
.bline .b-name { color: var(--ink); }
.bline .b-sub { font-size: 12px; color: var(--muted); }
.bline .b-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bline .b-amt s { color: var(--muted); font-size: 12px; margin-right: 5px; }
.bline.pending .b-amt, .bline.pending .b-name { color: var(--muted); font-style: italic; }
.b-remove { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
.b-remove:hover { color: #ff8b81; }
.b-total { border-top: 1px solid var(--hairline); margin-top: 6px; padding-top: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.b-total .t-label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.b-total .t-amt { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--blue-dark); font-variant-numeric: tabular-nums; }
.b-total .t-amt.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.06); color: var(--blue); } }
.b-savings { text-align: right; font-size: 12px; color: var(--green); margin-top: 4px; }

/* Mobile: one bottom drawer. The stepper and basket are moved INTO #dock by
   the dock Stimulus controller, and #dock-cta proxies the current screen's
   primary action. */
#dock { display: none; }
@media (max-width: 880px) {
  .layout { padding-bottom: 240px; }
  .actions .btn-primary { display: none; }   /* the drawer's CTA takes over */
  #dock {
    display: block; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: linear-gradient(180deg, #1c2b60, #172250);
    border-top: 1px solid #3d4d9c;
    box-shadow: 0 -14px 36px rgba(3,6,20,.7);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #dock .stepper { margin: 0; padding: 10px 16px 0; max-width: none; }
  #dock .step .dot { background: rgba(255,255,255,.07); border-color: #3d4d9c; }
  #dock .step.done .dot { background: rgba(74,111,240,.25); }
  #dock-cta { display: block; width: calc(100% - 28px); margin: 12px 14px; padding: 15px; font-size: 16px; }
  #dock .basket {
    position: static; margin: 0; padding: 10px 20px 12px; background: transparent;
    border: none; border-top: 1px solid #2f3d7d; border-radius: 0; box-shadow: none;
  }
  #dock .basket.expanded .b-total { border-top-color: #2f3d7d; }
  #dock .bline .b-sub, #dock .b-total .t-label { color: #a9b3d6; }
  .basket h2 { display: none; }
  .basket .b-lines { display: none; max-height: 40vh; overflow-y: auto; }
  .basket.expanded .b-lines { display: block; }
  .basket:not(.expanded) .b-savings { display: none; }
  .b-total { cursor: pointer; border-top: none; margin-top: 0; padding-top: 0; align-items: center; }
  .basket.expanded .b-total { border-top: 1px solid var(--hairline); padding-top: 12px; margin-top: 8px; }
  .b-total .t-label::after { content: " · view"; color: var(--blue-dark); }
  .basket.expanded .b-total .t-label::after { content: " · hide"; }
  .b-total .t-amt { font-size: 22px; }
}

footer { text-align: center; font-size: 12px; color: var(--muted); padding: 0 24px 40px; }
