/* What is a Harness? — 3D explainer styles */
:root {
  --ink: #0b1020;
  --paper: rgba(12, 16, 32, 0.82);
  --paper-light: rgba(255, 255, 255, 0.06);
  --accent: #ffd23f;
  --violet: #7c5cff;
  --cyan: #3fd9ff;
  --text: #f2f5ff;
  --muted: #b9c3dd;
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- canvas ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #1b2547, #0b1020 75%);
  transition: opacity 0.6s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
.load-box { text-align: center; color: var(--muted); }
.load-box h1 { color: var(--text); font-size: 1.4rem; }
.load-spinner {
  width: 54px; height: 54px; margin: 0 auto 18px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  pointer-events: none;
  font-size: 0.95rem;
}
#topbar .brand {
  background: var(--paper);
  backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--paper-light);
}
#topbar .hint {
  color: var(--muted);
  background: var(--paper);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--paper-light);
  font-size: 0.8rem;
}

/* ---------- nav dots ---------- */
#navdots {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 20;
}
.navdot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  background: transparent; cursor: pointer;
  padding: 0; position: relative;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.navdot:hover, .navdot:focus-visible { transform: scale(1.35); border-color: var(--accent); outline: none; }
.navdot.on { background: var(--accent); border-color: var(--accent); }
.navdot::after {
  content: attr(data-tip);
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  white-space: nowrap;
  background: var(--paper); color: var(--text);
  font-size: 0.75rem; padding: 5px 10px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  border: 1px solid var(--paper-light);
}
.navdot:hover::after, .navdot:focus-visible::after { opacity: 1; }

/* ---------- scrollytelling column ---------- */
#scroller {
  position: fixed; z-index: 10;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 42vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12vh 56px 12vh 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
#scroller section {
  min-height: 86vh;
  display: flex; align-items: center;
  pointer-events: none;
}
#scroller .card {
  pointer-events: auto;
  background: var(--paper);
  backdrop-filter: blur(14px);
  border: 1px solid var(--paper-light);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  opacity: 0.35;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.45s;
  max-height: 76vh;
  overflow-y: auto;
}
#scroller section.on .card,
#scroller section:nth-child(1) .card { }
.card h1 { font-size: 2.1rem; line-height: 1.08; margin: 0 0 14px; }
.card h1 em { color: var(--accent); font-style: normal; }
.card h2 { font-size: 1.45rem; line-height: 1.15; margin: 0 0 12px; }
.card p { line-height: 1.55; margin: 0 0 12px; color: var(--text); font-size: 0.98rem; }
.card .dict {
  background: var(--paper-light);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 0 10px 10px 0;
  font-size: 0.92rem;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 0.75rem; color: var(--cyan); margin: 0 0 8px !important;
  font-weight: 700;
}
.scrollcue { color: var(--muted); font-size: 0.85rem; }
.hero-card { text-align: left; }

/* active section highlighting driven by body[data-chapter] */
#scroller section .card { }
body[data-chapter="hero"] section[data-ch="hero"] .card,
body[data-chapter="climb"] section[data-ch="climb"] .card,
body[data-chapter="bridge"] section[data-ch="bridge"] .card,
body[data-chapter="sysprompt"] section[data-ch="sysprompt"] .card,
body[data-chapter="tools"] section[data-ch="tools"] .card,
body[data-chapter="loop"] section[data-ch="loop"] .card,
body[data-chapter="translate"] section[data-ch="translate"] .card,
body[data-chapter="closing"] section[data-ch="closing"] .card {
  opacity: 1;
  transform: none;
  border-color: rgba(255, 210, 63, 0.45);
}

/* ---------- try-it controls ---------- */
.tryit {
  margin-top: 14px;
  background: rgba(255, 210, 63, 0.07);
  border: 1px dashed rgba(255, 210, 63, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
}
.trytitle { font-weight: 700; margin: 0 0 8px !important; font-size: 0.9rem; color: var(--accent); }
.tryhint { font-size: 0.84rem; color: var(--muted); margin: 8px 0 0 !important; }
.btn {
  font: inherit;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.09);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  padding: 9px 16px;
  margin: 4px 6px 4px 0;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s, border-color 0.18s;
  min-height: 40px;
}
.btn:hover { background: rgba(255,255,255,0.18); transform: translateY(-1px); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: #ffdf6e; }

/* loop chapter controls */
.loop-caption {
  background: rgba(63, 217, 255, 0.1);
  border-left: 3px solid var(--cyan);
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  min-height: 3.2em;
  font-size: 0.92rem !important;
}
#loop-steps {
  margin: 0 0 12px; padding-left: 0;
  list-style: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
}
#loop-steps li {
  font-size: 0.83rem; color: var(--muted);
  padding: 3px 0 3px 4px;
  transition: color 0.3s;
}
#loop-steps li.done { color: #7cf2c8; }
#loop-steps li.done::after { content: " ✓"; }
#loop-scrub {
  width: 100%; margin-top: 10px;
  accent-color: var(--accent);
  min-height: 28px;
}

/* cost comparison */
.costcompare { margin-top: 12px; }
.costrow {
  display: grid; grid-template-columns: 92px 1fr 30px;
  align-items: center; gap: 8px;
  font-size: 0.85rem; margin-bottom: 6px;
}
.costrow .bar { height: 10px; background: rgba(255,255,255,0.1); border-radius: 6px; overflow: hidden; }
.costrow .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); border-radius: 6px; }
.costrow b { color: var(--accent); text-align: right; }

/* closing */
.recap ul { margin: 0; padding-left: 18px; }
.recap li { font-size: 0.9rem; line-height: 1.5; margin-bottom: 6px; }
.hammerline {
  font-size: 1.25rem !important;
  font-weight: 700;
  color: var(--accent) !important;
  text-align: center;
  margin: 18px 0 6px !important;
  line-height: 1.35 !important;
}
.credits { font-size: 0.8rem !important; color: var(--muted) !important; text-align: center; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--paper);
  border: 1px solid rgba(255, 210, 63, 0.5);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 30;
  max-width: min(640px, 90vw);
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(10px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #scroller { width: min(400px, 46vw); padding-right: 44px; }
}

@media (max-width: 700px) {
  :root { font-size: 15px; }
  /* canvas occupies the top band; the story scrolls in the bottom sheet */
  #scene { height: 42vh; }
  #scroller {
    left: 0; right: 0; top: 42vh;
    width: auto;
    height: 58vh;
    padding: 3vh 14px 8vh;
  }
  #scroller section { min-height: 52vh; align-items: flex-start; }
  #scroller .card {
    padding: 18px 18px;
    max-height: none;
    opacity: 0.92;
    transform: none;
  }
  .card h1 { font-size: 1.6rem; }
  .card h2 { font-size: 1.2rem; }
  .card p { font-size: 0.95rem; }
  #navdots { right: 10px; top: 24%; gap: 8px; }
  .navdot { width: 10px; height: 10px; }
  .navdot::after { display: none; }
  #topbar .hint { display: none; }
  #loop-steps { grid-template-columns: 1fr; }
  .costrow { grid-template-columns: 84px 1fr 26px; }
  .btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .load-spinner { animation: none; }
  #scroller .card { transition: none; }
}
