/* Look: a Romanian squared math notebook. Blue pen ink, the red margin line,
   the teacher's red pen circling the answer, and a yellow highlighter. */

:root {
  --paper: #fbfcfe;
  --grid: #e3eaf4;
  --sheet: #ffffff;
  --text: #24272d;
  --muted: #586070;
  --ink: #1d3c8f;
  --ink-hover: #132a69;
  --red: #cf3a2f;
  --marker: #fff0a0;
  --rule: #d4dce8;
  --fill: #c9d6f3;
  --cell: 24px;
  --margin-x: 3rem;
  --font: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  color-scheme: light;
}

/* Dark mode: the chalkboard. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d2925;
    --grid: rgba(255, 255, 255, 0.045);
    --sheet: #22302b;
    --text: #e8ece7;
    --muted: #b1bab3;
    --ink: #a9c5ff;
    --ink-hover: #d2e0ff;
    --red: #ff8b80;
    --marker: rgba(255, 226, 110, 0.16);
    --rule: rgba(255, 255, 255, 0.14);
    --fill: rgba(169, 197, 255, 0.3);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

main {
  flex: 1;
}

img,
svg,
iframe {
  max-width: 100%;
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ink-hover);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: 100%;
  max-width: 70rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--sheet);
}

.skip:focus {
  top: 0.5rem;
}

/* Header */

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 1rem;
}

.brand {
  display: flex;
  flex-direction: column;
  margin-right: auto;
  line-height: 1.25;
  text-decoration: none;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.brand-school {
  font-size: 0.9rem;
  color: var(--muted);
}

.main-nav {
  display: flex;
  gap: 1.25rem;
}

.main-nav a {
  font-weight: 700;
  text-decoration: none;
}

.main-nav a:hover {
  text-decoration: underline;
}

.lang {
  display: inline-flex;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--sheet);
}

.lang button {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.8rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.lang button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--sheet);
}

/* The page body carries the notebook's red margin line. */

.page {
  position: relative;
  padding-block: 1.5rem 3.5rem;
  padding-left: var(--margin-x);
}

.page::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--margin-x) - 1.25rem);
  width: 2px;
  background: var(--red);
  opacity: 0.7;
}

@media (max-width: 40rem) {
  :root {
    --margin-x: 1.75rem;
  }
}

.message {
  max-width: 40rem;
  font-size: 1.1rem;
}

/* Home */

.hero {
  max-width: 42rem;
  padding-block: 1rem 0.5rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 1.2rem + 3.2vw, 3.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.lead {
  margin: 0;
  font-size: 1.2rem;
  color: var(--muted);
}

.level {
  margin-top: 2.75rem;
  scroll-margin-top: 1rem;
}

.level h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 0 0 1rem;
  font-size: 1.5rem;
  line-height: 1.2;
}

.range {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

.grades {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  max-width: 46rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 40rem) {
  .grades {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  height: 100%;
  padding: 0.6rem 1rem 0.9rem;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--sheet);
  color: var(--text);
  text-decoration: none;
}

.tile:hover {
  border-color: var(--ink);
  color: var(--text);
}

/* Handwritten grade numeral; the red pen circles it on hover and on the current grade. */
.num {
  position: relative;
  display: inline-block;
  padding-inline: 0.18em;
  margin-left: -0.18em;
  font-family: var(--hand);
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.num::after {
  content: "";
  position: absolute;
  inset: 0.04em -0.1em -0.02em -0.08em;
  border: 2.5px solid var(--red);
  border-radius: 52% 46% 55% 45% / 55% 60% 42% 48%;
  opacity: 0;
  transform: rotate(-8deg) scale(0.85);
  transition: opacity 0.18s ease, transform 0.25s ease;
}

.tile:hover .num::after,
.tile:focus-visible .num::after,
.num.is-current::after {
  opacity: 1;
  transform: rotate(-8deg) scale(1);
}

.tile-name {
  margin-top: 0.4rem;
  font-weight: 700;
}

.tile-count {
  min-height: 1.5em;
  font-size: 0.9rem;
  color: var(--muted);
}

.about {
  max-width: 42rem;
  margin-top: 3rem;
}

.about h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.about p {
  margin: 0;
}

/* Class page */

.grade-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.grade-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 2px solid transparent;
  border-radius: 50%;
  font-family: var(--hand);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.grade-switch a.gap {
  margin-left: 0.75rem;
}

.grade-switch a:hover {
  border-color: var(--rule);
}

.grade-switch a[aria-current="page"] {
  border-color: var(--red);
}

.class-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.class-head .num {
  font-size: 5.5rem;
}

.class-head h1 {
  margin: 0;
  font-size: clamp(1.8rem, 1.3rem + 2vw, 2.5rem);
  line-height: 1.15;
}

.class-head p {
  margin: 0;
  color: var(--muted);
}

.chapter {
  max-width: 46rem;
  margin-top: 2rem;
}

.chapter h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

.lesson-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--sheet);
}

.lesson-list li + li {
  border-top: 1px solid var(--rule);
}

.lesson-list a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.85rem 1rem;
  text-decoration: none;
}

.lesson-list a:hover .lesson-title {
  text-decoration: underline;
}

.lesson-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.kind {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.kind-video::before,
.kind-textvideo::before {
  content: "";
  display: inline-block;
  margin-right: 0.4em;
  border-top: 0.35em solid transparent;
  border-bottom: 0.35em solid transparent;
  border-left: 0.55em solid var(--red);
}

/* Lesson page */

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.crumbs li + li::before {
  content: "/";
  margin-right: 0.25rem;
  color: var(--muted);
}

.lesson-head h1 {
  max-width: 42rem;
  margin: 0 0 0.35rem;
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.12;
  text-wrap: balance;
}

.lesson-meta {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.video {
  position: relative;
  width: 100%;
  max-width: 48rem;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-link {
  margin: 0.5rem 0 1.75rem;
  font-size: 0.95rem;
}

.note {
  max-width: 42rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  background: var(--marker);
}

.js article[data-lang]:not(.is-active) {
  display: none;
}

.lesson-body {
  max-width: 42rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--sheet);
  font-size: 1.125rem;
  line-height: 1.65;
}

@media (max-width: 40rem) {
  .lesson-body {
    padding: 1rem;
  }
}

.lesson-body h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--ink);
}

.lesson-body > :first-child {
  margin-top: 0;
}

.lesson-body p,
.lesson-body ul,
.lesson-body ol {
  margin: 0 0 1rem;
}

.lesson-body li {
  margin-bottom: 0.35rem;
}

.lesson-body .katex-display {
  margin: 0.75rem 0;
  padding-block: 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.retine {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  background: var(--marker);
}

.retine-title {
  margin: 0 0 0.15rem;
  font-family: var(--hand);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  color: var(--red);
}

.lesson-body .retine > :last-child {
  margin-bottom: 0;
}

.exercises > li {
  margin-bottom: 1.1rem;
}

.solution {
  margin-top: 0.35rem;
}

.solution summary {
  width: fit-content;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.solution > :not(summary) {
  margin: 0.4rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--red);
}

.fig {
  margin: 1rem 0 1.5rem;
  text-align: center;
}

.fig svg {
  width: 100%;
  max-width: 17rem;
  height: auto;
}

.fig-small svg {
  max-width: 11rem;
}

.fig figcaption {
  font-size: 0.95rem;
  color: var(--muted);
}

.fig .shape {
  fill: var(--fill);
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.fig .empty {
  fill: var(--sheet);
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.fig .line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
}

.fig .axis {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
}

.fig .gridline {
  stroke: var(--rule);
  stroke-width: 1;
}

.fig .mark {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
}

.fig .dot {
  fill: var(--red);
}

.fig text {
  fill: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.fig text.hand {
  fill: var(--red);
  font-family: var(--hand);
  font-size: 24px;
  font-weight: 600;
}

/* Footer */

.site-footer .wrap {
  padding-block: 1.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
