/* Geometry revision site — light by default, dark by preference or toggle. */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f1f3f9;
  --ink: #171c2b;
  --ink-soft: #5a6479;
  --line: #dfe3ee;
  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --ok: #15803d;
  --ok-soft: #e4f5ea;
  --bad: #be123c;
  --bad-soft: #fdeaef;
  --figure: #2b3245;
  --figure-fill: #eceafd;
  --shadow: 0 1px 2px rgba(20, 25, 45, .06), 0 8px 24px rgba(20, 25, 45, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10131c;
    --panel: #171b27;
    --panel-2: #1e2331;
    --ink: #e8ecf6;
    --ink-soft: #9aa4bb;
    --line: #2a3143;
    --accent: #8b87ff;
    --accent-soft: #262445;
    --ok: #4ade80;
    --ok-soft: #16301f;
    --bad: #fb7185;
    --bad-soft: #351822;
    --figure: #d5dcec;
    --figure-fill: #232144;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #10131c;
  --panel: #171b27;
  --panel-2: #1e2331;
  --ink: #e8ecf6;
  --ink-soft: #9aa4bb;
  --line: #2a3143;
  --accent: #8b87ff;
  --accent-soft: #262445;
  --ok: #4ade80;
  --ok-soft: #16301f;
  --bad: #fb7185;
  --bad-soft: #351822;
  --figure: #d5dcec;
  --figure-fill: #232144;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Several hidden elements are flex/grid containers, whose display would
   otherwise win over the browser's default [hidden] rule. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { width: min(920px, 100% - 32px); margin-inline: auto; }

/* ---------- header ---------- */

.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top > .wrap:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; line-height: 1; }
h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

.theme {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 17px;
  cursor: pointer;
  flex: none;
}
.theme:hover { border-color: var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 0;
  background: none;
  color: var(--ink-soft);
  padding: 9px 12px;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--ink); background: var(--panel-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- layout ---------- */

main { padding: 22px 0 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.lead { color: var(--ink-soft); margin: 0 0 16px; font-size: 15px; }
.hint { color: var(--ink-soft); font-size: 13.5px; }

.tools { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.search {
  flex: 1 1 220px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.big { padding: 13px 26px; font-size: 16px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn.ok, :root[data-theme="dark"] .btn.bad { color: #0f1219; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.ok,
  :root:not([data-theme="light"]) .btn.bad { color: #0f1219; }
}

/* ---------- accordion ---------- */

.acc-group { margin-bottom: 22px; }
.acc-group > h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  margin: 0 0 8px 2px;
}

.acc-list details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.acc-list details[open] { border-color: var(--accent); box-shadow: var(--shadow); }

.acc-list summary {
  padding: 13px 16px 13px 42px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15.5px;
  position: relative;
  list-style: none;
}
.acc-list summary::-webkit-details-marker { display: none; }
.acc-list summary::before {
  content: "＋";
  position: absolute;
  left: 15px;
  color: var(--accent);
  font-weight: 700;
}
.acc-list details[open] summary::before { content: "－"; }
.acc-list summary:hover { background: var(--panel-2); }

.acc-body { padding: 0 16px 15px 42px; }
.acc-body .text { margin: 0; font-size: 15.5px; }
.acc-body .extra {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--ink);
}
.acc-body .extra::before { content: "Полезно знать: "; font-weight: 600; color: var(--accent); }

mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- figures ---------- */

.fig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.fig {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.fig svg { width: 100%; height: auto; display: block; }
.fig figcaption { font-size: 14px; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }
.fig figcaption b { color: var(--ink); }

svg .shape { fill: var(--figure-fill); stroke: var(--figure); stroke-width: 2.2; stroke-linejoin: round; }
svg .shape-l { stroke: var(--figure); stroke-width: 2.2; }
svg .circ { fill: none; stroke: var(--accent); stroke-width: 2; }
svg .aux { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 4; fill: none; }
svg .aux-s { stroke: var(--figure); stroke-width: 2; }
svg .rad { stroke: var(--accent); stroke-width: 2.4; }
svg .arc { fill: none; stroke: var(--accent); stroke-width: 2; }
svg .arc-hl { fill: none; stroke: var(--bad); stroke-width: 2.6; }
svg .right { fill: none; stroke: var(--figure); stroke-width: 1.8; }
svg .tick { stroke: var(--bad); stroke-width: 2.4; stroke-linecap: round; }
svg .pt { fill: var(--figure); }
svg .pt-hl { fill: var(--accent); }
svg .lbl { fill: var(--ink); font-size: 15px; font-weight: 700; font-family: Georgia, "Times New Roman", serif; }
svg .deg { fill: var(--accent); font-size: 13px; font-weight: 700; }
svg .note { fill: var(--ink-soft); font-size: 11.5px; }

/* ---------- tasks ---------- */

.task-list { display: grid; gap: 12px; }
.task {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.task .num {
  display: inline-block;
  min-width: 26px; height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  margin-right: 8px;
}
.task .q { font-size: 15.5px; }
.task-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.reveal {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 15px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
}
.reveal.answer { background: var(--ok-soft); border-left-color: var(--ok); }
.reveal b { color: var(--ink); }

/* ---------- flashcards ---------- */

.card-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.chip b { color: var(--ink); }
.chip.ok { border-color: var(--ok); color: var(--ok); }
.chip.ok b { color: var(--ok); }
.chip.bad { border-color: var(--bad); color: var(--bad); }
.chip.bad b { color: var(--bad); }

.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.flash {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px 22px;
  min-height: 230px;
  display: flex;
  flex-direction: column;
}
.flash-front { font-size: 21px; font-weight: 700; line-height: 1.35; }
.flash-back {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 16.5px;
  flex: 1;
}
.flash-actions { display: flex; gap: 10px; margin-top: 12px; }
.flash-actions .btn { flex: 1; }
#flash-show { margin-top: auto; }

.done {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.done h3 { margin: 0 0 8px; font-size: 20px; }
.done p { color: var(--ink-soft); margin: 0 0 16px; }

/* ---------- quiz ---------- */

.quiz-start { text-align: center; padding: 26px 0; }
.quiz-start h2 { margin: 0 0 8px; }
.quiz-start .lead { max-width: 520px; margin-inline: auto; }

.quiz-head { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

.q-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.q-text { font-size: 18px; font-weight: 600; margin: 0 0 16px; line-height: 1.4; }

.q-opts { display: grid; gap: 8px; }
.opt {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 15.5px;
  font-family: inherit;
  cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.q-input { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q-input input {
  flex: 1 1 140px;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
}
.q-input input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.q-input .unit { color: var(--ink-soft); font-size: 14.5px; }

.why {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  font-size: 15px;
}
.why.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.why.bad { background: var(--bad-soft); border-left-color: var(--bad); }
.why .verdict { display: block; font-weight: 700; margin-bottom: 4px; }

#res-wrong { text-align: left; margin-bottom: 18px; }
#res-wrong .rw {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 8px;
  font-size: 14.5px;
}
#res-wrong .rw b { display: block; margin-bottom: 3px; }
#res-wrong h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- live constructions ---------- */

.sketch {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.sketch h3 { margin: 0; font-size: 16.5px; }
.sketch .viz-sub { margin: 4px 0 12px; }

/* touch-action:none — otherwise a drag on a phone scrolls the page instead. */
/* Capped so a 4:3 viewBox doesn't turn into a 570px-tall block of mostly air on
   a desktop; on a phone it just fills the card. */
.sk-svg { width: 100%; max-width: 470px; height: auto; display: block; margin-inline: auto; touch-action: none; user-select: none; }

.sk-svg .handle { cursor: grab; }
.sk-svg .handle.dragging { cursor: grabbing; }
.sk-svg .h-hit { fill: transparent; }
.sk-svg .h-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.sk-svg .handle:hover .h-dot, .sk-svg .handle.dragging .h-dot { r: 7.5; }
.sk-svg .handle:focus { outline: none; }
.sk-svg .handle:focus-visible .h-dot { stroke: var(--ink); stroke-width: 2.5; }
.sk-svg .h-lbl { fill: var(--ink); font-size: 14px; font-weight: 700; font-family: Georgia, "Times New Roman", serif; }
.sk-svg .circ-thin { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: .55; }
.sk-svg .deg-hl { fill: var(--bad); font-size: 13px; font-weight: 700; }

.sk-slider {
  display: grid;
  grid-template-columns: minmax(110px, 34%) 1fr 42px;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 8px;
}
.sk-slider input { width: 100%; accent-color: var(--accent); }
.sk-slider b { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* step-by-step constructions */
.build .base { opacity: 1; }
/* Earlier steps fade back so the current move is the thing you look at. */
.build .done { opacity: .45; }
.build .new .circ-thin { stroke-width: 2.2; opacity: 1; }
.build .new .pt, .build .new .pt-hl { r: 4.5; }
.step-text {
  margin: 10px 0 0;
  padding: 11px 13px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 15px;
  min-height: 3.2em;
}
.step-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.step-bar .step-n { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.step-bar .btn:disabled { opacity: .45; cursor: default; filter: none; }
.why-box {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.why-box summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent); }
.why-box p { margin: 8px 0 0; font-size: 14.5px; color: var(--ink); }

.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.fact {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.fact b { color: var(--ink); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ---------- progress: stat tiles and charts ----------
   The series hue is one step darker than the UI accent in dark mode: the
   accent itself (#8b87ff) sits at OKLCH L 0.682, just outside the dark
   lightness band (0.48-0.67) a data mark has to stay inside. Both values were
   checked by computation, not by eye. */

:root { --viz-series: #4f46e5; --viz-track: #ded9fb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --viz-series: #7c76f5; --viz-track: #2e2a63; }
}
:root[data-theme="dark"] { --viz-series: #7c76f5; --viz-track: #2e2a63; }

.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile .t-label { font-size: 13px; color: var(--ink-soft); }
.tile .t-value { font-size: 30px; font-weight: 650; line-height: 1.15; margin-top: 2px; }
.tile .t-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
/* Meter: fill carries the value, track is a lighter step of the same ramp. */
.meter { height: 6px; border-radius: 999px; background: var(--viz-track); margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--viz-series); border-radius: 999px; }

.viz-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.viz-card h3 { margin: 0; font-size: 16px; }
.viz-sub { margin: 3px 0 16px; font-size: 13.5px; color: var(--ink-soft); }
.viz-foot { margin-top: 12px; }
.chart { overflow-x: auto; }

/* horizontal bars: label | plot | value at the tip */
.bars { display: grid; gap: 6px; }
/* Each row keeps the same track template, so the columns line up without
   subgrid — and the row stays a real box, which display:contents would not
   (it has to be focusable and measurable for the tooltip). */
.bars .b-row {
  display: grid;
  grid-template-columns: minmax(96px, 30%) 1fr 46px;
  gap: 12px;
  align-items: center;
}
.bars .b-name { font-size: 13.5px; line-height: 1.3; }
.bars .b-track { position: relative; height: 24px; display: flex; align-items: center; }
.bars .b-fill {
  height: 14px;
  background: var(--viz-series);
  /* square at the baseline, 4px rounded data-end */
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bars .b-val { font-size: 13.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: right; }
.bars .b-hit { cursor: default; }
.bars .b-hit:hover .b-fill, .bars .b-hit:focus-visible .b-fill { filter: brightness(1.12); }
.bars .b-hit:focus-visible { outline: 2px solid var(--viz-series); outline-offset: 2px; border-radius: 4px; }

svg.line-chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.line-chart .grid { stroke: var(--line); stroke-width: 1; }
svg.line-chart .axis-t { fill: var(--ink-soft); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.line-chart .series { fill: none; stroke: var(--viz-series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.line-chart .dot { fill: var(--viz-series); stroke: var(--panel); stroke-width: 2; }
svg.line-chart .crosshair { stroke: var(--ink-soft); stroke-width: 1; opacity: .45; }
svg.line-chart .end-lbl { fill: var(--ink); font-size: 12px; font-weight: 650; }

.tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 7px 10px;
  font-size: 13px;
  max-width: 220px;
}
.tip b { display: block; margin-bottom: 2px; }

.viz-table { margin-top: 12px; overflow-x: auto; }
.viz-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.viz-table th, .viz-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.viz-table th { color: var(--ink-soft); font-weight: 600; }
.viz-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.viz-empty { color: var(--ink-soft); font-size: 14.5px; padding: 8px 0 4px; }

.foot { color: var(--ink-soft); font-size: 13px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 520px) {
  h1 { font-size: 18px; }
  .sub { display: none; }
  .acc-list summary { padding-left: 38px; font-size: 15px; }
  .acc-body { padding-left: 38px; }
  .flash-front { font-size: 19px; }
  .q-text { font-size: 16.5px; }
}
