/* Shapeshifter Academy: shared course stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:ital,wght@0,400;0,600;0,800;1,400&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --paper: #fbf8f1;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-soft: #5b6273;
  --rule: #e6e0d2;
  --grid: #ebe6da;
  --axis: #9a9384;

  --slide: #0fa39a;   /* translation */
  --mirror: #7c4dff;  /* reflection */
  --spin: #f2772c;    /* rotation */
  --zoom: #e8457c;    /* enlargement */
  --pip: #ffc93c;     /* mascot */
  --pip-edge: #c98e00;

  --good: #1f9d55;
  --good-bg: #e3f6ea;
  --bad: #d64545;
  --bad-bg: #fde8e8;

  --accent: var(--slide);
  --radius: 16px;
  --shadow: 0 2px 0 rgba(31,36,48,.06), 0 8px 24px rgba(31,36,48,.06);
  --measure: 40rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171a21; --card: #20242d; --ink: #eef0f4; --ink-soft: #a8afbf;
    --rule: #323846; --grid: #2a2f3b; --axis: #6f7789;
    --good-bg: #173326; --bad-bg: #3a1d1f;
    --shadow: 0 2px 0 rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --paper: #171a21; --card: #20242d; --ink: #eef0f4; --ink-soft: #a8afbf;
  --rule: #323846; --grid: #2a2f3b; --axis: #6f7789;
  --good-bg: #173326; --bad-bg: #3a1d1f;
}

body[data-power="slide"]  { --accent: var(--slide); }
body[data-power="mirror"] { --accent: var(--mirror); }
body[data-power="spin"]   { --accent: var(--spin); }
body[data-power="zoom"]   { --accent: var(--zoom); }
body[data-power="all"]    { --accent: #3b82f6; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.08rem/1.6 Nunito, system-ui, sans-serif;
}
a { color: var(--accent); font-weight: 700; text-underline-offset: 3px; }
h1, h2, h3 { font-family: Fredoka, Nunito, sans-serif; line-height: 1.15; letter-spacing: .2px; }
h1 { font-size: clamp(2rem, 6vw, 2.9rem); margin: .2em 0 .3em; }
h2 { font-size: 1.55rem; margin: 2.2rem 0 .6rem; }
h3 { font-size: 1.2rem; margin: 1.4rem 0 .4rem; }
p { margin: .6em 0; }
code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .95em; }
strong { font-weight: 800; }
.soft { color: var(--ink-soft); }
.small { font-size: .9rem; }

/* ---------- layout ---------- */
.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 16px 4rem; }
.wide { max-width: 56rem; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.topbar .home { font-family: Fredoka; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar .xp { margin-left: auto; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: .95rem; }
.xpbar { width: 90px; height: 10px; border-radius: 9px; background: var(--rule); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pip), var(--zoom)); transition: width .6s; }
.iconbtn { border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--ink); }
.iconbtn:hover { background: var(--rule); }

.hero { padding: 1.6rem 0 .4rem; }
.kicker {
  display: inline-flex; gap: 8px; align-items: center;
  font: 700 .8rem/1 Fredoka; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 6px 10px; border-radius: 999px;
}
.lead { font-size: 1.2rem; color: var(--ink-soft); }

/* ---------- cards & callouts ---------- */
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 1.2rem 0; }
.card > :first-child { margin-top: 0; }
.goal { border-left: 6px solid var(--accent); }
.goal b { font-family: Fredoka; color: var(--accent); }

.pip-says { display: flex; gap: 12px; align-items: flex-start; margin: 1.2rem 0; }
.pip-says .pip-avatar { flex: 0 0 54px; width: 54px; height: 54px; }
.bubble {
  position: relative; background: var(--card); border: 2px solid var(--ink); border-radius: 18px;
  padding: 10px 14px; font-weight: 600;
}
.bubble::before {
  content: ""; position: absolute; left: -10px; top: 16px; width: 14px; height: 14px;
  background: var(--card); border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
}

.rule-box { background: color-mix(in srgb, var(--accent) 9%, var(--card)); border: 2px dashed var(--accent); border-radius: var(--radius); padding: 14px 18px; margin: 1.2rem 0; }
.rule-box h3 { margin-top: 0; color: var(--accent); }

.flashback { border: 2px solid var(--pip); background: color-mix(in srgb, var(--pip) 10%, var(--card)); }
.flashback h3::before { content: "⚡ "; }

.stuck { border: 2px dashed var(--rule); background: transparent; box-shadow: none; }
.source { display: flex; gap: 14px; align-items: center; }
.source .play { flex: 0 0 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 1.2rem; }

/* ---------- boards ---------- */
.board-wrap { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); margin: 1rem 0; }
svg.board { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
svg.board .gl { stroke: var(--grid); stroke-width: 1; }
svg.board .ax { stroke: var(--axis); stroke-width: 2; }
svg.board .tick { fill: var(--ink-soft); font: 600 11px Nunito, sans-serif; }
svg.board .axlabel { fill: var(--ink-soft); font: italic 700 14px Nunito, serif; }
svg.board .lbl { font: 800 15px Fredoka, sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
svg.board .poly { stroke-width: 3; stroke-linejoin: round; }
svg.board .ghost { fill: none !important; stroke-dasharray: 6 6; stroke-width: 2.5; opacity: .75; }
svg.board .hover-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; opacity: 0; transition: opacity .1s; pointer-events: none; }
svg.board.pickable { cursor: crosshair; }
svg.board.pickable:hover .hover-ring { opacity: 1; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 4px 4px; }
.controls label { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.controls input[type=range] { accent-color: var(--accent); width: 150px; }
.readout { font-family: 'JetBrains Mono', monospace; font-weight: 700; background: var(--paper); border: 1px solid var(--rule); padding: 2px 8px; border-radius: 8px; }

/* ---------- buttons ---------- */
.btn {
  font: 700 1rem Fredoka, sans-serif; letter-spacing: .3px;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 12px; cursor: pointer;
  box-shadow: 0 3px 0 var(--ink); transition: transform .06s, box-shadow .06s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 0 3px 0 var(--ink); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.small { padding: 5px 10px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.dpad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); gap: 4px; }
.dpad .btn { padding: 0; font-size: 1.3rem; }

input.num {
  width: 3.4em; font: 700 1.1rem 'JetBrains Mono', monospace; text-align: center;
  padding: 6px; border: 2px solid var(--ink); border-radius: 10px; background: var(--card); color: var(--ink);
}
.vec { display: inline-grid; grid-template-rows: auto auto; gap: 4px; padding: 4px 10px; position: relative; vertical-align: middle; }
.vec::before, .vec::after { content: ""; position: absolute; top: 0; bottom: 0; width: 8px; border: 2.5px solid var(--ink); }
.vec::before { left: 0; border-right: 0; border-radius: 10px 0 0 10px; }
.vec::after { right: 0; border-left: 0; border-radius: 0 10px 10px 0; }
.vec.inline { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: .85em; line-height: 1.1; text-align: center; padding: 2px 9px; gap: 0; }
.vec.inline::before, .vec.inline::after { border-width: 2px; width: 6px; }

/* ---------- feedback ---------- */
.feedback { min-height: 1.6em; font-weight: 700; margin: 8px 4px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.dots { display: flex; gap: 6px; margin: 4px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--rule); }
.dots i.done { background: var(--good); }
.dots i.now { background: var(--accent); }

/* ---------- quiz ---------- */
.quiz .qhead { display: flex; justify-content: space-between; align-items: center; font: 700 .9rem Fredoka; color: var(--ink-soft); }
.quiz .q { font-size: 1.15rem; font-weight: 700; margin: 10px 0; }
.quiz .choices { display: grid; gap: 10px; }
@media (min-width: 560px) { .quiz .choices.two { grid-template-columns: 1fr 1fr; } }
.quiz .choice {
  text-align: left; font: 600 1.02rem Nunito, sans-serif; color: var(--ink);
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px; padding: 12px 14px; cursor: pointer;
  transition: border-color .1s, transform .1s;
}
.quiz .choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.quiz .choice.right { border-color: var(--good); background: var(--good-bg); }
.quiz .choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz .choice:disabled { cursor: default; }
.quiz .why { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper); }
.quiz .end { text-align: center; padding: 10px 0; }
.quiz .stars { font-size: 2.4rem; letter-spacing: 6px; }

/* ---------- badge / complete ---------- */
.complete { text-align: center; display: none; }
.complete.show { display: block; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.badge { width: 110px; height: 110px; margin: 0 auto; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.wiggle { animation: wiggle .4s; }

/* ---------- lesson nav ---------- */
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.lesson-nav a { text-decoration: none; }
.toc-mini { font-size: .92rem; color: var(--ink-soft); }

/* ---------- course map ---------- */
.map { display: grid; gap: 14px; }
.world { margin-top: 1.4rem; }
.world h2 { display: flex; align-items: center; gap: 10px; }
.world h2 .dot { width: 16px; height: 16px; border-radius: 50%; }
.level {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 2px solid var(--rule); border-radius: var(--radius); padding: 12px 14px;
  transition: transform .1s, border-color .1s;
}
.level:hover { transform: translateX(4px); border-color: var(--c, var(--accent)); }
.level .num { flex: 0 0 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font: 700 1.1rem Fredoka; color: #fff; background: var(--c, var(--accent)); }
.level .t { font: 600 1.08rem Fredoka; }
.level .d { font-size: .92rem; color: var(--ink-soft); }
.level .state { margin-left: auto; font-size: 1.3rem; }
.level.done { border-color: color-mix(in srgb, var(--good) 50%, var(--rule)); }

table.ref { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .98rem; }
table.ref th, table.ref td { border-bottom: 1px solid var(--rule); padding: 8px 6px; text-align: left; vertical-align: top; }
table.ref th { font-family: Fredoka; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .topbar, .lesson-nav, .btn, .controls, .stuck { display: none !important; }
  body { background: #fff; }
  .card, .board-wrap { box-shadow: none; break-inside: avoid; }
}

/* ---------- read-aloud buttons ---------- */
.bubble, .rule-box, .goal { position: relative; }
.bubble { padding-right: 40px; }
.rule-box, .goal { padding-right: 46px; }
.say-btn { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); cursor: pointer; font-size: 1rem; line-height: 1; display: grid; place-items: center; }
.say-btn:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.say-btn.talking { animation: pulse 1s infinite; background: var(--accent); }
@keyframes pulse { 50% { transform: scale(1.15); } }
@media print { .say-btn { display: none; } }
