/* Design tokens from the Blueprint Brand Guidelines:
   Blueprint Blue #2121F9, Midnight Blue #0A0F2C, True Blue #4351EF,
   Charcoal #202020, Off-white #DDDDDD. Typeface Grift (falls back to the
   system font until the Grift files are added). White background throughout.
   Spacing 4/8/12/16/24/32/48, radius 14/22/pill, two easing curves. */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F6F9;
  --line: #DDDDDD;
  --ink: #202020;
  --muted: #5B5B66;
  --accent: #2121F9;
  --accent-ink: #FFFFFF;
  --true-blue: #4351EF;
  --midnight: #0A0F2C;
  --accent-wash: #EFEFFE;
  --accent-soft: #D7D7FD;
  --plan: #B4B4F3;
  --grid: #EBEBFD;
  --success: #12704A;
  --danger: #B42318;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 14px; --r-lg: 22px; --r-pill: 999px;
  --header-h: 56px;
  --shadow: 0 1px 2px rgba(10, 15, 44, 0.05), 0 8px 24px rgba(10, 15, 44, 0.06);
  --shadow-lift: 0 2px 4px rgba(10, 15, 44, 0.06), 0 14px 32px rgba(33, 33, 249, 0.16);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);        /* settle: entrances, fills, drawing */
  --ease-press: cubic-bezier(0.3, 0, 0.5, 1);    /* quick: taps, exits */
  --font: "Grift", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must never override hidden */
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, p, blockquote { margin: 0; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }

/* App shell: header plus a main area that fills the visible screen */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--s5), env(safe-area-inset-right)) 0 max(var(--s5), env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: var(--s2); }
.brand-mark { height: 25px; width: auto; display: block; }
.wordmark { font-weight: 800; letter-spacing: -0.02em; color: var(--ink); font-size: 17px; }
.topbar-label { font-size: 14px; color: var(--muted); font-weight: 600; }

main {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: var(--s5) max(var(--s4), env(safe-area-inset-left)) calc(var(--s7) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-right));
  outline: none;
}
.screen { display: flex; flex-direction: column; gap: var(--s5); }
.screen.entering { animation: rise 420ms var(--ease) both; }

/* Shared pieces */
.hero { display: grid; gap: var(--s3); }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
h1 { font-size: clamp(30px, 8vw, 42px); line-height: 1.08; letter-spacing: -0.03em; font-weight: 800; text-wrap: balance; }
.intro-verse { display: grid; gap: var(--s2); padding: var(--s4); border-radius: var(--r-sm); background: var(--accent-wash); margin-bottom: var(--s2); }
.intro-verse p { font-size: 16px; line-height: 1.5; font-weight: 600; }
.intro-verse cite { font-style: normal; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent); }
.intro-title { text-transform: uppercase; letter-spacing: -0.01em; }
.credit { font-size: 11px; line-height: 1.5; color: var(--muted); text-align: center; }
.lede { font-size: 17px; color: var(--muted); max-width: 58ch; }
.muted { color: var(--muted); font-size: 15px; }

.parts-preview { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s2); }
.parts-preview li { height: 6px; border-radius: var(--r-pill); background: var(--accent-soft); }
.parts-preview li.done { background: var(--accent); }
.parts-caption { font-size: 13px; font-weight: 700; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow); display: grid; gap: var(--s4); }
.card-title { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; }

.resume { gap: var(--s4); border-color: var(--accent-soft); background: var(--accent-wash); box-shadow: none; }
.resume-actions { display: flex; gap: var(--s3); flex-wrap: wrap; }
.resume-actions .btn { flex: 1 1 140px; }

.field-row { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: grid; gap: var(--s2); font-size: 14px; font-weight: 700; }
.field input {
  min-height: 52px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); font-size: 17px; font-weight: 400;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), background-color 160ms var(--ease);
}
.field input:focus-visible { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(33, 33, 249, 0.16); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; }
.form-error:not([hidden]) { animation: nudge 360ms var(--ease-press); }

.btn {
  min-height: 52px; padding: 0 var(--s5);
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 700; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: transform 160ms var(--ease-press), background-color 160ms var(--ease), opacity 160ms var(--ease), box-shadow 200ms var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(33, 33, 249, 0.4); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(33, 33, 249, 0.24); }
.btn-quiet { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-text { background: transparent; color: var(--muted); min-height: 44px; }
.btn-block { width: 100%; }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled), .btn-quiet:hover:not(:disabled) { transform: translateY(-2px); }
}

/* Progress: five segments, one per part */
.segments { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s1); }
.seg { height: 6px; border-radius: var(--r-pill); background: var(--accent-soft); overflow: hidden; }
.seg > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 420ms var(--ease); }

/* The blueprint house */
.house-wrap {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background-color: #FFFFFF;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px; background-position: -1px -1px;
  display: grid; place-items: center; padding: var(--s3);
}
.house { width: 100%; max-width: 360px; height: auto; max-height: 30dvh; display: block; overflow: visible; }
.house path { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.layer.plan path { stroke: var(--plan); stroke-dasharray: 4 5; }
.layer.built path, .layer.drawing path { stroke: var(--accent); }
.layer.drawing path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 900ms var(--ease) forwards; }
.wall-fill path { fill: var(--accent-wash); }
.wall-fill.drawing path { animation: draw 900ms var(--ease) forwards, fill-in 600ms 400ms var(--ease) both; }
.lights rect { fill: var(--true-blue); animation: glow 900ms 700ms var(--ease) both; }

/* Part intro */
.screen-part { flex: 1; gap: var(--s4); max-width: 560px; width: 100%; margin: 0 auto; }
main:has(.screen-part:not([hidden])), main:has(.screen-questions:not([hidden])) { padding-top: var(--s3); padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
.part-done { font-size: 14px; font-weight: 700; color: var(--success); min-height: 21px; }
.part-done:empty { display: none; }
.part-copy { display: grid; gap: var(--s2); }
.part-title { font-size: clamp(30px, 8.4vw, 40px); }
.part-intro { font-size: 17px; color: var(--muted); }
.verse { margin-top: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--surface-2); display: grid; gap: var(--s1); }
.verse p { font-size: 15px; line-height: 1.5; }
.verse cite { font-style: normal; font-size: 13px; font-weight: 700; color: var(--accent); }
.part-actions { margin-top: auto; display: grid; gap: var(--s1); }

/* Questions: statement in the middle, answers in the thumb zone */
.screen-questions {
  flex: 1; gap: 0; position: relative;
  max-width: 560px; width: 100%; margin: 0 auto;
}
.q-top { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: var(--s3); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: transform 160ms var(--ease-press);
}
.icon-btn:active { transform: scale(0.92); }
.q-count { font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

.q-stage { flex: 1; display: flex; align-items: center; padding: var(--s6) var(--s1); touch-action: pan-y; }
.q-card { display: grid; gap: var(--s3); width: 100%; will-change: transform, opacity; }
.q-label { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.q-text { font-size: clamp(24px, 6.6vw, 32px); line-height: 1.22; letter-spacing: -0.02em; font-weight: 800; outline: none; text-wrap: pretty; }

.q-bottom { display: grid; gap: var(--s3); }
.q-ask { font-size: 14px; font-weight: 700; color: var(--muted); }
.choices { display: grid; gap: var(--s2); }
.choice {
  display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: var(--s3);
  min-height: 56px; padding: 0 var(--s4); width: 100%; text-align: left; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  font-size: 16px; font-weight: 600;
  transition: transform 140ms var(--ease-press), background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), box-shadow 220ms var(--ease);
}
.choice-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: 15px;
  transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}
.choice:active { transform: scale(0.98); }
.choice:focus-visible { outline: 3px solid rgba(33, 33, 249, 0.4); outline-offset: 2px; }
.choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lift); }
.choice[aria-pressed="true"] .choice-num { background: var(--accent-ink); color: var(--accent); border-color: transparent; }
@media (hover: hover) {
  .choice:hover:not([aria-pressed="true"]) { border-color: var(--accent); }
}
.q-hint { font-size: 13px; text-align: center; min-height: 20px; color: var(--muted); transition: opacity 300ms var(--ease); }
.q-hint.gone { opacity: 0; }

/* Complete: the finished house and the View My Results button */
.screen-complete { flex: 1; gap: var(--s5); max-width: 560px; width: 100%; margin: 0 auto; justify-content: center; }
main:has(.screen-complete:not([hidden])) { padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
.complete-copy { display: grid; gap: var(--s2); text-align: center; }
.complete-title { font-size: clamp(28px, 7.6vw, 38px); }
.screen-complete .btn { animation: rise 420ms 1400ms var(--ease) both; }

/* Results */
.top-gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); }
.gift-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s5); box-shadow: var(--shadow); display: grid; gap: var(--s3);
  opacity: 0; transform: translateY(16px) scale(0.98);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
}
.gift-card.in { opacity: 1; transform: none; }
.gift-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.rank { background: var(--accent-wash); color: var(--accent); font-size: 13px; font-weight: 800; padding: var(--s1) var(--s3); border-radius: var(--r-pill); }
.gift-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.gift-score { font-size: 14px; color: var(--muted); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: var(--r-pill); background: var(--accent-soft); overflow: hidden; }
.meter > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 900ms var(--ease); }
.gift-summary { font-size: 16px; }
.gift-meta { font-size: 14px; color: var(--muted); }
.gift-meta strong { color: var(--ink); }

/* Top gift: Midnight Blue "for depth", with the B mark as a watermark */
.gift-card.featured { background: var(--midnight); border-color: var(--midnight); color: #FFFFFF; box-shadow: 0 18px 40px rgba(10, 15, 44, 0.28); }
.gift-card.featured .gift-name { font-size: 30px; }
.gift-card.featured .rank { background: var(--accent); color: #FFFFFF; }
.gift-card.featured .gift-score, .gift-card.featured .gift-meta { color: rgba(255, 255, 255, 0.78); }
.gift-card.featured .gift-meta strong { color: #FFFFFF; }
.gift-card.featured .meter { background: rgba(255, 255, 255, 0.16); }
.gift-card.featured .meter > div { background: var(--true-blue); }
.gift-card.featured > * { position: relative; }
.gift-card .watermark { position: absolute; right: -18px; bottom: -26px; width: 132px; opacity: 0.08; pointer-events: none; }
.tie-note { text-align: center; }

.all-gifts { padding: 0; gap: 0; overflow: hidden; }
.all-gifts summary {
  list-style: none; cursor: pointer; font-weight: 800; font-size: 17px;
  min-height: 60px; padding: 0 var(--s5);
  display: flex; align-items: center; justify-content: space-between;
}
.all-gifts summary::-webkit-details-marker { display: none; }
.all-gifts .chev { transition: transform 260ms var(--ease); color: var(--muted); }
.all-gifts[open] .chev { transform: rotate(180deg); }
.bars { list-style: none; margin: 0; padding: 0 var(--s5) var(--s5); display: grid; gap: var(--s3); }
.all-gifts[open] .bars { animation: rise 320ms var(--ease) both; }
.bar-row { display: grid; grid-template-columns: 112px 1fr 32px; gap: var(--s3); align-items: center; font-size: 14px; }
.bar-row .meter { height: 10px; }
.bar-row.top .bar-name { font-weight: 800; }

/* Dream Teams list on the results screen */
.teams-card .card-title { margin-bottom: var(--s2); }
.dream-teams { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s3); }
.team-row { padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: 0; padding-bottom: 0; }
.team-row.selected { background: var(--accent-wash); border-radius: var(--r-sm); padding: var(--s3); border-bottom-color: transparent; }
.team-row.selected .team-name { color: var(--accent); }
.team-option { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: var(--s3); row-gap: 2px; align-items: start; cursor: pointer; }
.team-radio { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.team-radio-mark { grid-column: 1; grid-row: 1 / span 2; width: 20px; height: 20px; margin-top: 2px; border: 2px solid var(--muted); border-radius: 50%; background: var(--bg); }
.team-row.selected .team-radio-mark { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--bg); }
.team-option:focus-within .team-radio-mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.team-name { grid-column: 2; grid-row: 1; font-weight: 800; font-size: 16px; }
.team-gifts { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 14px; }
.team-pick-note { margin: var(--s3) 0 0; padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--accent-wash); font-weight: 600; font-size: 15px; line-height: 1.5; }
.bar-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.email-note {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5); border-radius: var(--r-lg);
  background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 15px;
}
.email-note svg { flex: none; }
.email-note p { color: var(--ink); }
.noscript { padding: var(--s5); text-align: center; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-6px); } 60% { transform: translateX(4px); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fill-in { from { fill-opacity: 0; } to { fill-opacity: 1; } }
@keyframes glow { from { opacity: 0; } to { opacity: 0.9; } }

/* Short phones (iPhone SE, small Androids): tighten so actions stay in reach */
@media (max-height: 700px) {
  .q-stage { padding: var(--s4) var(--s1); }
  .q-text { font-size: clamp(21px, 6vw, 26px); }
  .choice { min-height: 50px; }
  .choice-num { width: 30px; height: 30px; }
  .q-hint { display: none; }
  .house { max-height: 22dvh; }
  .part-intro { font-size: 15px; }
  .verse p { font-size: 14px; }
}

@media (min-width: 640px) {
  main { padding-top: var(--s7); }
  .top-gifts { grid-template-columns: repeat(2, 1fr); }
  .gift-card.featured { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .gift-card { transform: none; }
}
