/* ============================================================
   Sidequest landing — design tokens
   ============================================================ */
:root {
  --bg: #FBF4E9;
  --ink: #1C1917;
  --muted: #78716C;
  --btn: #8C6D46;
  --line: #E4D5BE;
  --card-line: #E0CFB4;

  --rose: #E5A3BE;
  --magenta: #B4517F;
  --plum: #7E2F55;
  --orange: #C9662E;
  --burnt: #7A3E1D;
  --tan: #D9B48F;
  --gold: #C9A227;

  --sel-blue: #BCD3F5;
  --rose-tint: #F3D7E3;
  --pop-blue: #8FB6F9;

  --sans: "Inter", -apple-system, sans-serif;
  --serif: "Crimson Pro", Georgia, serif;
}

@property --hl-c {
  syntax: "<color>";
  inherits: false;
  initial-value: #BCD3F5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Shared bits
   ============================================================ */
.btn-pill {
  display: inline-block;
  background: var(--btn);
  color: var(--bg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(140,109,70,.35); }

.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); font-weight: 400; }

.serif-em { font-family: var(--serif); font-style: italic; font-size: 1.08em; }

/* ============================================================
   Nav
   ============================================================ */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(24px, 5vw, 64px);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(48px, 9vh, 120px) clamp(24px, 7vw, 110px) clamp(80px, 14vh, 180px);
  min-height: 72vh;
}
.hero-copy h1 {
  font-size: clamp(32px, 3.4vw, 46px);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 12.5em;
}
.hero-sub { margin-top: 18px; color: var(--muted); font-size: 14px; }

.hero-demo-wrap { display: flex; justify-content: center; }

/* ============================================================
   Demo card language (shared: hero, steps, try-it)
   ============================================================ */
.demo-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: 14px;
  padding: 22px 20px;
  width: 100%;
  max-width: 470px;
  box-shadow: 0 1px 0 rgba(28,25,23,.03);
}

.hero-demo {
  max-width: 480px;
  padding-right: 64px;   /* room for tree panel */
  user-select: none;
  -webkit-user-select: none;
}
.demo-inner { transition: opacity .3s ease; }
.demo-inner.fading { opacity: 0; }

.chat-p {
  font-size: 12.5px;
  line-height: 1.65;
  margin-bottom: 12px;
  color: var(--ink);
}
.chat-strong { font-weight: 700; margin-bottom: 8px; }
.term { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.chat-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--card-line);
  border-radius: 8px;
  padding: 9px 12px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.35);
}
.chat-input .send {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-left: 1px solid var(--card-line);
  padding-left: 12px;
}

/* --- highlights ------------------------------------------- */
.hl {
  --hl-c: var(--sel-blue);
  background-image: linear-gradient(var(--hl-c), var(--hl-c));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  border-radius: 2px;
  transition: background-size .5s cubic-bezier(.4,0,.2,1), --hl-c .45s ease;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl.selecting { background-size: 100% 100%; }
.hl.kept { --hl-c: var(--rose-tint); background-size: 100% 100%; }
.hl-blue.selecting { --hl-c: var(--sel-blue); }

/* --- popup -------------------------------------------------- */
.sq-popup {
  position: absolute;
  display: flex;
  align-items: stretch;
  background: #2B2724;
  color: #F5F0E8;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(28,25,23,.28);
  opacity: 0;
  transform: translateY(6px) scale(.92);
  transform-origin: bottom center;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 30;
}
.sq-popup.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.sq-popup.below { transform-origin: top center; }
.pop-item {
  padding: 8px 14px;
  cursor: pointer;
  border-right: 1px solid rgba(245,240,232,.16);
  transition: background .15s ease;
}
.pop-item:last-child { border-right: none; }
.pop-item:hover { background: rgba(245,240,232,.09); }
.pop-item.pressed { background: rgba(143,182,249,.22); }
.pop-blue { color: var(--pop-blue); }

/* --- tree panel (hero right edge) --------------------------- */
.demo-tree {
  position: absolute;
  top: 22px;
  right: 14px;
  width: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.tree-bar {
  display: inline-block;
  height: 8px;
  border-radius: 4px;
}
.tree-root { width: 34px; background: var(--burnt); }
.tree-child {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 8px;
}
.tree-glyph { font-size: 9px; color: var(--muted); line-height: 1; }
.tree-child .tree-bar { width: 22px; }
.bar-rose    { background: var(--rose); }
.bar-magenta { background: var(--magenta); }
.bar-plum    { background: var(--plum); }
.bar-orange  { background: var(--orange); }
.bar-gold    { background: var(--gold); }
.bar-tan     { background: var(--tan); }

/* --- note cards --------------------------------------------- */
.note-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-left: 3px solid var(--rose);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 10.5px;
  line-height: 1.4;
  box-shadow: 0 3px 12px rgba(28,25,23,.08);
  max-width: 160px;
}
.note-phrase { font-weight: 600; }
.note-comment { color: var(--muted); }

.hero-note {
  position: absolute;
  left: -126px;
  top: 34%;
  z-index: 20;
}

/* ============================================================
   Animated-item state machine
   Default (no JS / reduced motion): end state, fully visible.
   html.anim-on: items start hidden, classes .in reveal them.
   ============================================================ */
.anim-item { opacity: 1; transform: none; }

html.anim-on .anim-item {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .5s ease, transform .5s cubic-bezier(.3,.7,.3,1);
}
html.anim-on .anim-item.in { opacity: 1; transform: none; }

html.anim-on .hero-note { transform: translateX(14px); }
html.anim-on .hero-note.in { transform: translateX(0); }

html.anim-on .tree-child.anim-item { transform: translateX(-8px); }
html.anim-on .tree-child.anim-item.in { transform: translateX(0); }

/* hero highlights: end state by default, cleared by JS */
html:not(.anim-on) #heroSel1,
html:not(.anim-on) #heroSel2 { --hl-c: var(--rose-tint); background-size: 100% 100%; }
html:not(.anim-on) #step2Sel { --hl-c: var(--sel-blue); background-size: 100% 100%; }
html:not(.anim-on) .sq-popup#step2Popup { opacity: 1; transform: none; }

/* ============================================================
   Scroll reveals (only when animating)
   ============================================================ */
html.anim-on .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s ease, transform .7s cubic-bezier(.3,.7,.3,1);
}
html.anim-on .reveal.in { opacity: 1; transform: none; }

/* ============================================================
   "ugh" section
   ============================================================ */
.ugh {
  padding: clamp(48px, 8vh, 96px) clamp(24px, 7vw, 110px);
  border-top: 1px solid var(--line);
  max-width: 1100px;
}
.ugh-head { display: flex; align-items: center; gap: 28px; }
.ugh-head h2 { font-size: 17px; font-weight: 400; white-space: nowrap; }
.ugh-head strong { font-weight: 700; }
.ugh-head .rule { flex: 1; height: 1px; background: var(--line); }
.ugh-body {
  margin-top: 14px;
  max-width: 420px;
  font-size: 13.5px;
  color: var(--ink);
}

/* ============================================================
   Manifesto
   ============================================================ */
.manifesto {
  text-align: center;
  padding: clamp(80px, 14vh, 160px) 24px;
  max-width: 640px;
  margin: 0 auto;
}
.manifesto p {
  font-size: clamp(21px, 2.2vw, 27px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.manifesto-divider {
  display: block;
  width: 56px;
  height: 1.5px;
  background: var(--ink);
  margin: 44px auto;
}

/* ============================================================
   How it works
   ============================================================ */
.how { padding: clamp(40px, 7vh, 80px) clamp(24px, 6vw, 90px) 40px; }
.how-title {
  text-align: center;
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 800;
  margin-bottom: clamp(48px, 8vh, 88px);
}
.steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 980px;
  margin: 0 auto;
}
.step {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 300px);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  width: 100%;
  justify-content: center;
}
.step-connector {
  width: 1px;
  height: clamp(40px, 7vh, 72px);
  background: var(--card-line);
  margin: 8px 0;
}
.step-label { color: var(--orange); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.step-text h3 { font-size: 19px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.01em; }
.step-text p { font-size: 13.5px; color: var(--ink); margin-bottom: 10px; max-width: 300px; }

.step-card { margin: 0 auto; }
.demo-chat.small .chat-p { font-size: 12px; }

/* step 2 popup: JS anchors it to the selection; CSS keeps a sane
   fallback spot for the no-JS / reduced-motion end state */
#step2Popup { left: 26px; top: 226px; }

/* --- step 3 map card ---------------------------------------- */
.map-card {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 22px;
  min-height: 250px;
}
.map-skeleton { display: flex; flex-direction: column; gap: 7px; padding-top: 4px; }
.sk-bar { height: 7px; border-radius: 4px; background: var(--tan); opacity: .65; }
.sk-bar.w9 { width: 100%; } .sk-bar.w8 { width: 88%; } .sk-bar.w7 { width: 76%; }
.sk-bar.w6 { width: 64%; } .sk-bar.w5 { width: 52%; }
.sk-gap { height: 10px; }
.sk-box { height: 44px; border: 1px solid var(--card-line); border-radius: 6px; margin-top: auto; }

.map-tree {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 14px 16px;
  background: rgba(255,255,255,.3);
}
.map-root {
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-bottom: 10px;
}
.map-quest {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--rose);
  background: var(--rose-tint);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  margin-bottom: 12px;
}
.mq-title { color: var(--magenta); font-weight: 600; }
.mq-sub { color: var(--muted); font-size: 10px; }
.map-bars { display: flex; flex-direction: column; gap: 9px; }
.map-bar .tree-bar { width: 120px; height: 9px; }
.map-bar.deep { padding-left: 22px; }
.map-bar.deep .tree-bar { width: 96px; }

/* ============================================================
   Try it
   ============================================================ */
.tryit {
  padding: clamp(56px, 9vh, 110px) clamp(24px, 6vw, 90px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.try-kicker {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 26px;
  color: var(--ink);
}
.try-kicker::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--rose);
  margin-right: 9px;
  vertical-align: 1px;
}
.try-card {
  max-width: 560px;
  padding: 26px 24px 22px;
}
.try-para {
  font-size: 13.5px;
  line-height: 1.75;
  cursor: text;
}
.try-para::selection, .try-para *::selection { background: var(--sel-blue); }
.hl-kept {
  background: var(--rose-tint);
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.try-spawn { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.sq-mini {
  border: 1px solid var(--card-line);
  border-left: 3px solid var(--rose);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.35);
  opacity: 1;
  transform: none;
  transition: opacity .4s ease, transform .4s cubic-bezier(.3,.7,.3,1);
}
.sq-mini.enter { opacity: 0; transform: translateY(8px); }
.sq-mini.leave { opacity: 0; transform: translateY(-6px); }
.sq-mini .mini-from {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 7px;
}
.sq-mini .mini-bars { display: flex; flex-direction: column; gap: 6px; }
.sq-mini .mini-bars span { height: 7px; border-radius: 4px; display: block; }

.try-notes {
  position: absolute;
  left: -150px;
  top: 24px;
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 16px;
}
.try-notes .note-card { transition: opacity .4s ease, transform .4s ease; }
.try-notes .note-card.enter { opacity: 0; transform: translateX(10px); }
.try-notes .note-card.leave { opacity: 0; transform: translateX(-6px); }

.try-input { margin-top: 18px; }
.try-input-placeholder { color: var(--muted); }
.quote-chip {
  display: inline-block;
  background: var(--rose-tint);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink);
  font-size: 11px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  margin-right: 6px;
}
.try-reset {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.try-reset:hover { color: var(--ink); }

/* ============================================================
   Closing
   ============================================================ */
.closing {
  padding: clamp(64px, 11vh, 140px) clamp(24px, 7vw, 110px) clamp(72px, 12vh, 150px);
  border-top: 1px solid var(--line);
}
.closing p {
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 22px;
  max-width: 420px;
}
.closing-btn { margin-top: 10px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-demo { padding-right: 58px; }
  .hero-note { left: 10px; top: auto; bottom: 68px; }
  .step { grid-template-columns: 1fr; gap: 22px; }
  .step-text { max-width: 480px; margin: 0 auto; width: 100%; }
  .try-notes {
    position: static;
    width: auto;
    padding: 0;
    margin-top: 12px;
    order: 3;
  }
  .try-card { display: flex; flex-direction: column; }
  .try-notes .note-card { max-width: none; }
  .ugh-head h2 { white-space: normal; }
}

/* ============================================================
   Reduced motion — end states everywhere, no transitions
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
