/* eMath geometry teacher - the whole stylesheet.
   No build step: this file is served exactly as it is written. */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --brand-soft: #eff6ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --ok-ink: #065f46;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --warn-ink: #92400e;
  --bad: #e11d48;
  --bad-soft: #fff1f2;
  --accent: #7c3aed;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --font: "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #111c33;
    --surface-2: #0f172a;
    --border: #28374f;
    --ink: #e2e8f0;
    --muted: #94a3b8;
    --brand: #3b82f6;
    --brand-soft: #16233c;
    --ok-soft: #08261d;
    --ok-ink: #a7f3d0;
    --warn-soft: #2a1f08;
    --warn-ink: #fcd34d;
    --bad-soft: #2b0f17;
    --accent: #c4b5fd;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111c33;
  --surface-2: #0f172a;
  --border: #28374f;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --brand: #3b82f6;
  --brand-soft: #16233c;
  --ok-soft: #08261d;
  --ok-ink: #a7f3d0;
  --warn-soft: #2a1f08;
  --warn-ink: #fcd34d;
  --bad-soft: #2b0f17;
  --accent: #c4b5fd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Several blocks below set `display`, which would otherwise beat the browser's
   own rule for [hidden] and leave a hidden element on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 16px 48px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 1120px; margin: 0 auto; display: grid; gap: 18px; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h3 { font-size: 1rem; }
p { margin: 0; }

/* -- header ------------------------------------------------------------- */
.top {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand b { letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark rect { fill: var(--brand); }
.brand-mark path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linejoin: round; }

.theme-icon {
  display: block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* -- cards -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* -- form --------------------------------------------------------------- */
.ask form { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field.small { min-width: 120px; }

textarea, input[type="text"], select {
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  width: 100%;
  resize: vertical;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.controls .primary { margin-left: auto; }

button { font: inherit; cursor: pointer; border-radius: 12px; transition: all .15s ease; }
button:disabled { opacity: .55; cursor: progress; }

.primary {
  background: var(--brand);
  color: var(--brand-ink);
  border: 1px solid transparent;
  padding: 11px 20px;
  font-weight: 600;
}
.primary:hover:not(:disabled) { filter: brightness(1.08); }

.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--border);
  padding: 8px 14px;
}
.ghost:hover { background: var(--surface-2); border-color: var(--brand); }

.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: .84rem;
  color: var(--muted);
}
.chip:hover { border-color: var(--brand); color: var(--ink); }

/* -- status ------------------------------------------------------------- */
.status { display: flex; gap: 16px; align-items: center; }

.spinner {
  width: 26px; height: 26px; flex: none;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: .88rem; }
.pipeline li { color: var(--muted); }
.pipeline li.done { color: var(--ink); }
.pipeline li.done::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.pipeline li:not(.done)::before { content: "· "; }

.problem-note {
  border-left: 4px solid var(--warn);
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.problem-note.bad { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.problem-note ul { margin: 8px 0 0; padding-left: 20px; font-size: .86rem; opacity: .85; }

/* -- result ------------------------------------------------------------- */
.echo { display: grid; gap: 10px; }
.echo-text { font-size: 1.02rem; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips .fact {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .82rem;
  font-weight: 600;
}

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 9px 18px;
  color: var(--muted);
  font-weight: 600;
}
.tab[aria-selected="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* -- figure ------------------------------------------------------------- */
.figure-card { display: grid; gap: 14px; align-content: start; position: sticky; top: 16px; }
@media (max-width: 900px) { .figure-card { position: static; } }

.figure { display: grid; place-items: center; min-height: 240px; }
.figure svg { width: 100%; height: auto; max-height: 52vh; }

.player { display: flex; align-items: center; gap: 10px; }

.icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: .72rem;
  flex: none;
}
.icon:hover { border-color: var(--brand); color: var(--brand); }
.icon.play { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-size: .8rem; }

.track { display: flex; gap: 5px; flex: 1; }
.track button {
  flex: 1; height: 7px; padding: 0; border: none; border-radius: 99px;
  background: var(--border);
}
.track button[data-on="1"] { background: var(--brand); }
.track button:hover { filter: brightness(1.15); }

.counter { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.hint-line { font-size: .86rem; color: var(--muted); min-height: 1.3em; }

/* -- steps -------------------------------------------------------------- */
.teach { display: grid; gap: 18px; align-content: start; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  opacity: .58;
  transition: opacity .25s ease, border-color .25s ease, transform .25s ease;
}
.step.seen { opacity: 1; }
.step.active { border-left-color: var(--brand); box-shadow: var(--shadow); transform: translateX(2px); }

.step-head { display: flex; align-items: center; gap: 10px; }
.step-no {
  width: 24px; height: 24px; flex: none;
  border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700;
}
.step.active .step-no { background: var(--brand); color: var(--brand-ink); }
.step-title { font-weight: 600; }

.step-math {
  font-family: var(--mono);
  font-size: 1.02rem;
  color: var(--brand);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 7px 11px;
  overflow-x: auto;
}
.step-text { font-size: .9rem; color: var(--muted); }

.why {
  font-size: .84rem;
  background: var(--brand-soft);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--ink);
}
.why-toggle {
  justify-self: start;
  background: none; border: none; padding: 0;
  color: var(--brand); font-size: .84rem; font-weight: 600;
}

/* -- hints -------------------------------------------------------------- */
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hints { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.hints:empty { margin: 0; }
.hints li {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: .9rem;
  animation: rise .3s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* -- answer ------------------------------------------------------------- */
.answer-box { display: grid; gap: 12px; }
.answer-row { display: flex; gap: 10px; }
.answer-row input { flex: 1; font-size: 1.1rem; font-weight: 600; }

.feedback { border-radius: 12px; padding: 11px 14px; font-size: .92rem; animation: rise .3s ease; }
.feedback.ok { background: var(--ok-soft); color: var(--ok-ink); }
.feedback.no { background: var(--bad-soft); color: var(--bad); }

.reveal { display: grid; gap: 10px; }
.reveal img { width: 100%; height: auto; border-radius: 12px; }

/* -- full solution ------------------------------------------------------ */
.full summary { cursor: pointer; font-weight: 600; }
.full-body { display: grid; gap: 14px; margin-top: 14px; justify-items: center; }
.full-body img { width: 100%; max-width: 640px; height: auto; border-radius: 12px; }

/* -- figure gallery ----------------------------------------------------- */
.top-nav { display: flex; align-items: center; gap: 10px; }
.top-nav a { text-decoration: none; }

.page-title { font-size: 1.35rem; margin-bottom: 6px; }
.page-lead { color: var(--muted); font-size: .92rem; max-width: 62ch; margin-bottom: 4px; }

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.gallery {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.shape-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 6px;
  align-content: start;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.shape-card:hover, .shape-card:focus-visible {
  border-color: var(--brand);
  transform: translateY(-2px);
  outline: none;
}
.shape-card h3 { font-size: .98rem; }
.shape-figure { display: grid; place-items: center; }
.shape-figure svg, .shape-figure img { width: 100%; height: auto; }
.shape-measures { font-size: .82rem; color: var(--muted); }

.viewer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  max-width: 720px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
.viewer::backdrop { background: rgba(15, 23, 42, .55); }
.viewer h2 { font-size: 1.15rem; margin-bottom: 4px; }
.viewer-note { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.viewer-close { display: flex; justify-content: flex-end; }
/* The drawing gives way a little, so a formula or two is visible without
   scrolling - they belong together on the screen. */
.viewer .figure svg { width: 100%; height: auto; max-height: 34vh; }
.layer-toggles { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }

.formulas {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.formula {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  display: grid;
  gap: 4px;
}
.formula-name { font-size: .8rem; font-weight: 600; color: var(--muted); }
.formula-letters {
  font-family: var(--mono);
  font-size: 1.02rem;
  color: var(--brand);
  font-weight: 600;
}
.formula-worked { font-family: var(--mono); font-size: .92rem; color: var(--ink); }

.foot {
  max-width: 1120px;
  margin: 28px auto 0;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
