/* ==========================================================================
   HotSignals — "How to read a ticket" guide.
   Builds on app.css (same tokens, same slip). Layout: intro, then a two-column
   tour (sticky ticket stage | step card + step list), then reference blocks.
   ========================================================================== */

/* Follow the system theme when no explicit choice is set (the site sets one). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #E4EAEE; --bg-2: #D9E1E7; --surface: #FFFFFF; --surface-2: #F2F5F7; --line: #C6D0DA;
    --text: #172234; --muted: #56667C; --flare: #DC4E1E; --flare-ink: #FFFFFF; --turf: #CFE3D8;
    --shadow-ticket: drop-shadow(0 4px 10px rgba(23, 34, 52, .16));
    --shadow-ticket-hover: drop-shadow(0 12px 20px rgba(23, 34, 52, .22));
    --glow-a: rgba(255, 255, 255, .7); --glow-b: rgba(220, 78, 30, .05);
    color-scheme: light;
  }
}

/* --- Frame ----------------------------------------------------------------- */

.g-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}

.guide {
  max-width: 1180px; margin: 0 auto;
  padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 48px;
}

/* --- Intro ----------------------------------------------------------------- */

.g-intro { display: grid; gap: 14px; max-width: 760px; }
.g-intro h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem); font-weight: 800; font-stretch: 68%;
  line-height: .98; letter-spacing: -.005em; text-wrap: balance;
}
.lede { margin: 0; font-size: 1.08rem; color: var(--muted); max-width: 60ch; }

.quick { display: grid; gap: 8px; margin-top: 6px; }
.quick-label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.quick-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: q; }
.quick-steps li { counter-increment: q; display: flex; align-items: center; gap: 8px; }
.quick-steps li + li::before { content: ""; width: 14px; height: 2px; background: var(--line); }
.quick-steps button {
  display: grid; grid-template-columns: auto 1fr; column-gap: 9px; text-align: left;
  padding: 8px 12px 8px 8px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color .15s ease, transform .12s ease;
}
.quick-steps button::before {
  content: counter(q); grid-row: 1 / span 2; align-self: center;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--flare); color: var(--flare-ink); font-weight: 800; font-size: .8rem;
}
.quick-steps button b { font-size: .92rem; }
.quick-steps button span { font-size: .76rem; color: var(--muted); }
.quick-steps button:hover { border-color: var(--muted); }
.quick-steps button:active { transform: scale(.98); }

/* --- Tour layout ----------------------------------------------------------- */

.tour { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 40px; align-items: start; }
.stage { position: sticky; top: 20px; padding: 18px 14px 10px; }
.panel-col { display: grid; gap: 16px; min-width: 0; }

/* The tour ticket is not a link: no hover lift */
.tour-ticket, .tour-ticket:hover, .tour-ticket:active { cursor: default; transform: none; }
.tour-ticket { margin: 0; }
.tour-ticket .stat .bar i { width: var(--w); }

/* Spotlight: dim every part except the lit ones */
.tour-ticket [data-part] { transition: opacity .35s ease, box-shadow .35s ease, filter .35s ease; border-radius: 6px; }
.tour-ticket.focusing [data-part]:not(.lit) { opacity: .16; filter: blur(.3px); }
.tour-ticket.focusing .lit {
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--flare), 0 0 22px 4px color-mix(in srgb, var(--flare) 40%, transparent);
}
.tour-ticket.focusing .flag.lit { border-radius: 99px; }
.tour-ticket.focusing .stamp.lit { box-shadow: none; }
.tour-ticket .slip-sel, .tour-ticket .slip-teams, .tour-ticket .slip-top { position: relative; }

/* Numbered pin that follows the lit part */
.pin {
  position: absolute; z-index: 5; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--flare); color: var(--flare-ink);
  font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--flare) 25%, transparent), 0 6px 14px rgba(0, 0, 0, .35);
  transition: transform .45s cubic-bezier(.3, 1.3, .5, 1);
  pointer-events: none;
}

/* Per-step micro-animations */
.tour-ticket.grow .stat .bar i { animation: bar-grow .9s cubic-bezier(.2, .8, .2, 1) both; }
.tour-ticket.grow .stat:nth-child(2) .bar i { animation-delay: .12s; }
.tour-ticket.grow .stat:nth-child(3) .bar i { animation-delay: .24s; }
@keyframes bar-grow { from { width: 0; } }

.tour-ticket.scan .barcode { position: relative; overflow: hidden; }
.tour-ticket.scan .barcode::after {
  content: ""; position: absolute; top: -4px; bottom: -4px; width: 3px; left: 0;
  background: #E2502A; box-shadow: 0 0 10px 2px #E2502A;
  animation: scan 1.4s ease-in-out 2 alternate;
}
@keyframes scan { to { left: calc(100% - 3px); } }

.tour-ticket.nudge .flag.lit { animation: nudge .6s ease 2; }
@keyframes nudge { 50% { transform: translateX(4px); } }

/* --- Step card ------------------------------------------------------------- */

.step-card {
  display: grid; gap: 14px; padding: 22px 22px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  min-height: 330px; align-content: start;
}
.step-meta { display: flex; align-items: center; gap: 12px; }
.step-count { font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step-progress { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.step-progress span { display: block; height: 100%; width: 0; background: var(--flare); transition: width .4s ease; }
.step-card h2 { font-size: clamp(1.5rem, 3.2vw, 2rem); font-weight: 800; font-stretch: 72%; line-height: 1.05; text-wrap: balance; }
.step-body { display: grid; gap: 12px; font-size: 1rem; line-height: 1.55; max-width: 62ch; }
.step-body p { margin: 0; }
.step-body.enter { animation: body-in .35s ease both; }
@keyframes body-in { from { opacity: 0; transform: translateY(6px); } }
.step-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.mono { font-family: var(--mono); }
.hl { font-weight: 700; }

/* Small explainer blocks inside steps */
.sum {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px;
  padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: .92rem;
}
.sum b { font-weight: 600; }
.sum.say { font-family: var(--sans); font-size: .95rem; line-height: 1.5; }
.sum.say b { font-family: var(--mono); }
.glossary { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .9rem; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; color: var(--muted); }
.signals { display: grid; gap: 8px; }
.signal { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; font-size: .9rem; }
.signal i { grid-row: 1 / span 2; width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; background: var(--fc); }
.signal b { font-weight: 700; }
.signal span { color: var(--muted); }
.signal[data-flag="PRESSURE"]  { --fc: var(--f-pressure); }
.signal[data-flag="INACTIVE"]  { --fc: var(--f-inactive); }
.signal[data-flag="CHAOS"]     { --fc: var(--f-chaos); }
.signal[data-flag="GOAL_SOON"] { --fc: var(--f-goal); }
.signal[data-flag="CORNERS"]   { --fc: var(--f-corners); }

.variant { display: flex; flex-wrap: wrap; gap: 6px; }
.variant .btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* --- Step list ------------------------------------------------------------- */

.step-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; counter-reset: s; }
.step-list li { counter-increment: s; }
.step-list button {
  width: 100%; display: flex; align-items: center; gap: 9px; text-align: left;
  padding: 7px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer;
  font-size: .86rem; color: var(--muted);
}
.step-list button::before {
  content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 800; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--line); color: var(--muted);
}
.step-list button:hover { color: var(--text); border-color: var(--line); }
.step-list button.done::before { background: var(--line); border-color: var(--line); color: var(--text); }
.step-list button.on { color: var(--text); background: var(--surface); border-color: var(--line); font-weight: 700; }
.step-list button.on::before { background: var(--flare); border-color: var(--flare); color: var(--flare-ink); }

/* --- Reference blocks ------------------------------------------------------ */

.ref { display: grid; gap: 14px; }
.ref h2 { font-size: 1.5rem; font-weight: 800; font-stretch: 72%; }
.ref-lede { margin: -6px 0 0; color: var(--muted); }

.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stamp-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 6px;
  padding: 12px 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.stamp-card h3 { color: var(--text); font-size: 1rem; }
.stamp-card p { margin: 0; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.stamp-card > b { font-family: var(--mono); font-weight: 600; font-size: 1.05rem; }
.mini-slip {
  position: relative; height: 84px; border-radius: 6px; margin-bottom: 4px;
  background: repeating-linear-gradient(0deg, transparent 0 11px, rgba(80, 60, 30, .06) 11px 12px), linear-gradient(var(--paper), var(--paper-2));
  overflow: hidden;
}
.mini-slip .stamp { top: 50%; left: 50%; font-size: 1.8rem; padding-inline: 10px; }
.stamp-card.is-lost .mini-slip, .stamp-card.is-half_lost .mini-slip { filter: grayscale(.85) brightness(.94); }

.ref-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.ref-split > div { display: grid; gap: 14px; min-width: 0; }

.calc { display: flex; flex-wrap: wrap; gap: 12px; }
.calc .field { flex: 1 1 140px; }
.calc-out { display: grid; gap: 12px; padding: 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.prob { display: grid; gap: 6px; font-size: .9rem; }
.prob b { font-family: var(--mono); font-size: 1.3rem; font-weight: 600; }
.prob-bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.prob-bar span { display: block; height: 100%; width: 47.6%; background: var(--flare); transition: width .35s ease; }
.calc-kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.calc-kv div { display: grid; gap: 2px; }
.calc-kv dt { font-size: .78rem; color: var(--muted); }
.calc-kv dd { margin: 0; font-family: var(--mono); font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-note { margin: 0; font-size: .8rem; color: var(--muted); }

.combo-facts { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; line-height: 1.5; }
.leg-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 12px; border-radius: 10px; background: var(--paper); color: var(--ink); font-size: .86rem; font-weight: 600; }
.leg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.leg-legend .leg-ico { font-style: normal; }
.combo-note { margin: 0; font-size: .88rem; color: var(--muted); line-height: 1.6; }
.combo-note .tag { color: var(--text); border-color: var(--muted); }

.g-foot { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 860px) {
  .tour { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  /* Keep the ticket in view while reading: a compact sticky stage */
  .stage {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6;
    width: 100%; margin: 0 auto; padding: 14px 0 10px;
    display: flex; justify-content: center;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .tour-ticket { zoom: .7; width: min(380px, 100%); }
  .step-card { min-height: 0; }
  .ref-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .quick-steps li + li::before { display: none; }
  .quick-steps { display: grid; grid-template-columns: 1fr 1fr; }
  .quick-steps button { width: 100%; }
  .glossary { grid-template-columns: 1fr; gap: 0 0; }
  .glossary dd { margin-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .pin { transition: none; }
}
