/* ============================================================
   ENERGY — unit page styles
   Coaster ledger hero · First Hill Rule · KE explorer ·
   shelf lab · the Coaster (PE/KE/heat sim) · myth flips ·
   flashcards · exit ticket
   ============================================================ */

/* the hidden attribute must always win over the display rules below */
[hidden] { display: none !important; }

/* ---------- hero ---------- */
.en-hero {
  position: relative;
  padding-top: clamp(150px, 20vh, 200px);
  overflow: hidden;
  background: linear-gradient(180deg, #F7F2E4 0%, var(--sand-50) 60%, var(--sand-100) 100%);
}
.en-hero-grid {
  position: relative; z-index: 1; /* above .sun */
  display: grid; grid-template-columns: 1.15fr 0.85fr;
  align-items: center; gap: clamp(30px, 5vw, 60px);
  padding-bottom: 70px;
}
.en-hero-grid > * { min-width: 0; }
.en-title { font-size: clamp(2.9rem, 6.5vw, 5.4rem); margin-bottom: 26px; }
.en-title .char { display: inline-block; }
.en-hero .lede em { font-style: italic; color: var(--iris-500); }
.en-chips { display: flex; gap: 10px; margin-top: 30px; flex-wrap: wrap; }

.hero-coast {
  max-width: 420px; margin-left: auto; width: 100%;
  background: #FFFDF6; border: 1px solid rgb(13 13 17 / 0.08);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 18px 18px 10px;
}
.coast-svg { display: block; width: 100%; height: auto; }
.coast-cap { margin-top: 8px; text-align: center; }

/* ---------- the phenomenon ---------- */
.en-hill { background: var(--sand-100); }
.rule-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
  margin-bottom: clamp(36px, 5vw, 54px);
}
.rule-card .rule-num {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--amber-500); display: block; margin-bottom: 12px; line-height: 1;
}
.rule-card h3 { margin-bottom: 10px; }
.rule-card p { font-size: 14.5px; line-height: 1.65; color: var(--ink-700); }
.rule-card strong { color: var(--ink-900); }
.hill-question { max-width: 780px; }
.race-q {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.4rem, 3vw, 2.1rem); letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.race-a { font-size: 16.5px; line-height: 1.7; color: var(--ink-700); max-width: 68ch; }
.race-a strong, .race-a em { color: var(--ink-900); }
.race-a em { font-style: italic; color: var(--amber-500); }

/* ---------- KE explorer ---------- */
.en-kinetic { background: var(--sand-50); }
.ke-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px;
  align-items: start; max-width: 1000px;
}
.ke-panel { display: flex; flex-direction: column; gap: 8px; }
.pl-slider { margin-top: 6px; }
.pl-label {
  display: block; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-500);
  margin-bottom: 8px;
}
.pl-label strong { color: var(--ink-900); font-size: 13px; }
.pl-slider input[type="range"] { width: 100%; accent-color: var(--iris-500); height: 28px; }
.ke-out {
  margin-top: 18px; padding: 20px; text-align: center;
  border: 1px dashed rgb(91 84 214 / 0.4); border-radius: 16px;
}
.ke-num {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 2.7rem); letter-spacing: -0.02em;
  color: var(--ink-900); line-height: 1.05;
}
.ke-eq { display: block; margin-top: 8px; }
.ke-doublers { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.mass-btn {
  font: inherit; font-family: var(--font-mono); font-size: 11px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgb(13 13 17 / 0.16); background: #FFFDF6; color: var(--ink-700);
  transition: border-color 0.25s, background 0.25s;
}
.mass-btn:hover { border-color: var(--iris-500); }
.mass-btn.active { border-color: var(--iris-500); background: rgb(91 84 214 / 0.1); color: var(--iris-500); }
.ke-scale h3 { margin-bottom: 12px; }
.landing { font-size: 14.5px; line-height: 1.6; color: var(--ink-700); padding: 8px 0; }
.landing + .landing { border-top: 1px dashed rgb(13 13 17 / 0.1); }
.landing strong { color: var(--ink-900); }

/* ---------- shelf lab ---------- */
.en-potential { background: var(--sand-100); }
.pe-grid {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 22px;
  align-items: start;
}
.shelf-stage {
  position: relative; height: 300px; border-radius: 16px;
  background: linear-gradient(180deg, #F7EFDC 0%, #F0E5C9 100%);
  border: 1px solid rgb(13 13 17 / 0.1);
  overflow: hidden; margin-bottom: 16px;
}
.shelf {
  position: absolute; left: 8%; right: 8%; height: 10px;
  background: #C9A36A; border-radius: 4px;
  box-shadow: 0 4px 10px -4px rgb(13 13 17 / 0.35);
}
.shelf span {
  position: absolute; right: -8px; top: 16px;
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-300);
  text-align: right; white-space: nowrap;
}
.shelf.s1 { top: 18%; }
.shelf.s2 { top: 48%; }
.shelf.s3 { top: 78%; }
.shelf-beetle {
  position: absolute; left: 20%; width: 74px;
  transition: top 0.6s cubic-bezier(0.3, 1.3, 0.5, 1), left 0.6s;
}
.shelf-beetle svg { width: 100%; height: auto; display: block; transform: scaleX(-1); }
.shelf-beetle[data-on="1"] { top: calc(78% - 46px); }
.shelf-beetle[data-on="2"] { top: calc(48% - 46px); }
.shelf-beetle[data-on="3"] { top: calc(18% - 46px); }
.shelf-controls { display: flex; gap: 10px; }
.shelf-read { margin-top: 14px; min-height: 1.6em; }
.pe-kinds h3 { margin-bottom: 12px; }

/* ---------- the coaster (dark band) ---------- */
.en-coaster {
  background: var(--ink-900); color: var(--sand-50);
  border-radius: clamp(24px, 4vw, 48px);
  margin: 0 clamp(10px, 2vw, 24px);
  padding: var(--section-pad) 0;
}
.eyebrow-light { color: var(--iris-300); }
.lede-light { color: rgb(250 246 235 / 0.72); }
.coast-lab {
  display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 22px;
  align-items: stretch;
}
.coast-stage-wrap {
  background: #08080C; border: 1px solid rgb(250 246 235 / 0.12);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 16px;
}
.coast-stage { display: block; width: 100%; height: auto; }
#coast-cart { transition: none; }
.coast-bars { display: flex; flex-direction: column; gap: 10px; }
.cb-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 12px; }
.cb-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgb(250 246 235 / 0.55);
}
.cb-track {
  height: 12px; border-radius: 6px;
  background: rgb(250 246 235 / 0.1); overflow: hidden;
}
.cb-fill {
  display: block; height: 100%; width: 0%;
  border-radius: 6px;
  transition: width 0.12s linear;
}
.cb-pe { background: var(--iris-500); }
.cb-ke { background: var(--amber-500); }
.cb-heat { background: #C26A2B; }
.coast-controls {
  background: rgb(250 246 235 / 0.05); border: 1px solid rgb(250 246 235 / 0.12);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 22px;
}
.cc-label {
  display: block; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber-300); margin-bottom: 10px;
}
.cc-row { display: flex; gap: 8px; flex-wrap: wrap; }
.en-coaster .mass-btn {
  background: rgb(250 246 235 / 0.06); border-color: rgb(250 246 235 / 0.2);
  color: var(--sand-50);
}
.en-coaster .mass-btn:hover { border-color: var(--amber-500); }
.en-coaster .mass-btn.active {
  border-color: var(--amber-500); background: rgb(232 112 58 / 0.15); color: var(--amber-300);
}
.coast-status {
  margin-top: auto; min-height: 3.2em;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: rgb(250 246 235 / 0.6);
}
.coast-status.ok { color: #7BE39A; }
.coast-status.warn { color: var(--amber-300); }
.standards-note {
  margin-top: 44px;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.7;
  color: var(--ink-300); max-width: 70ch;
}
.standards-note strong { color: var(--ink-500); }
.standards-dark { color: rgb(250 246 235 / 0.35) !important; }
.standards-dark strong { color: rgb(250 246 235 / 0.65) !important; }

/* ---------- myth flip cards ---------- */
.en-myths { background: var(--sand-100); }
.myth-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.myth-flip {
  position: relative; min-height: 210px; padding: 0; border: 0;
  background: none; cursor: pointer; font: inherit; text-align: left;
  perspective: 1100px; border-radius: var(--radius);
}
.myth-flip:focus-visible { outline: 2px solid var(--iris-500); outline-offset: 3px; }
.myth-face {
  position: absolute; inset: 0; border-radius: var(--radius);
  padding: 28px; display: flex; flex-direction: column; justify-content: center; gap: 12px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.65s cubic-bezier(0.3, 1.3, 0.4, 1);
  font-family: var(--font-display); font-weight: 600; font-size: 1.14rem;
  line-height: 1.3; letter-spacing: -0.01em;
}
.myth-front {
  background: #FFFDF6; border: 1px solid rgb(13 13 17 / 0.08);
  box-shadow: var(--shadow-card); color: var(--ink-900);
}
.myth-tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber-500);
  border: 1px solid rgb(232 112 58 / 0.4); border-radius: 999px;
  padding: 4px 10px; align-self: flex-start;
}
.myth-back {
  background: var(--ink-900); color: var(--sand-50);
  font-family: var(--font-body); font-weight: 400; font-size: 0.98rem;
  line-height: 1.55; letter-spacing: 0;
  transform: rotateY(180deg);
}
.myth-back strong { color: var(--amber-300); font-family: var(--font-display); font-size: 1.15rem; display: block; margin-bottom: 4px; }
.myth-flip.flipped .myth-front { transform: rotateY(-180deg); }
.myth-flip.flipped .myth-back { transform: rotateY(0deg); }

/* antenna wiggle — applies to every <use> of the beetle symbol */
.beetle-antenna { transform-origin: 11px 54px; animation: ant-wig 2.6s ease-in-out infinite; }
@keyframes ant-wig {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-7deg); }
}

/* ============================================================
   FLASHCARDS (spaced repetition)
   ============================================================ */
.en-cards { background: var(--sand-50); }
.deck-wrap {
  display: grid; grid-template-columns: 300px 1fr;
  gap: 22px; align-items: start; max-width: 980px; margin-inline: auto;
}
.deck-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.deck-stat { text-align: center; }
.deck-stat-num {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: 1.9rem; line-height: 1.05; color: var(--ink-900);
}
.deck-stat-label {
  display: block; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-300);
  margin-top: 5px;
}
.deck-bar {
  grid-column: 1 / -1; height: 8px; border-radius: 4px;
  background: var(--sand-200); overflow: hidden; margin-top: 6px;
}
.deck-bar-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--iris-500), var(--amber-500));
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.deck-next { grid-column: 1 / -1; margin-top: 4px; line-height: 1.6; }
.deck-stats .sorter-reset { grid-column: 1 / -1; justify-self: start; }
.deck-main { min-width: 0; }
.flashcard {
  position: relative; display: block; width: 100%; height: 270px;
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit;
  perspective: 1300px; border-radius: var(--radius);
}
.flashcard:focus-visible { outline: 2px solid var(--iris-500); outline-offset: 3px; }
.fc-face {
  position: absolute; inset: 0; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 30px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.62s cubic-bezier(0.3, 1.25, 0.4, 1);
}
.fc-front {
  background: #FFFDF6; border: 1px solid rgb(13 13 17 / 0.08);
  box-shadow: var(--shadow-card);
}
.fc-back {
  background: var(--ink-900); color: var(--sand-50);
  transform: rotateY(180deg);
}
.flashcard.flipped .fc-front { transform: rotateY(-180deg); }
.flashcard.flipped .fc-back { transform: rotateY(0deg); }
.fc-kicker {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--iris-500);
}
.fc-back .fc-kicker { color: var(--amber-300); }
.fc-term {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -0.02em;
  color: var(--ink-900); text-align: center;
}
.fc-def {
  font-size: clamp(0.98rem, 2vw, 1.2rem); line-height: 1.55;
  color: rgb(250 246 235 / 0.88); text-align: center; max-width: 46ch;
}
.fc-hint {
  position: absolute; bottom: 18px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em;
  color: var(--ink-300);
}
.deck-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.grade-btn {
  font: inherit; font-weight: 700; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 10px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid; background: none;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.grade-btn small { font-family: var(--font-mono); font-weight: 400; font-size: 10px; opacity: 0.75; }
.grade-btn:hover { transform: translateY(-2px); }
.grade-btn:disabled { opacity: 0.35; pointer-events: none; }
.grade-again { border-color: var(--amber-500); color: var(--amber-500); }
.grade-again:hover { box-shadow: 0 8px 20px -8px rgb(232 112 58 / 0.5); }
.grade-good { border-color: var(--iris-500); background: var(--iris-500); color: #fff; }
.grade-good:hover { box-shadow: 0 8px 20px -8px rgb(91 84 214 / 0.6); }
.grade-easy { border-color: var(--ink-900); color: var(--ink-900); }
.grade-easy:hover { box-shadow: 0 8px 20px -8px rgb(13 13 17 / 0.4); }
.deck-status { margin-top: 14px; text-align: center; }
.sorter-reset {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em;
  color: var(--ink-500); background: none; border: 0; cursor: pointer;
  border-bottom: 1px dashed var(--ink-300); padding: 2px 0;
}
.sorter-reset:hover { color: var(--amber-500); border-color: var(--amber-500); }

/* ============================================================
   EXIT TICKET
   ============================================================ */
.en-quiz { background: var(--sand-100); }
.quiz { max-width: 780px; margin-inline: auto; }
.quiz-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.quiz-dots { display: flex; gap: 7px; }
.quiz-dots i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--sand-300); transition: background 0.3s;
}
.quiz-dots i.current { background: var(--amber-500); }
.quiz-dots i.answered { background: var(--iris-500); }
.quiz-q {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.2rem, 2.6vw, 1.55rem); line-height: 1.25;
  letter-spacing: -0.01em; margin-bottom: 20px;
}
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt {
  font: inherit; font-size: 15px; text-align: left;
  padding: 13px 16px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid rgb(13 13 17 / 0.14);
  background: var(--sand-50); color: var(--ink-900);
  transition: border-color 0.25s, background 0.25s, transform 0.2s, opacity 0.25s;
}
.quiz-opt:hover { border-color: var(--iris-500); transform: translateY(-1px); }
.quiz-opt:focus-visible { outline: 2px solid var(--iris-500); outline-offset: 2px; }
.quiz-opt.correct { border-color: #2F9E5F; background: rgb(123 227 154 / 0.14); }
.quiz-opt.wrong { border-color: #D64545; background: rgb(214 69 69 / 0.08); animation: shake 0.42s; }
.quiz-opt.dim { opacity: 0.45; pointer-events: none; }
.quiz-opt.locked { pointer-events: none; }
.quiz-feedback {
  min-height: 1.7em; margin-top: 14px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  color: var(--ink-500);
}
.quiz-feedback.ok { color: #2F9E5F; }
.quiz-feedback.no { color: #C26A2B; }
.quiz-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.quiz-result { text-align: center; padding-top: 10px; }
.quiz-stamp { width: 150px; margin: 0 auto 20px; color: var(--iris-500); animation: stamp-in 0.55s cubic-bezier(0.2, 1.4, 0.4, 1); }
.quiz-stamp svg { width: 100%; height: auto; display: block; }
@keyframes stamp-in {
  from { transform: rotate(-9deg) scale(2.3); opacity: 0; }
}
.quiz-score {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -0.02em;
}
.quiz-note { color: var(--ink-500); font-size: 15px; margin-top: 8px; }
.quiz-result .sorter-reset { margin-top: 18px; }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* ---------- closer ---------- */
.en-closer { padding: clamp(80px, 10vw, 130px) 0; text-align: center; background: var(--sand-50); }
.en-closer .btn { margin: 6px; }
.en-closer-big {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -0.03em;
  margin-bottom: 34px;
}

/* ---------- chapter dots ---------- */
.chapters {
  position: fixed; right: 20px; top: 50%; transform: translateY(-50%);
  z-index: 900; display: flex; flex-direction: column; gap: 13px;
}
.chapters a {
  position: relative; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--ink-500);
  box-shadow: 0 0 0 3px rgb(250 246 235 / 0.5);
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
.chapters a:hover { transform: scale(1.35); }
.chapters a.active { background: var(--amber-500); border-color: var(--amber-500); }
.chapters a span {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; white-space: nowrap;
  background: var(--ink-900); color: var(--sand-50);
  padding: 4px 9px; border-radius: 7px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.chapters a:hover span, .chapters a:focus-visible span { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .chapters { display: none; }
}
@media (max-width: 1020px) {
  .en-hero-grid { grid-template-columns: 1fr; }
  .hero-coast { margin: 10px auto 0; }
  .rule-grid { grid-template-columns: 1fr; }
  .ke-grid { grid-template-columns: 1fr; }
  .pe-grid { grid-template-columns: 1fr; }
  .coast-lab { grid-template-columns: 1fr; }
  .myth-grid { grid-template-columns: 1fr; }
  .myth-flip { min-height: 170px; }
  .deck-wrap { grid-template-columns: 1fr; }
  .deck-stats { max-width: 460px; }
}
@media (max-width: 640px) {
  .flashcard { height: 300px; }
  .ke-doublers, .shelf-controls { flex-wrap: wrap; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .beetle-antenna { animation: none !important; }
  .shelf-beetle { transition: none; }
  .cb-fill { transition: none; }
}
