/* style.css - Night to Fire.
   --heat (0..1, eased toward the current kaalam by the ring) drives the mood:
   the canvases, this sheet, and the shader's uHeat all read it. */

:root {
  --heat: 0;
  --night: #08060a;
  --ember: #e0512c;
  --gold: #e3b94e;
  --zari: #c69a3a;
  --cream: #f1e7cf;
  --reed: #e25a82;
  --ink: rgba(241, 231, 207, 0.92);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* canvases fill the viewport: field behind, ring in front (clicks pass through) */
#field, #ring { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#field { z-index: 0; }
#ring  { z-index: 1; pointer-events: none; }

/* calm wash until the WebGL field paints, and the reduced-motion fallback */
#field {
  background:
    radial-gradient(120% 90% at 50% 80%,
      color-mix(in oklab, var(--ember) calc(var(--heat) * 30%), #0c0a10) 0%,
      var(--night) 60%);
}

header, footer { position: fixed; left: 0; right: 0; z-index: 3; text-align: center; pointer-events: none; }
header { top: 0; padding: 1.05rem 1rem 0; }
footer { bottom: 0; padding: 0 1rem 1.15rem; }
footer > * { pointer-events: auto; }

h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  letter-spacing: 0.02em;
  color: var(--cream);
  text-shadow: 0 0 18px color-mix(in oklab, var(--gold) calc(30% + var(--heat) * 50%), transparent);
}
.hint {
  margin: 0.35rem 0 0;
  min-height: 1.2em;
  font-size: 0.92rem;
  color: color-mix(in oklab, var(--gold) 80%, var(--cream));
  opacity: 0.9;
}

/* ---------- buttons (base) ---------- */
button {
  font: inherit;
  color: var(--ink);
  background: rgba(20, 16, 22, 0.5);
  border: 1px solid color-mix(in oklab, var(--zari) 50%, transparent);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(6px);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
button:disabled { opacity: 0.4; cursor: default; }
button:not(:disabled):hover { border-color: var(--gold); transform: translateY(-1px); }

/* ---------- thaalam selector (top-left) ---------- */
.thaalam-select { position: fixed; z-index: 3; top: 0.9rem; left: 0.9rem; display: flex; gap: 0.45rem; }
.thaalam-btn { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.12; padding: 0.4rem 0.8rem; border-radius: 12px; }
.thaalam-btn .tname { font-weight: 600; font-size: 0.86rem; }
.thaalam-btn small { font-size: 0.62rem; opacity: 0.6; }
.thaalam-btn.active {
  border-color: var(--gold);
  background: color-mix(in oklab, var(--gold) 16%, rgba(20, 16, 22, 0.6));
  box-shadow: 0 0 16px color-mix(in oklab, var(--gold) 35%, transparent);
}

/* ---------- corner buttons (help + teach) ---------- */
.corner-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-weight: 700; display: grid; place-items: center; }
#help  { position: fixed; z-index: 3; top: 0.9rem; right: 3.4rem; }
#teach { position: fixed; z-index: 3; top: 0.9rem; right: 0.9rem; }
#teach[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px color-mix(in oklab, var(--gold) 40%, transparent); }

/* ---------- voice tokens (footer) ---------- */
.tokens { display: flex; gap: 0.55rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.8rem; }
.token {
  display: flex; flex-direction: column; align-items: center; gap: 0.18rem;
  min-width: 76px; padding: 0.5rem 0.6rem; border-radius: 14px;
  background: rgba(18, 14, 20, 0.5);
  border: 1px solid color-mix(in oklab, var(--c, var(--zari)) 35%, transparent);
  color: color-mix(in oklab, var(--c, var(--cream)) 70%, var(--cream));
}
.token .glyph svg { width: 26px; height: 26px; display: block; }
.token .name { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.01em; }
.token .gloss { display: none; font-size: 0.63rem; opacity: 0.72; max-width: 116px; text-align: center; line-height: 1.2; }
body.teach .token .gloss { display: block; }
.token.active {
  border-color: var(--c);
  background: color-mix(in oklab, var(--c) 14%, rgba(18, 14, 20, 0.6));
  box-shadow: 0 0 18px color-mix(in oklab, var(--c) 45%, transparent);
  color: var(--cream);
}
.token.hit { animation: tokhit 0.4s ease; }
@keyframes tokhit {
  0% { transform: scale(1); }
  28% { transform: scale(1.12); box-shadow: 0 0 26px var(--c); }
  100% { transform: scale(1); }
}

/* ---------- the Ascend / Muri hero ---------- */
.ascend { font-weight: 600; padding: 0.7rem 1.5rem; font-size: 0.95rem; }
.ascend.ready { border-color: var(--gold); animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 16px color-mix(in oklab, var(--gold) 38%, transparent); }
  50% { box-shadow: 0 0 32px color-mix(in oklab, var(--gold) 70%, transparent); }
}
.ascend.muri { border-color: var(--ember); color: var(--cream); box-shadow: 0 0 22px color-mix(in oklab, var(--ember) 55%, transparent); }

/* ---------- kaalam ladder (right-center) ---------- */
.kaalam-ladder { position: fixed; z-index: 3; top: 50%; right: 0.9rem; transform: translateY(-50%); display: flex; flex-direction: column; gap: 0.32rem; align-items: center; }
.rung {
  position: relative; width: 30px; height: 16px; border-radius: 5px;
  display: grid; place-items: center;
  background: rgba(18, 14, 20, 0.4);
  border: 1px solid color-mix(in oklab, var(--zari) 38%, transparent);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.rung b { font-size: 0.6rem; opacity: 0.5; }
.rung em { display: none; }
body.teach .rung em { display: block; position: absolute; right: 38px; font-style: normal; font-size: 0.6rem; opacity: 0.6; white-space: nowrap; }
.rung.lit { background: color-mix(in oklab, var(--ember) 28%, rgba(18, 14, 20, 0.5)); border-color: var(--gold); }
.rung.lit b { opacity: 0.95; }
.rung.current { border-color: var(--ember); box-shadow: 0 0 14px var(--ember); transform: scale(1.1); }
.ladder-label { font-size: 0.6rem; opacity: 0.6; margin-top: 0.2rem; }

/* ---------- teaching panel (bottom-left) ---------- */
.teach-panel {
  position: fixed; z-index: 3; left: 0.9rem; bottom: 5.4rem; max-width: 260px;
  padding: 0.7rem 0.9rem; border-radius: 12px;
  background: rgba(10, 8, 12, 0.74);
  border: 1px solid color-mix(in oklab, var(--zari) 40%, transparent);
  backdrop-filter: blur(8px); font-size: 0.72rem;
}
.teach-panel h3 { margin: 0 0 0.2rem; font-family: Fraunces, serif; font-size: 0.9rem; color: var(--gold); }
.teach-panel .kline { margin: 0 0 0.45rem; opacity: 0.82; }
.glossary { margin: 0; display: flex; flex-direction: column; gap: 0.28rem; }
.gterm { display: flex; gap: 0.45rem; }
.gterm dt { color: var(--gold); font-weight: 600; min-width: 62px; text-transform: capitalize; }
.gterm dd { margin: 0; opacity: 0.82; line-height: 1.25; }

/* ---------- first-visit guide ---------- */
.guide { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(4, 3, 6, 0.72); backdrop-filter: blur(3px); }
.guide[hidden] { display: none; }
.guide-card {
  max-width: 380px; margin: 1rem; padding: 1.4rem 1.5rem; border-radius: 16px;
  background: linear-gradient(160deg, #14101a, #0a0810);
  border: 1px solid color-mix(in oklab, var(--zari) 45%, transparent);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
}
.guide-card h2 { margin: 0 0 0.7rem; font-family: Fraunces, serif; color: var(--gold); }
.guide-card ol { margin: 0 0 1rem; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.86rem; line-height: 1.4; }
.guide-card strong { color: var(--gold); font-weight: 600; }
.guide-close { display: block; margin-left: auto; }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .kaalam-ladder { right: 0.5rem; gap: 0.24rem; }
  .rung { width: 24px; height: 13px; }
  .teach-panel { bottom: 5.6rem; max-width: 70vw; }
  .token { min-width: 64px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  button, .rung { transition: none; }
  .ascend.ready { animation: none; box-shadow: 0 0 18px color-mix(in oklab, var(--gold) 45%, transparent); }
  .token.hit { animation: none; }
}
