/*
 * selector.css — neutral "selector" chrome for the This-or-This flow.
 * The chrome deliberately runs on its own quiet tokens (warm grey + one deep
 * teal accent, system UI type) so it never competes with the site renders
 * inside the cards (§5). Mobile-first: stacked cards + sticky choose-bar;
 * >=860px the cards sit side by side.
 */

:root {
  --bg: #f3f3ef;
  --surface: #ffffff;
  --ink: #1b1d1c;
  --ink-soft: rgba(27, 29, 28, .62);
  --hairline: rgba(27, 29, 28, .14);
  --accent: #0e6b5a;
  --accent-soft: rgba(14, 107, 90, .12);
  --radius: 14px;
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* the cards scroll; the page never does */
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app { display: flex; flex-direction: column; height: 100dvh; }

/* -------------------------------- Header -------------------------------- */
.top { padding: calc(10px + env(safe-area-inset-top)) 16px 8px; text-align: center; }
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.top-spacer { width: 64px; } /* balances the Back button so the name stays centred */
.biz {
  flex: 1;
  font-size: 12px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.back-btn {
  width: 64px; min-height: 32px;
  border: 0; background: none; border-radius: 8px;
  color: var(--ink-soft); font-size: 13px; text-align: left;
}
.back-btn:hover { color: var(--ink); }
.axis-label { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; min-height: 26px; }
.chief-line {
  font-size: 13px; line-height: 1.45; color: var(--ink-soft);
  max-width: 46ch; margin: 4px auto 0;
  max-height: 4em; overflow: hidden;
  transition: opacity .24s var(--ease-out), max-height .24s var(--ease-out), margin .24s var(--ease-out);
}
.chief-line.tucked { opacity: 0; max-height: 0; margin-top: 0; } /* frees room for the cards */

/* ------------------------ Progress (one seg per axis) ------------------------ */
.progress { display: flex; gap: 6px; max-width: 280px; margin: 10px auto 0; }
.seg { flex: 1; height: 3px; border-radius: 2px; background: var(--hairline); }
.seg-fill {
  display: block; height: 100%; width: 0; border-radius: 2px;
  background: var(--accent); transform-origin: center;
  transition: width .3s var(--ease-out);
}
.seg.pulse .seg-fill { animation: seg-pulse .45s var(--ease-out); }
@keyframes seg-pulse { 40% { transform: scaleY(2.4); } }

/* --------------------------------- Cards --------------------------------- */
.stage {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 12px 4px;
}
.slot {
  position: relative; flex: 1 1 0; min-height: 0;
  transition: flex-grow .32s var(--ease-out), opacity .24s var(--ease-out);
}
.slot.collapsed { flex-grow: .001; opacity: 0; pointer-events: none; } /* finish: winner expands */
.slot-chip {
  position: absolute; z-index: 3; top: 8px; left: 8px;
  width: 22px; height: 22px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--hairline);
}
[data-phase="done"] .slot-chip { display: none; }
.slot.kb-target .card { outline: 3px solid var(--accent); outline-offset: 3px; } /* arrow-key highlight */

.card {
  position: absolute; inset: 0; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--hairline); /* 1px hairline, no drop-shadow soup */
  border-radius: var(--radius);
  overflow: hidden;
}
.card.is-winner { box-shadow: 0 0 0 2px var(--accent); } /* the 2px accent ring */
.card.pressed { border-color: var(--accent); }           /* press: border -> accent */
.card-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

/* Skeleton shimmer — only visible while a card's iframe hasn't loaded */
.card.loading::after {
  content: ""; position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(100deg, #efefec 35%, #fafaf7 50%, #efefec 65%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* One soft light-sweep across the winner at the finish (~600ms) */
.card.sweep::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .5) 50%, transparent 60%);
  transform: translateX(-130%);
  animation: sweep .6s var(--ease-out) forwards;
}
@keyframes sweep { to { transform: translateX(130%); } }

/* ------------------------------- Choose-bar ------------------------------- */
.choose-bar {
  display: flex; gap: 8px; align-items: stretch;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  transition: opacity .2s var(--ease-out);
}
[data-phase="loading"] .choose-bar,
[data-phase="intro"] .choose-bar,
[data-phase="error"] .choose-bar { opacity: 0; pointer-events: none; }
.pick {
  flex: 1 1 0; min-height: 48px; /* 44px+ tap targets */
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 650;
  transition: transform .12s var(--ease-out), border-color .12s var(--ease-out), background .12s var(--ease-out);
}
.pick:hover { border-color: var(--ink-soft); }
.pick:active { transform: scale(.985); border-color: var(--accent); background: var(--accent-soft); }
.pick-glyph { font-size: 11px; color: var(--ink-soft); }
.pick-same {
  flex: 0 1 auto; min-height: 48px; padding: 0 14px;
  border: 1px dashed var(--hairline); border-radius: 12px;
  background: none; color: var(--ink-soft); font-size: 13px;
  transition: color .12s var(--ease-out), border-color .12s var(--ease-out), transform .12s var(--ease-out);
}
.pick-same:hover { color: var(--ink); border-color: var(--ink-soft); }
.pick-same:active { transform: scale(.985); }

/* ------------------------------- Finish bar ------------------------------- */
.finish-bar {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--accent); color: #fff; /* accent fills the bar (§5) */
}
.finish-copy { font-size: 15px; font-weight: 600; line-height: 1.4; }
.finish-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.finish-back {
  min-height: 48px; padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, .55); border-radius: 12px;
  background: transparent; color: #fff; font-weight: 600;
  transition: transform .12s var(--ease-out), background .12s var(--ease-out), border-color .12s var(--ease-out);
}
.finish-back:hover { border-color: #fff; background: rgba(255, 255, 255, .12); }
.finish-back:active { transform: scale(.985); }
.finish-cta {
  flex-shrink: 0; min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 12px;
  background: #fff; color: var(--accent); font-weight: 700;
  transition: transform .12s var(--ease-out), opacity .12s;
}
.finish-cta:active { transform: scale(.985); }
.finish-cta:disabled { opacity: .85; cursor: default; }

/* -------------------------------- Utilities -------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* Offscreen but laid out, so preloading iframes render and accept scroll positions */
.stash {
  position: fixed; inset: 0;
  transform: translateX(-200vw);
  visibility: hidden; pointer-events: none;
}

/* --------------------------------- Desktop --------------------------------- */
@media (min-width: 860px) {
  .stage { flex-direction: row; gap: 14px; max-width: 1240px; margin: 0 auto; padding: 12px 20px 6px; }
  .choose-bar { max-width: 720px; width: 100%; margin: 0 auto; }
  .finish-bar { justify-content: center; }
  .axis-label { font-size: 24px; }
}

/* --------------------------- Reduced motion (§5/§8) --------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .12s !important;
  }
}
