/* Order wizard — builds on styles.css */

body.order-page { background: var(--orange-tint); min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) { body.order-page { padding-bottom: 48px; } }

.card {
  background: #fff; border: var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 var(--ink); padding: clamp(16px, 3.5vw, 26px);
}
.stack { display: grid; gap: 16px; }

/* ---------- Header ---------- */

.order-top {
  position: sticky; top: 0; z-index: 30;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 10px;
  background: #fff; border-bottom: var(--border);
}
.order-top-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.order-account { min-width: 40px; display: flex; justify-content: flex-end; }

.steps { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; }
.step-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer; color: var(--ink-soft);
  font: 700 1rem/1 var(--font-display);
}
.step-btn:disabled { cursor: default; opacity: .6; }
.step-num {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--orange-tint); color: var(--ink-soft); border: 2.5px solid #E3CFC5;
}
.step-btn[aria-current="step"] { color: var(--ink); }
.step-btn[aria-current="step"] .step-num { background: var(--orange-strong); color: #fff; border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.step-btn.done .step-num { background: var(--ink); color: #fff; border-color: var(--ink); }
.step-line { width: clamp(24px, 6vw, 70px); height: 5px; border-radius: 5px; background: #EBDDD6; overflow: hidden; }
.step-line span { display: block; height: 100%; width: 0; background: var(--orange-strong); transition: width .5s var(--bounce); }
.step-line.filled span { width: 100%; }

@media (max-width: 720px) {
  .order-top .brand-name { display: none; }
  .step-label { display: none; }
  .step-btn { padding: 4px; }
}

/* ---------- Layout ---------- */

.order-main { padding-block: 18px 40px; }
.back-link { display: inline-block; margin-bottom: 14px; font-weight: 800; color: var(--ink-soft); text-decoration: none; }
.back-link:hover { color: var(--ink); }
.order-intro { margin-bottom: 24px; max-width: 46rem; }
.order-intro h1 { font-size: clamp(2rem, 5vw, 3rem); }
.order-intro p { margin: .5em 0 0; font-size: 1.1rem; font-weight: 600; color: var(--ink-soft); }
.order-intro p:empty { display: none; }

.step-head { margin-bottom: 16px; }
.step-head h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); display: flex; align-items: center; gap: 10px; }
.step-head .hint { margin-top: 6px; font-size: .98rem; }
.step-badge {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--orange-strong); color: #fff; font-size: 1.2rem; box-shadow: 0 3px 0 var(--orange-deep);
}
.step-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
@media (max-width: 899px) { .step-foot .btn { display: none; } } /* the bottom bar takes over on phones */

/* ---------- Step 1: characters ---------- */

.char-add { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: clamp(20px, 3.5vw, 36px); }
.char-fields { display: grid; gap: 16px; align-content: start; }
.seg-sm span { padding: .5em .9em; font-size: .9rem; }
.char-add-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: flex-end; }
.char-add-foot .form-status { flex: 1 1 200px; }
.char-add-foot .form-status:empty { display: none; }

/* Live preview of the character being added */
.char-stage {
  display: grid; align-content: center; justify-items: center; gap: 10px; text-align: center;
  padding: 24px 20px; min-height: 320px; border-radius: var(--radius);
  background: var(--orange-tint); border: 2.5px dashed #E3CFC5;
  transition: background-color .2s, border-color .2s;
}
.char-stage.is-found { background: #fff; border-style: solid; border-color: var(--ink); }
.char-stage.is-missing .stage-text { color: var(--err); }
.stage-avatar {
  display: grid; place-items: center; overflow: hidden; width: clamp(150px, 19vw, 220px); aspect-ratio: 1;
  border-radius: 32px; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
  background: var(--orange); color: #fff; font: 700 4.5rem/1 var(--font-display);
}
.stage-avatar.roblox { background: #3B4252; }
.stage-avatar img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; animation: pop .4s var(--bounce); }
.stage-avatar.roblox img { image-rendering: auto; }
.is-empty .stage-avatar, .is-missing .stage-avatar, .is-busy .stage-avatar {
  background: #fff; color: #E3CFC5; border: 3px dashed #D9C4BA; box-shadow: none;
}
.is-busy .stage-avatar { animation: breathe 1.1s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.96); opacity: .7; } }
.stage-name { margin-top: 6px; font: 700 1.5rem/1.15 var(--font-display); overflow-wrap: anywhere; }
.stage-text { margin: 0; max-width: 32ch; font-weight: 700; font-size: .92rem; color: var(--ink-soft); }
.is-found .stage-text { color: var(--ok); }

@media (max-width: 760px) {
  .char-add { grid-template-columns: 1fr; }
  /* Compact card on phones: avatar left, details right */
  .char-stage {
    order: -1; min-height: 0; padding: 14px; text-align: left;
    grid-template-columns: auto minmax(0, 1fr); justify-items: start; align-content: center; column-gap: 14px; row-gap: 4px;
  }
  .stage-avatar { grid-row: span 3; width: 92px; border-radius: 22px; border-width: 2.5px; box-shadow: 0 4px 0 var(--ink); font-size: 2.4rem; }
  .stage-name { margin-top: 0; font-size: 1.25rem; }
  .stage-text { max-width: none; }
}

.file-pick { position: relative; display: block; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick-ui {
  display: flex; align-items: center; justify-content: center; min-height: 50px; padding: .7em 1em;
  font: 700 1rem/1.2 var(--font-display); color: var(--orange-deep);
  border: 2.5px dashed var(--orange); border-radius: 14px; background: var(--orange-tint);
}
.file-pick:focus-within .file-pick-ui { outline: 3px solid var(--ink); outline-offset: 2px; }

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; margin-top: 20px; }
.char-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px 12px 12px;
  background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: 0 4px 0 var(--ink);
  animation: pop .4s var(--bounce);
}
.char-info { flex: 1; min-width: 0; display: grid; gap: 4px; justify-items: start; }
.char-info strong { font: 700 1.15rem/1.2 var(--font-display); overflow-wrap: anywhere; }
.char-info p { margin: 0; font-size: .88rem; font-weight: 600; color: var(--ink-soft); }
.char-info p.unsynced { color: var(--err); font-weight: 800; }

.headshot {
  flex: none; display: grid; place-items: center; overflow: hidden;
  width: var(--s); height: var(--s); border-radius: calc(var(--s) / 4.5);
  background: var(--orange); color: #fff; font: 700 calc(var(--s) / 2.2) var(--font-display);
  border: 2px solid var(--ink);
}
.headshot.roblox { background: #3B4252; }
.headshot img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.headshot.roblox img { image-rendering: auto; }

.empty-card {
  padding: 28px 20px; text-align: center; font-weight: 700; color: var(--ink-soft);
  border: 2.5px dashed #D9C4BA; border-radius: var(--radius); background: #fff; grid-column: 1 / -1;
}

.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; padding: 0; flex: none;
  color: var(--ink); background: transparent; border: 0; border-radius: 12px; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--orange-tint); }
.icon-btn.danger { color: var(--err); }

/* ---------- Step 2: videos ---------- */

.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
@media (max-width: 899px) { .order-layout { grid-template-columns: 1fr; } }

.slots { display: grid; gap: 22px; }
.slot { display: grid; gap: 18px; animation: pop .4s var(--bounce); }
.slot-head { display: flex; align-items: center; gap: 12px; }
.slot-head h3 { font-size: 1.4rem; margin-right: auto; }
.slot-price { font: 700 1.2rem var(--font-display); color: var(--orange-deep); }

.ref-detect { margin: 0; font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
.ref-detect:empty { display: none; }
.ref-detect.ok { color: var(--ok); }
.ref-detect.warn { color: #8A5A00; }
.ref-detect.busy::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2.5px solid var(--orange); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.yt-probe { position: fixed; left: -9999px; top: 0; width: 200px; height: 120px; overflow: hidden; }

.tier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.tier { position: relative; cursor: pointer; }
.tier input { position: absolute; opacity: 0; pointer-events: none; }
.tier > span {
  display: grid; justify-items: center; gap: 2px; padding: 10px 4px 9px; min-height: 76px; align-content: center;
  border: 2.5px solid #E3CFC5; border-radius: 16px; background: #fff; text-align: center;
  transition: transform .18s var(--bounce), border-color .15s, background-color .15s, box-shadow .15s;
}
.tier strong { font: 700 1.15rem/1 var(--font-display); }
.tier em { font-style: normal; font-weight: 800; font-size: .92rem; color: var(--ink-soft); }
.tier small { font: 700 .68rem/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--orange-deep); }
.tier.highlight > span { border-color: var(--orange); }
.tier:hover > span { transform: translateY(-2px); }
.tier input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 4px 0 var(--orange-strong); }
.tier input:checked + span em, .tier input:checked + span small { color: #FFD6C8; }
.tier input:focus-visible + span { outline: 3px solid var(--orange-strong); outline-offset: 2px; }

.pick-chars { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-char { position: relative; cursor: pointer; }
.pick-char input { position: absolute; opacity: 0; pointer-events: none; }
.pick-char > span {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; min-height: 48px;
  border: 2.5px solid #E3CFC5; border-radius: 999px; background: #fff; font-weight: 800;
  transition: border-color .15s, background-color .15s;
}
.pick-char .headshot { border-radius: 50%; border-width: 1.5px; }
.pick-char input:checked + span { border-color: var(--ink); background: var(--orange-tint); box-shadow: 0 3px 0 var(--ink); }
.pick-char input:checked + span::after { content: '✓'; color: var(--orange-deep); font-weight: 900; }
.pick-char input:focus-visible + span { outline: 3px solid var(--orange-strong); outline-offset: 2px; }

.addon-list { display: grid; gap: 8px; }
.addon {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  border: 2.5px solid #E3CFC5; border-radius: 16px; background: #fff; transition: border-color .15s, background-color .15s;
}
.addon input { width: 22px; height: 22px; accent-color: var(--orange-strong); flex: none; }
.addon > span { flex: 1; display: grid; gap: 2px; }
.addon strong { font: 700 1rem/1.2 var(--font-display); }
.addon small { font-weight: 600; color: var(--ink-soft); font-size: .86rem; }
.addon em { font-style: normal; font-weight: 800; color: var(--orange-deep); white-space: nowrap; }
.addon:has(input:checked) { border-color: var(--ink); background: var(--orange-tint); }

.slot-missing { margin: 0; font-weight: 800; font-size: .92rem; color: #8A5A00; }
.slot-ready { margin: 0; font-weight: 800; color: var(--ok); }
.link-btn-inline { padding: 0; border: 0; background: none; font: inherit; font-weight: 800; color: var(--orange-deep); text-decoration: underline; cursor: pointer; }

.add-slot { margin-top: 18px; }
.bundle-hint { margin: 10px 0 0; text-align: center; font-weight: 800; color: var(--orange-deep); }
.bundle-hint:empty { display: none; }

/* ---------- Summary ---------- */

.summary { position: sticky; top: 92px; display: grid; gap: 14px; }
.summary h2 { font-size: 1.5rem; }
@media (max-width: 899px) { .summary { position: static; scroll-margin-top: 90px; } }
.summary-lines { display: grid; gap: 8px; }
.sl { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.sl span { min-width: 0; }
.sl small { font-weight: 700; color: var(--ink-soft); }
.sl .sl-addons { display: block; font-size: .82rem; }
.sl.muted { color: var(--ink-soft); }
.sl.discount { color: var(--ok); }
.summary-total {
  display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px;
  border-top: 2.5px dashed #E3CFC5; font: 700 1.2rem var(--font-display);
}
.summary-total strong { font-size: 1.9rem; }
.summary-total:empty { display: none; }
.summary-note, .summary-problems .hint { margin: 0; font-size: .86rem; }
.summary-note:empty { display: none; }
.secure-note { margin: 0; font-size: .82rem; text-align: center; }

.ref-form { display: grid; gap: 6px; }
.ref-form label { font: 700 .92rem var(--font-display); }
.ref-row { display: flex; gap: 8px; }
.ref-row input {
  flex: 1; min-width: 0; min-height: 44px; padding: .5em .9em; text-transform: uppercase;
  font: 700 1rem ui-monospace, 'SF Mono', Menlo, monospace; color: var(--ink);
  background: var(--orange-tint); border: 2.5px solid transparent; border-radius: 12px;
}
.ref-row input:focus { outline: none; border-color: var(--orange-strong); background: #fff; }
.ref-row input::placeholder { text-transform: none; font-family: var(--font-body); font-weight: 600; color: #A58D82; }
.ref-form .form-status { font-size: .88rem; min-height: 0; }

/* ---------- Checkout ---------- */

.checkout { display: grid; gap: 10px; }
.checkout-who { margin: 0; font-size: .88rem; font-weight: 700; color: var(--ink-soft); overflow-wrap: anywhere; }
.checkout-who:empty { display: none; }
#paypal-buttons { min-height: 48px; }
.checkout .form-status { font-size: .9rem; min-height: 0; }

/* ---------- Legal: consents, notes, footer ---------- */

.summary-legal { margin: 0; font-size: .84rem; }
.summary-legal:empty { display: none; }
.consents { display: grid; gap: 10px; }
.consent {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 10px 12px; border: 2.5px solid #E3CFC5; border-radius: 14px;
  font-size: .86rem; font-weight: 700; line-height: 1.4; transition: border-color .15s, background-color .15s;
}
.consent input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--orange-strong); }
.consent a { color: var(--orange-deep); }
.consent:has(input:checked) { border-color: var(--ink); background: var(--orange-tint); }
.consent.missing { border-color: var(--err); }
.binding-note { margin: 0; text-align: center; font-size: .82rem; }
.auth-legal { text-align: center; font-size: .8rem; }
.auth-legal a { color: var(--orange-deep); }
.order-foot {
  margin-top: 40px; padding-top: 18px; border-top: 2.5px dashed #E3CFC5;
  font-size: .88rem; font-weight: 700; color: var(--ink-soft); text-align: center;
}
.order-foot a { color: var(--ink); }
.order-foot-seller { display: block; margin-top: 4px; font-weight: 600; }
.order-foot-seller:empty { display: none; }

/* ---------- Account (header) ---------- */

.acct { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: .9rem; }
.acct-link { color: var(--orange-deep); white-space: nowrap; }
.acct-email { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
@media (max-width: 720px) { .acct-email { display: none; } }

/* ---------- Sign-in dialog ---------- */

.auth-dialog {
  width: min(440px, calc(100vw - 32px)); max-width: none; padding: 0; overflow: visible;
  border: 0; background: transparent; color: var(--ink);
}
.auth-dialog::backdrop { background: rgba(35, 21, 15, .7); backdrop-filter: blur(3px); }
.auth-dialog[open] { animation: pop .35s var(--bounce); }
.auth-box {
  position: relative; padding: clamp(20px, 5vw, 30px);
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius-lg); box-shadow: 0 8px 0 var(--orange);
}
.auth-box h2 { font-size: 1.6rem; margin-bottom: 6px; padding-right: 36px; }
.auth-close { position: absolute; top: 12px; right: 12px; font-size: 1.1rem; font-weight: 900; }
.code-input { font: 700 1.5rem ui-monospace, 'SF Mono', Menlo, monospace !important; letter-spacing: .3em; text-align: center; }
.auth-alt { text-align: center; }

/* ---------- Done ---------- */

.done { max-width: 40rem; margin-inline: auto; display: grid; gap: 12px; justify-items: center; text-align: center; }
.done h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.done p { margin: 0; font-weight: 600; }
.done-badge {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: var(--ok); color: #fff; font: 700 2.2rem var(--font-display); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  animation: pop .5s var(--bounce);
}
.done-code { font-size: 1.15rem; }
.done-code strong { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 1.3rem; }
.done-attention { color: #8A5A00; font-weight: 800 !important; }
.done-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.done-discord-alt { max-width: 30rem; }
.done-discord-alt a { color: var(--orange-deep); font-weight: 800; }
body.is-done .mobile-bar, body.is-done .steps { visibility: hidden; }

/* ---------- Mobile bottom bar ---------- */

.mobile-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 32px) calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff; border-top: var(--border); box-shadow: 0 -6px 20px rgba(35, 21, 15, .08);
}
.mobile-bar-info { display: grid; line-height: 1.2; }
.mobile-bar-info span { font-weight: 700; color: var(--ink-soft); font-size: .92rem; }
.mobile-bar-info strong { font: 700 1.35rem var(--font-display); }
.mobile-bar-info strong:empty { display: none; }
@media (min-width: 900px) { .mobile-bar { display: none; } }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); max-width: calc(100vw - 32px); text-align: center;
  padding: .8em 1.3em; border-radius: 22px;
  font: 700 1rem/1.3 var(--font-display); background: var(--ink); color: #fff;
  box-shadow: 0 5px 0 var(--orange-strong); animation: pop .3s var(--bounce);
}
.toast.err { background: var(--err); box-shadow: 0 5px 0 #7E170F; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
