/* Paper page (005 R2–R5, R10; 006 R10–R13; plans PD11, GD11). Light only (006 D6), phone first, roomy, no web
   fonts besides KaTeX's. */
:root {
  --ink: #17202b;
  --muted: #55606e;
  --line: #dde3ea;
  --paper: #ffffff;
  --bg: #f5f7fb;
  --accent: #2459d6;
  --accent-ink: #ffffff;
  --accent-soft: #eaf0fd;
  --lesson: #fff8e6;
  --lesson-line: #f0c96a;
  --ok: #1b7a3e;
  --ok-soft: #e7f6ec;
  --bad: #b3261e;
  --info: #7a5a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 32, 43, 0.06), 0 2px 8px rgba(23, 32, 43, 0.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.katex { font-size: 1.2em; }

/* Header with the running score (006 R12). */
.top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { font-weight: 800; font-size: 19px; text-decoration: none; color: var(--accent); letter-spacing: 0.2px; }
.score { font-size: 15px; color: var(--muted); }
.score b { color: var(--ink); }

main { max-width: 720px; margin: 0 auto; padding: 20px 16px 32px; }
h1 { font-size: 22px; line-height: 1.3; margin: 4px 0 4px; }
.sub { margin: 0 0 16px; color: var(--muted); }
.intro, .oficiu { font-size: 15px; color: var(--muted); }
.notice {
  border: 1px solid var(--lesson-line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--lesson);
}

/* Download and send (006 R13). */
.paper-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; align-items: center; }
.paper-actions a, .paper-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--accent);
  background: var(--paper);
  color: var(--accent);
  cursor: pointer;
}
.paper-actions button.share { background: var(--accent); color: var(--accent-ink); }
.share-status { flex-basis: 100%; font-size: 14px; color: var(--muted); }
.share-status:empty { display: none; }

.subiect h2 { font-size: 19px; margin: 32px 0 12px; }
.spts { font-weight: 400; color: var(--muted); }
.context { margin: 20px 0 10px; overflow-x: auto; }

/* One roomy card per gradable unit (006 R12). */
.unit {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: 16px 0;
}
.statement { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.num { font-weight: 800; color: var(--accent); }
.upts { font-weight: 700; margin-right: 6px; color: var(--muted); font-size: 15px; }

/* Answer: the math field, or the text box when it can't load (006 R11). */
form.answer { margin-top: 16px; }
form.answer label { display: block; font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.symbols { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
button {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
button.sym { min-width: 44px; padding: 6px 8px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row input, math-field {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 19px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
math-field:focus-within, .row input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.preview { min-height: 1.5em; margin-top: 8px; overflow-x: auto; }
.preview .label { color: var(--muted); font-size: 15px; }
.feedback { margin-top: 6px; font-weight: 700; }
.feedback[data-tone="ok"] { color: var(--ok); }
.feedback[data-tone="bad"] { color: var(--bad); }
.feedback[data-tone="info"] { color: var(--info); font-weight: 500; }
.self { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.self legend { font-size: 15px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.self label { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; }

/* "Pași de rezolvare": the lesson, then one step per tap (006 R10). */
.ladder { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
button.solve-next {
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 17px;
  box-shadow: var(--shadow);
}
button.solve-next:active { transform: translateY(1px); }
.hint {
  background: var(--lesson);
  border: 1px solid var(--lesson-line);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}
.lesson-title { margin: 0 0 6px; font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--info); }
.lesson-text { margin: 0; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}
.steps li[hidden] { display: none; }
.step-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; }
.step-no { font-weight: 800; font-size: 15px; color: var(--accent); }
.pts { font-weight: 700; font-size: 15px; color: var(--muted); }
.step-math { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.why { margin: 10px 0 0; color: var(--ink); }
.verification {
  background: var(--ok-soft);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}
.solve-done { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }
.reveal { animation: reveal 250ms ease-out; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
}

/* Theory chips open their cards inline (006 R4, R7). */
details.theory { display: inline-block; max-width: 100%; margin: 8px 8px 0 0; vertical-align: top; }
details.theory[open] { display: block; margin-right: 0; }
details.theory > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 22px;
  background: var(--paper);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
details.theory > summary::-webkit-details-marker { display: none; }
details.theory[open] > summary { background: var(--accent); color: var(--accent-ink); }
.theory-body, .theory-example {
  background: var(--paper);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  margin-top: 8px;
  overflow-x: auto;
}
.theory-example { border-left-color: var(--line); }
.theory-example::before { content: "Exemplu: "; font-weight: 700; color: var(--muted); }
/* Older engines lay out the content of a closed details; hide it explicitly. */
details.theory:not([open]) > .theory-body,
details.theory:not([open]) > .theory-example { display: none; }
.theory-list { margin-top: 10px; }
.theory-intro { margin: 0; font-size: 15px; font-weight: 700; color: var(--muted); }

.unit-score { margin: 14px 0 0; font-size: 15px; color: var(--muted); }
.report { margin-top: 8px; font-size: 15px; }
.report summary { color: var(--muted); cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.report-form textarea {
  display: block;
  width: 100%;
  font: inherit;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.report-status { margin-left: 8px; }
.list { padding-left: 18px; }
.list li { margin: 8px 0; }
footer { max-width: 720px; margin: 0 auto; padding: 16px; font-size: 14px; color: var(--muted); }

/* 006 R17, second design pass: maths in its own ink and larger, the solution on squared maths paper, more space. */
:root { --math-ink: #1b3a8c; --grid: #e2e8f2; --paper-bg: #fdfdfb; }
.katex { font-size: 1.35em; color: var(--math-ink); }
.unit { padding: 22px 20px; margin: 28px 0; }
.ladder { gap: 20px; margin-top: 24px; }
.why { font-size: 15px; color: var(--muted); margin: 6px 0 0; }
.paper {
  background-color: var(--paper-bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  border: 1px solid #d5ddea;
  border-radius: 12px;
  padding: 8px 16px;
  overflow-x: auto;
}
.paper:not(:has(li.step:not([hidden]))) { display: none; }
.paper .steps { gap: 0; }
.paper .steps > li.step {
  background: transparent;
  border-radius: 0;
  padding: 16px 0;
  border-bottom: 1px dashed #c9d3e3;
}
.paper .steps > li.step:last-child { border-bottom: 0; }
ol.lines { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 22px; }
ol.lines > li.line { background: transparent; padding: 0; }
.line-math, .step-math { overflow-x: auto; overflow-y: hidden; padding: 8px 0; }
.line-math .katex-html, .step-math .katex-html { white-space: nowrap; }  /* 006 R26: a formula never wraps, it scrolls */
.chain { margin: 10px 0; }  /* 006 R24, R25: a chain of equalities is its own block */
.line-math .katex, .step-math .katex, .statement .katex, .context .katex { font-size: 1.5em; }  /* 006 R23 */
.line-why { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
.unit-score { font-size: 14px; margin-top: 20px; }
.report { font-size: 14px; }
.theory-body .katex, .theory-example .katex { font-size: 1.25em; }

[hidden] { display: none !important; }

/* 006 R27, R28: the lesson is collapsed under "Lecția"; its maths is as large as the statement's (R23). */
details.lesson > summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  font-weight: 800;
  font-size: 16px;
  color: var(--info);
  cursor: pointer;
  list-style: none;
}
details.lesson > summary::-webkit-details-marker { display: none; }
details.lesson > summary::after { content: "▾"; margin-left: auto; padding-left: 12px; }
details.lesson[open] > summary::after { content: "▴"; }
details.lesson:not([open]) > :not(summary) { display: none; }
.theory-body .katex, .theory-example .katex, .theory summary .katex { font-size: 1.5em; }
.theory-body, .theory-example { font-size: inherit; }

/* 006 R31: the action bar sits at the bottom of a phone screen. */
@media (max-width: 767.98px) {
  nav.paper-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--paper);
    border-top: 1px solid var(--line);
  }
  nav.paper-actions a, nav.paper-actions button {
    justify-content: center;
    min-height: 48px;
    padding: 8px 6px;
    border-radius: 0;
    border-width: 0 1px 0 0;
    text-align: center;
  }
  nav.paper-actions .share-status, nav.paper-actions .share-copy { grid-column: 1 / -1; font-size: 14px; padding: 6px 12px; }
  nav.paper-actions .share-copy input { width: 100%; min-height: 44px; font: inherit; }
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* 006 R34: a maths block that slides sideways shows a soft fade with `>` / `<` where more lies. */
.scroll-hint { position: relative; }
.scroll-hint::before,
.scroll-hint::after {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  align-items: center;
  pointer-events: none;
  font-weight: 800;
  font-size: 20px;
  color: var(--accent);
}
.scroll-hint::before {
  content: "<";
  content: "<" / "";
  justify-content: flex-start;
  left: 0;
  background: linear-gradient(to right, var(--sh-bg, #fff) 35%, transparent);
}
.scroll-hint::after {
  content: ">";
  content: ">" / "";
  justify-content: flex-end;
  right: 0;
  background: linear-gradient(to left, var(--sh-bg, #fff) 35%, transparent);
}
details.theory:not([open]) > .scroll-hint { display: none; }
.scroll-hint[data-hint="left"]::before,
.scroll-hint[data-hint="both"]::before,
.scroll-hint[data-hint="right"]::after,
.scroll-hint[data-hint="both"]::after { display: flex; }

/* 006 R34: maths blocks and the boxes holding them never scroll vertically (subpixel overflow showed arrows). */
.statement, .context, .line-math, .step-math, .theory-body, .theory-example,
.hint, .steps li, .verification, .preview, .paper { overflow-y: hidden; }
