/* Travel Companion — interactive demo, layered on styles.css tokens */

/* [hidden] must beat our own display:flex/grid rules */
[hidden] { display: none !important; }

.demo-body { background: var(--paper); }

.load-error {
  margin: 0; padding: 14px 20px; background: var(--stale-bg); color: var(--stale);
  font-family: var(--mono); font-size: 13px;
}

.beat { padding: 76px 0; }
.beat + .beat { border-top: 1px solid var(--rule); }

.reveal { opacity: 0; translate: 0 20px; transition: opacity .6s, translate .6s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; translate: none; transition: none; } }

.beat-head { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 40px; }
.beat-num {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  border: 1px solid var(--rule); border-radius: 100px; padding: 7px 13px;
  flex: none; translate: 0 6px;
}
.beat-head h2 { font-size: clamp(28px, 3.7vw, 46px); }
.beat-head h2 em { color: var(--accent); }
.beat-head .section-label { margin-bottom: 12px; }

.lede { font-size: 17px; color: var(--ink-2); line-height: 1.6; max-width: 34rem; text-wrap: pretty; }
.lede.center { max-width: 44rem; margin: 0 auto 38px; text-align: center; font-size: 18px; }
.lede b { color: var(--ink); font-weight: 600; }

/* ── ① setup ─────────────────────────────────────────────── */

.setup { padding-top: 40px; }
.setup h1 { margin: 26px 0 0; font-size: clamp(42px, 6vw, 76px); }
.setup h1 em { color: var(--accent); }

.story { margin-top: 30px; max-width: 34rem; font-size: 19px; line-height: 1.6; }
.story p { margin-bottom: 10px; color: var(--ink-2); }
.story b { color: var(--ink); font-weight: 600; }
.story .turn {
  font-family: var(--display); font-style: italic; font-size: 25px;
  color: var(--ink); margin-top: 18px;
}
.story .turn b { color: var(--accent); font-style: normal; font-family: var(--sans); font-size: 21px; }

.timeline { position: relative; height: 66px; margin: 52px 0 0; }
.tl-axis { position: absolute; left: 0; right: 0; top: 26px; height: 1px; background: var(--rule); pointer-events: none; }
.dot {
  position: absolute; top: 20px; width: 13px; height: 13px; border-radius: 50%;
  translate: -50% 0; cursor: pointer; border: 2px solid var(--paper);
  transition: scale .18s, box-shadow .18s;
}
.dot.stale { background: var(--stale); }
.dot.fresh { background: var(--fresh); }
.dot:hover, .dot:focus-visible { scale: 1.5; outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.dot::after {
  content: attr(data-tip); position: absolute; bottom: 24px; left: 50%; translate: -50% 0;
  background: var(--ink); color: var(--paper); font-size: 11.5px; font-family: var(--mono);
  padding: 6px 10px; border-radius: 7px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .18s; z-index: 5;
}
.dot:hover::after, .dot:focus-visible::after { opacity: 1; }
.tl-label { pointer-events: none; position: absolute; top: 44px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.tl-old { left: 0; } .tl-new { right: 0; }

.timeline-key { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-key .k { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.timeline-key .k.stale { background: var(--stale); }
.timeline-key .k.fresh { background: var(--fresh); margin-left: 10px; }
.timeline-key em { font-style: normal; opacity: .75; }

/* ── layout ──────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }

/* ── ② problem ───────────────────────────────────────────── */

.prefs { margin: 24px 0 0; }
.pref-row {
  display: grid; grid-template-columns: 82px 1fr; gap: 12px; align-items: baseline;
  padding: 11px 0; border-top: 1px solid var(--rule-2);
}
.pref-row dt { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.pref-row dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pref-row code {
  font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 100px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.pref-row code.bad { background: var(--stale-bg); color: var(--stale); text-decoration: line-through; }
.pref-row.missing dt { color: var(--accent); }
.absent {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 3px 11px; border-radius: 100px;
}

.gotcha {
  margin-top: 26px; padding: 20px 22px; border-radius: 16px;
  background: var(--stale-bg); border: 1px solid color-mix(in srgb, var(--stale) 22%, transparent);
}
.gotcha p { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.gotcha code {
  font-family: var(--mono); font-size: 12.5px; background: color-mix(in srgb, var(--ink) 8%, transparent);
  padding: 2px 7px; border-radius: 5px;
}
.gotcha .punch { margin-top: 12px; color: var(--stale); font-weight: 600; font-size: 15.5px; }

/* ── reply cards ─────────────────────────────────────────── */

.reply-card { border: 1px solid var(--rule-2); border-radius: 18px; background: var(--card); overflow: hidden; }
.rc-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
}
.rc-top a { color: inherit; opacity: .8; }
.reply-card.stale .rc-top { background: var(--stale-bg); color: var(--stale); }
.reply-card.fresh .rc-top { background: var(--fresh-bg); color: var(--fresh); }
.rc-body { padding: 20px 22px; font-size: 14px; line-height: 1.62; color: var(--ink-2); max-height: 460px; overflow-y: auto; }
.rc-body h4 { font-size: 14.5px; color: var(--ink); margin: 16px 0 7px; }
.rc-body h4:first-child { margin-top: 0; }
.rc-body p { margin: 0 0 10px; }
.rc-body ul { margin: 0 0 11px; padding-left: 17px; }
.rc-body li { margin-bottom: 5px; }
.rc-body strong { color: var(--ink); font-weight: 600; }

.trace {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 13px 20px;
  border-bottom: 1px solid var(--rule-2); background: color-mix(in srgb, var(--fresh-bg) 28%, transparent);
}
.tool {
  font-family: var(--mono); font-size: 10.5px; padding: 4px 9px; border-radius: 6px;
  background: var(--card); border: 1px solid var(--rule-2); color: var(--ink-2);
  animation: pop .4s cubic-bezier(.2,.8,.2,1) backwards;
}
.trace .arrow { font-style: normal; color: var(--ink-3); font-size: 11px; }
@keyframes pop { from { opacity: 0; scale: .9; } to { opacity: 1; scale: 1; } }

.checks { list-style: none; margin: 24px 0 0; padding: 0; }
.checks li {
  padding: 11px 0 11px 26px; border-top: 1px solid var(--rule-2);
  font-size: 15px; color: var(--ink-2); position: relative;
}
.checks li::before {
  content: "✓"; position: absolute; left: 2px; color: var(--fresh); font-size: 13px;
}

/* ── ③ the interactive fix ───────────────────────────────── */

.fix-beat { background: var(--paper-2); border-block: 1px solid var(--rule); }

.control {
  max-width: 620px; margin: 0 auto; padding: 24px 28px;
  background: var(--card); border: 1px solid var(--rule-2); border-radius: 18px;
  box-shadow: var(--shadow);
}
.control-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.control-row label { font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
#window-out { font-family: var(--display); font-style: italic; font-size: 26px; color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 100px;
  background: linear-gradient(90deg, var(--fresh) 0%, var(--rule) 45%, var(--stale) 100%);
  outline: none; cursor: grab; direction: rtl;
}
input[type="range"]:active { cursor: grabbing; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--card); cursor: grab;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
}
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--ink);
  border: 3px solid var(--card); cursor: grab; box-shadow: 0 2px 10px rgba(0,0,0,.28);
}

.ticks { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.tick {
  font-family: var(--mono); font-size: 11px; padding: 7px 13px; border-radius: 100px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink-2);
  cursor: pointer; transition: all .2s;
}
.tick:hover { border-color: var(--ink-3); }
.tick.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tick.is-key { border-color: var(--accent); color: var(--accent); }
.tick.is-key.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.counter {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin: 34px auto 26px; max-width: 620px; padding: 22px;
  border-radius: 18px; background: var(--stale-bg); transition: background .4s;
}
.counter b { font-family: var(--display); font-size: 62px; line-height: 1; color: var(--stale); transition: color .4s; }
.counter span { font-size: 14.5px; color: var(--ink-2); max-width: 15rem; line-height: 1.4; }
.counter.clean { background: var(--fresh-bg); }
.counter.clean b { color: var(--fresh); }

.live-rank { list-style: none; margin: 0 auto; padding: 0; max-width: 760px; }
.live-rank li {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 14px; align-items: baseline;
  padding: 14px 20px; background: var(--card);
  border: 1px solid var(--rule-2); border-bottom: 0;
  transition: background .35s;
}
.live-rank li:first-child { border-radius: 12px 12px 0 0; }
.live-rank li:last-child { border-radius: 0 0 12px 12px; border-bottom: 1px solid var(--rule-2); }
.live-rank li.is-stale { background: color-mix(in srgb, var(--stale-bg) 48%, var(--card)); }
.lr-i { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.lr-main b { display: block; font-weight: 500; font-size: 15px; letter-spacing: -.01em; }
.lr-age { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.is-stale .lr-age { color: var(--stale); font-weight: 500; }

.tag {
  display: inline-block; margin-top: 5px; font-family: var(--mono);
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 100px;
}
.tag.stale { background: var(--stale-bg); color: var(--stale); }
.tag.fresh { background: var(--fresh-bg); color: var(--fresh); }

/* ── ⑤ close ─────────────────────────────────────────────── */

.close { text-align: center; padding: 92px 0 100px; }
.close h2 { font-size: clamp(26px, 3.4vw, 42px); line-height: 1.25; }
.close h2 em { color: var(--accent); }
.close .stack-items { justify-content: center; margin-top: 44px; }
.capture-note { margin-top: 34px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ── responsive ──────────────────────────────────────────── */

@media (max-width: 940px) {
  .split { grid-template-columns: 1fr; gap: 28px; }
  .beat { padding: 56px 0; }
  .counter { flex-direction: column; gap: 10px; text-align: center; }
  .live-rank li { grid-template-columns: 24px 1fr; }
  .lr-age { grid-column: 2; }
}

.rc-top .ok {
  background: color-mix(in srgb, var(--fresh) 18%, transparent);
  padding: 3px 10px; border-radius: 100px;
}

/* ── interactive: memory detail ──────────────────────────── */

.dot.on { scale: 1.6; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 28%, transparent); }

.mem-detail {
  margin-top: 26px; padding: 20px 24px; max-width: 46rem;
  border-radius: 16px; background: var(--card);
  border: 1px solid var(--rule-2); border-left: 3px solid var(--rule);
  animation: rise .4s cubic-bezier(.2,.8,.2,1);
}
.mem-detail.stale { border-left-color: var(--stale); }
.mem-detail.fresh { border-left-color: var(--fresh); }
.md-top {
  display: flex; gap: 14px; align-items: baseline;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px;
}
.md-kind { color: var(--accent); }
.mem-detail h4 { font-size: 17px; margin: 0 0 8px; letter-spacing: -.015em; }
.mem-detail p { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); margin-bottom: 12px; }

/* ── interactive: ask gates ──────────────────────────────── */

.ask-gate {
  padding: 34px 26px; text-align: center;
  transition: opacity .25s, translate .25s;
}
.ask-gate.gone { opacity: 0; translate: 0 -8px; }
.ask-q {
  font-family: var(--display); font-style: italic; font-size: 17px;
  color: var(--ink-2); line-height: 1.45; margin-bottom: 20px; text-wrap: pretty;
}
.ask-btn {
  font-family: var(--sans); font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 26px; border-radius: 100px; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 0;
  transition: translate .2s, box-shadow .2s;
}
.ask-btn:hover { translate: 0 -2px; box-shadow: var(--shadow-lg); }
.ask-btn span { opacity: .6; }
.ask-btn.fresh { background: var(--fresh); color: #fff; }

/* ── interactive: source links ───────────────────────────── */

.src {
  display: inline-block; margin-top: 14px;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  text-decoration: none; border-bottom: 1px solid var(--rule);
  padding-bottom: 2px; transition: color .2s, border-color .2s;
}
.src:hover { color: var(--accent); border-color: var(--accent); }
.center-src { display: block; width: fit-content; margin: 22px auto 0; }

.close-links {
  display: flex; align-items: center; justify-content: center;
  gap: 26px; margin-top: 44px; flex-wrap: wrap;
}
