/* 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;
  --marker-soft: #fffaea;
  --marker-edge: #ffd94a;
  --remember-soft: #e8f6ef;
  --remember-edge: #2a9d6e;
  --remember-text: #17704f;
  --rule: #d4dce8;
  --fill: #c9d6f3;
  --brand-marker: #fff0a0;
  --b-lectii-bg: #e3ebfb;
  --b-lectii-fg: #1d3c8f;
  --b-fise-bg: #e1f2e8;
  --b-fise-fg: #1b6b43;
  --b-teste-bg: #fbe5e2;
  --b-teste-fg: #a52a20;
  --b-jocuri-bg: #fbeed9;
  --b-jocuri-fg: #8a4b0c;
  --header-h: 4.5rem;
  --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. Two doors into it: the reader's own choice, and
   the system setting when the reader has not chosen light here. The colours are
   spelled out twice because CSS cannot share one block across a media query.
   The validator fails if the two copies drift apart. */

:root[data-theme="dark"] {
  --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);
  --marker-soft: rgba(255, 226, 110, 0.1);
  --marker-edge: rgba(255, 217, 74, 0.75);
  --remember-soft: rgba(120, 210, 160, 0.12);
  --remember-edge: rgba(120, 210, 160, 0.75);
  --remember-text: #a8e6c1;
  --rule: rgba(255, 255, 255, 0.14);
  --fill: rgba(169, 197, 255, 0.3);
  --brand-marker: rgba(255, 217, 74, 0.5);
  --b-lectii-bg: rgba(169, 197, 255, 0.18);
  --b-lectii-fg: #c9d9ff;
  --b-fise-bg: rgba(120, 210, 160, 0.16);
  --b-fise-fg: #a8e6c1;
  --b-teste-bg: rgba(255, 139, 128, 0.16);
  --b-teste-fg: #ffb3ab;
  --b-jocuri-bg: rgba(255, 190, 110, 0.16);
  --b-jocuri-fg: #ffd09a;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --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);
    --marker-soft: rgba(255, 226, 110, 0.1);
    --marker-edge: rgba(255, 217, 74, 0.75);
    --remember-soft: rgba(120, 210, 160, 0.12);
    --remember-edge: rgba(120, 210, 160, 0.75);
    --remember-text: #a8e6c1;
    --rule: rgba(255, 255, 255, 0.14);
    --fill: rgba(169, 197, 255, 0.3);
    --brand-marker: rgba(255, 217, 74, 0.5);
    --b-lectii-bg: rgba(169, 197, 255, 0.18);
    --b-lectii-fg: #c9d9ff;
    --b-fise-bg: rgba(120, 210, 160, 0.16);
    --b-fise-fg: #a8e6c1;
    --b-teste-bg: rgba(255, 139, 128, 0.16);
    --b-teste-fg: #ffb3ab;
    --b-jocuri-bg: rgba(255, 190, 110, 0.16);
    --b-jocuri-fg: #ffd09a;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* Keep the centered page (and its red margin line) in the same place whether
     or not the page is long enough to scroll: without this, the vertical
     scrollbar appearing on long pages shifts .wrap sideways on desktop. */
  scrollbar-gutter: stable;
}

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: 50;
  padding: 0.5rem 0.75rem;
  background: var(--sheet);
}

.skip:focus {
  top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Header: stays at the top while the page scrolls */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
}

.header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding-block: 0.55rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-right: auto;
  line-height: 1.2;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

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

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

.grade-nav {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.grade-nav-label {
  display: none;
}

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

.grade-nav a.gap {
  margin-left: 0.6rem;
}

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

.grade-nav a[aria-current] {
  border-color: var(--red);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 15rem;
  min-height: 2.5rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
}

.search:focus-within {
  border-color: var(--ink);
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.35rem 0.9rem 0.35rem 2.3rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.search input:focus {
  outline: none;
}

.search input::placeholder {
  color: var(--muted);
  opacity: 1;
}


.search-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.search > .search-icon {
  position: absolute;
  top: 50%;
  left: 0.8rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.75rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn[aria-expanded="true"] {
  border-color: var(--ink);
  background: var(--paper);
}

/* Theme switch. It only works with JavaScript, so it stays hidden without it
   rather than sitting there doing nothing. */

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
}

html:not(.js) .theme-btn {
  display: none;
}

.theme-btn:hover {
  border-color: var(--ink);
}

.theme-icon {
  width: 1.2rem;
  height: 1.2rem;
}

/* The moon offers the chalkboard; the sun offers the paper back. */
.theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-icon-moon {
    display: none;
  }
}

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

.lang button,
.lang a {
  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;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

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

@media (max-width: 60rem) {
  .brand-school {
    display: none;
  }

  .brand-mark {
    width: 1.9rem;
    height: 1.9rem;
  }

  .icon-btn {
    display: inline-flex;
  }

  .grade-nav,
  .search {
    display: none;
    order: 10;
    width: 100%;
  }

  .site-header[data-open="grades"] .grade-nav {
    display: flex;
    flex-wrap: wrap;
    padding-block: 0.25rem 0.5rem;
  }

  .site-header[data-open="search"] .search {
    display: flex;
    margin-bottom: 0.5rem;
  }

  .grade-nav-label {
    display: inline;
    margin-right: 0.5rem;
    font-weight: 700;
  }
}

@media (max-width: 24rem) {
  .brand-name {
    font-size: 1rem;
  }

  .lang button,
  .lang a {
    min-width: 2.4rem;
    padding-inline: 0.55rem;
  }
}

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

.page {
  position: relative;
  padding-block: 0.5rem 0;
  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: 0.5rem 0.25rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 1rem + 2.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

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

.whats-new {
  max-width: 50rem;
  margin-top: 1.75rem;
}

.whats-new h2 {
  margin: 0 0 0.75rem;
  font-size: 1.3rem;
  line-height: 1.2;
}

#whats-new {
  max-height: 21.6rem;
  overflow-y: auto;
}

.level {
  margin-top: 1.25rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.level h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.6rem;
  font-size: 1.3rem;
  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));
  grid-auto-rows: 1fr;
  gap: 0.5rem;
  max-width: 50rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.grades > li {
  margin: 0;
  padding: 0;
  min-height: 0;
}

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

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 0.2rem 0.65rem 0.35rem;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--sheet);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
}

.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: 2rem;
  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 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 0;
  margin-left: 0;
  width: 2.35rem;
  height: 2.35rem;
  border: 2px solid transparent;
  border-radius: 50%;
  transition: border-color 0.18s ease;
}

.tile .num::after {
  display: none;
}

.num.is-current::after {
  opacity: 1;
  transform: rotate(-8deg) scale(1);
}

.tile:hover .num,
.tile:focus-visible .num {
  border-color: var(--red);
}

.tile-name {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tile-count,
.tile-updated {
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 100%;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.about {
  max-width: 50rem;
  margin-top: 1.25rem;
}

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

.about p {
  margin: 0;
  font-size: 1.05rem;
}

/* Lists of materials (home, grade page, search, related) */

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

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

.m-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
}

@media (min-width: 40rem) {
  .m-link {
    grid-template-columns: 14rem minmax(0, 1fr) auto;
    align-items: baseline;
    row-gap: 0;
    column-gap: 0.75rem;
  }

  /* Rows that also name the grade and the topic carry too much meta text for a
     third column: it would take all the width and squeeze the title to a sliver.
     Those rows drop to two columns and put the meta under the title. */
  .m-link:has(.m-where) {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .m-link:has(.m-where) .m-meta {
    grid-column: 2;
  }

  /* The leading block is two lines tall, and so is the text beside it: let it
     stand in both rows instead of stretching the first one. The badges then sit
     next to the title and the date next to the topic line, which is the shortest
     the row can be without dropping anything. */
  .m-link:has(.m-where) .m-badges {
    grid-row: 1 / span 2;
    align-content: start;
    /* Tight enough that the date sits on the line of the topic text beside it. */
    row-gap: 0.15rem;
  }
}

.m-link:hover {
  color: var(--text);
}

.m-link:hover .m-title {
  text-decoration: underline;
}

.m-link:focus-visible {
  outline-offset: -3px;
}

.m-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: break-word;
}

.m-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.m-date {
  white-space: nowrap;
}

.new {
  padding: 0 0.45rem;
  border-radius: 3px;
  background: var(--marker);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge {
  display: inline-block;
  justify-self: start;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  background: var(--b-lectii-bg);
  color: var(--b-lectii-fg);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.material-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-self: start;
}

.m-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* The publish date leads the row, with the grade and the type. */
.m-badges .m-date {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Wide enough for a leading column: the date takes a whole line of the badge
   block, so every row breaks in the same place and the dates line up under one
   another. On a phone the row is one column already, and a second line there
   would only make every row taller. The badges above the date are pills whose
   text starts one padding in, so the date takes the same inset and the two read
   as one left edge. */
@media (min-width: 40rem) {
  .m-badges .m-date {
    flex-basis: 100%;
    padding-left: 0.5rem;
  }
}

.m-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--b-lectii-bg);
  color: var(--b-lectii-fg);
  font-family: var(--hand);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.m-grade-fise {
  background: var(--b-fise-bg);
  color: var(--b-fise-fg);
}

.m-grade-teste {
  background: var(--b-teste-bg);
  color: var(--b-teste-fg);
}

.m-grade-jocuri {
  background: var(--b-jocuri-bg);
  color: var(--b-jocuri-fg);
}

.badge-fise {
  background: var(--b-fise-bg);
  color: var(--b-fise-fg);
}

.badge-teste {
  background: var(--b-teste-bg);
  color: var(--b-teste-fg);
}

.badge-jocuri {
  background: var(--b-jocuri-bg);
  color: var(--b-jocuri-fg);
}

/* Filter buttons */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.chip {
  min-height: 2.5rem;
  padding: 0.3rem 0.95rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

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

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

/* Grade page */

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

.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);
}

/* "More / less" toggle for long grade intros: a small inline link-button. */
.lead-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.9em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  white-space: nowrap;
  cursor: pointer;
}

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

.year {
  max-width: 50rem;
  margin-top: 1.5rem;
}

.year > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  cursor: pointer;
  list-style: none;
}

.year > summary::-webkit-details-marker {
  display: none;
}

.year > summary::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2.5px solid var(--red);
  border-bottom: 2.5px solid var(--red);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.year[open] > summary::before {
  transform: rotate(45deg);
}

.year > summary h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.topic {
  margin-top: 1.25rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.topic-title {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.3;
}

.topic-updated {
  margin: 0.1rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Material page */

/* The check note and the "delete my answers" button are one row: two stacked
   blocks pushed the first exercise a whole button-height further down. The
   button is hidden until something is saved, so the note sits alone then. */
.check-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  max-width: 50rem;
  margin: 0 0 1rem;
}

.check-bar .note {
  flex: 1 1 18rem;
  margin: 0;
}

.check-bar .chip {
  flex: 0 0 auto;
}

.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);
}

#material-head h1 {
  max-width: 42rem;
  margin: 0.4rem 0 0.35rem;
  font-size: clamp(1.7rem, 1.25rem + 1.1vw, 2.15rem);
  font-weight: 800;
  line-height: 1.12;
  text-wrap: balance;
}

.material-meta {
  margin: 0 0 1rem;
  color: var(--muted);
}

.material-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--sheet);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--ink-hover);
  color: var(--sheet);
}

.video {
  position: relative;
  width: 100%;
  max-width: 50rem;
  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;
}

/* Clips: a card is a YouTube link until JS turns it into a player. */
.clip-card {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 1rem;
  align-items: center;
  max-width: 42rem;
  margin: 0.5rem 0 1rem;
  padding: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--text);
  text-decoration: none;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.clip-card:hover { border-color: var(--ink); }

.clip-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
}

.clip-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clip-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.8rem;
  height: 2.8rem;
  margin: -1.4rem 0 0 -1.4rem;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.clip-play::after {
  content: "";
  position: absolute;
  inset: 30% 26% 30% 38%;
  background: var(--sheet);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.clip-dur {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.clip-text { display: block; }
.clip-kicker { display: block; font-size: 0.85rem; color: var(--muted); }
.clip-name { display: block; margin: 0.15rem 0; font-weight: 700; color: var(--ink); }

.clip-seen {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--marker-edge);
  border-radius: 3px;
  background: var(--marker-soft);
  font-size: 0.8rem;
  color: var(--text);
}

.clip-seen[hidden], .clip-state[hidden], .clips-progress[hidden] { display: none; }

/* One clip: the large player above the article. */
.clip-hero {
  display: block;
  max-width: 50rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.clip-hero .clip-play { width: 4.5rem; height: 4.5rem; margin: -2.25rem 0 0 -2.25rem; }

.clip-open { max-width: 50rem; margin: 0.5rem 0 1rem; scroll-margin-top: calc(var(--header-h) + 1rem); }
.clip-open .video-link { margin: 0.5rem 0 0; }

/* Several clips: the overview above the article. */
.clips-overview { max-width: 50rem; margin: 0 0 1.75rem; }

.clips-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.5rem 0 0.4rem;
}

.clips-head h2 { margin: 0; font-size: 1.15rem; }
.clips-summary { margin: 0; color: var(--muted); font-size: 0.95rem; }
.clips-lang { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.95rem; }

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

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

ol.clips a {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

ol.clips a:hover .clip-title { text-decoration: underline; }

.clip-num {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--rule);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Fixed dark text on the yellow marker fill, readable in both themes. */
li.seen .clip-num { border-color: var(--marker-edge); background: var(--marker-edge); color: #24272d; }

.clip-state { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); }

ol.clips .clip-dur {
  position: static;
  padding: 0;
  background: none;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.95rem;
}

.clip-top .clip-card:first-child { margin-top: 0; }

@media (max-width: 40rem) {
  .clip-card { grid-template-columns: 1fr; }
}

.note {
  display: inline-block;
  max-width: 50rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-left: 5px solid var(--marker-edge);
  border-radius: 4px;
  background: var(--marker-soft);
}

.material-actions .note {
  margin: 0;
}

.material-body {
  max-width: 50rem;
  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;
}

/* Wide screens: the PDF button sits in a second column beside the title
   instead of costing a full row under the date. Explicit rows, because the
   English pages and the PDF-only materials also put a note span in
   .material-actions, and a joc or a quiz has no .material-actions at all. */
@media (min-width: 40rem) {
  #material-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1.5rem;
    align-items: start;
  }

  #material-head .crumbs {
    grid-area: 1 / 1 / 2 / 3;
  }

  #material-head .material-kinds {
    grid-area: 2 / 1 / 3 / 2;
  }

  #material-head h1 {
    grid-area: 3 / 1 / 4 / 2;
  }

  #material-head .material-meta {
    grid-area: 4 / 1 / 5 / 2;
    margin-bottom: 1.25rem;
  }

  #material-head .material-actions {
    grid-area: 2 / 2 / 5 / 3;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
    max-width: 16rem;
    margin: 0.35rem 0 1.25rem;
  }

  #material-head .material-actions .note {
    font-size: 0.9rem;
  }
}

@media (max-width: 40rem) {
  /* Phone: the head must not eat the first screen. The DOM order is crumbs,
     badge, h1, date, PDF; grid puts the badge and the date on one row under
     the title without the generator having to change. Explicit rows, because
     .material-actions can also carry a note span on the English pages. */
  #material-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.6rem;
    row-gap: 0.3rem;
    align-items: baseline;
  }

  #material-head .crumbs {
    grid-area: 1 / 1 / 2 / 3;
  }

  #material-head h1 {
    grid-area: 2 / 1 / 3 / 3;
    margin: 0.1rem 0 0.15rem;
    font-size: 1.5rem;
    line-height: 1.15;
  }

  #material-head .material-kinds {
    grid-area: 3 / 1 / 4 / 2;
  }

  #material-head .material-meta {
    grid-area: 3 / 2 / 4 / 3;
    margin: 0;
    font-size: 0.85rem;
  }

  #material-head .material-actions {
    grid-area: 4 / 1 / 5 / 3;
    margin: 0.55rem 0 1rem;
  }

  /* One line, swipe for the rest. Wrapped crumbs cost two lines of the first
     screen and the last crumb is the one that matters. */
  .crumbs ol {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
  }

  .crumbs ol::-webkit-scrollbar {
    display: none;
  }

  .crumbs li {
    white-space: nowrap;
  }

  .material-body {
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.55;
  }

  .note {
    padding: 0.5rem 0.7rem;
    font-size: 0.95rem;
  }
}

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

.material-body h3 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1.15rem;
  line-height: 1.3;
}

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

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

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

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

/* Wide tables scroll sideways inside the page instead of widening it. */
.material-body table {
  display: block;
  max-width: 100%;
  margin: 0 0 1rem;
  overflow-x: auto;
  border-collapse: collapse;
}

.material-body th,
.material-body td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--rule);
  vertical-align: top;
}

.material-body th {
  background: var(--paper);
}

/* A formula in a cell stays on one line: a narrow cell would otherwise break it
   after "=" or "+", or leave the ";" after it at the start of the next line.
   The table already scrolls sideways when it gets too wide. */
.material-body td .katex {
  white-space: nowrap;
}

/* Grid, not flex: options then line up in columns instead of reflowing into a
   ragged block. auto-fit picks as many columns as fit, so a phone gets two and
   a desktop four, and a long option drops to one column on its own. */
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.4rem 0.9rem;
  padding: 0;
  list-style: none;
}

/* Options too long for a quarter of the row (a set with many elements): two
   columns on a desktop, one on a phone, so a formula never wraps away from its
   letter or runs past its column. Put the class on the <ul> by hand. */
.choices.choices-wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.material-body .choices li {
  margin: 0;
  min-width: 0;
}

/* A choice button normally sits at the end of the question paragraph above
   (see placeButton in check.js). When there is no such paragraph, the button
   stays INSIDE this grid: it flows right after the options, on the same row
   when the row still has room, wrapped to its own row otherwise. Either way
   it never stretches, and the grid's row gap keeps the distance when it
   wraps, so it needs no margin of its own. */
.choices .check-btn {
  justify-self: start;
  align-self: center;
  margin: 0;
}

/* Highlighted boxes cover a lot of page, so they take the pale fill and put the
   strong yellow in the edge. Full-strength yellow over that much area shouts.
   The small "Nou" badge keeps the strong yellow: a dab should stay a dab. */
.retine {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--marker-edge);
  border-radius: 4px;
  background: var(--marker-soft);
}

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

/* "De reținut" (Remember): what a student keeps after the worksheet. Green,
   so it never reads as one more yellow example box next to it. */
.retine-de-retinut {
  border-left-color: var(--remember-edge);
  background: var(--remember-soft);
}

.retine-de-retinut .retine-title {
  color: var(--remember-text);
}

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

/* A hairline between exercises: a long one then has a visible start and end
   instead of running into its neighbour. The old bottom margin goes, or the
   gap would double (margin + padding) and cost more scrolling than the
   smaller font just saved. */
.exercises > li {
  margin-bottom: 0;
}

.exercises > li + li {
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}

/* Result checking: one exercise at a time. The green and the red reuse the
   worksheet and test badge tokens, so both themes already know them. Colour
   is never the only sign: verdicts and chips always carry ✓ or ✗. */

.check-btn {
  margin-left: 0.6rem;
  padding: 0.15rem 0.8rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.check-btn:hover {
  background: var(--ink);
  color: var(--sheet);
}

/* The result is the answer to the student's question, so it reads at the size
   of the exercise around it, not at kind-badge size. inherit keeps it in step
   with the article on a phone without a second rule. */
.check-chip {
  margin-left: 0.6rem;
  padding: 0.05rem 0.55rem;
  font-size: inherit;
  line-height: 1.4;
  white-space: nowrap;
}

.choices li.check-ok {
  background: var(--b-fise-bg);
  color: var(--b-fise-fg);
  border-radius: 3px;
  outline: 2px solid var(--b-fise-fg);
  outline-offset: 1px;
}

.choices li.check-bad {
  background: var(--b-teste-bg);
  color: var(--b-teste-fg);
  border-radius: 3px;
  outline: 2px solid var(--b-teste-fg);
  outline-offset: 1px;
}

.check-dialog {
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--sheet);
  color: var(--text);
}

.check-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.check-title {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
}

.check-body {
  display: grid;
  gap: 0.6rem;
}

.check-option {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.check-option:hover {
  background: var(--paper);
}

.check-option input {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--ink);
}

.check-field {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  font: inherit;
}

.check-field:focus {
  border-color: var(--ink);
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}

.check-example,
.check-hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.check-syms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.sym {
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.15rem 0.45rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

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

/* Permutation tables: the two-line notation of the answer, with the first
   row fixed and one small box per value of the second row. The rounded side
   borders read as the parentheses around the table. */
.perm-list {
  display: grid;
  gap: 0.75rem;
}

.perm-item {
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.perm-cap {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.perm-grid {
  display: inline-flex;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  border-left: 2px solid var(--text);
  border-right: 2px solid var(--text);
  border-radius: 14px;
}

.perm-col {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  gap: 0.25rem;
}

.perm-top {
  font-size: 0.95rem;
  color: var(--muted);
}

.perm-prefix {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.perm-cell {
  width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.2rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  font: inherit;
  text-align: center;
}

.perm-cell:focus {
  border-color: var(--ink);
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}

/* Options with parts: one small radio group per part, the part named above
   its options and the options side by side when they fit. */
.check-part {
  display: grid;
  gap: 0.2rem;
}

.check-part-title {
  margin: 0;
  font-weight: 700;
}

.check-part-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
}

/* A table to fill in: a copy of the page table, one box per empty cell. The
   dialog sits outside the article, so it gets its own table rules; a wide
   table scrolls inside the dialog instead of widening it. */
.grid-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.grid-wrap table {
  border-collapse: collapse;
}

.grid-wrap th,
.grid-wrap td {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--rule);
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.grid-wrap th {
  background: var(--paper);
}

/* The row names stay in view while a wide table scrolls on a phone. */
.grid-wrap tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--sheet);
  text-align: left;
}

.grid-wrap thead tr > :first-child {
  background: var(--paper);
}

.check-verdict {
  margin: 0.75rem 0 0;
  font-weight: 700;
}

.check-verdict[data-kind="ok"] {
  color: var(--b-fise-fg);
}

.check-verdict[data-kind="bad"] {
  color: var(--b-teste-fg);
}

.check-verdict[data-kind="error"] {
  color: var(--b-teste-fg);
  font-weight: 400;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.check-again {
  margin-left: 0.5rem;
}

.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);
}

.related {
  max-width: 50rem;
  margin-top: 2rem;
}

.related h2 {
  margin: 0 0 0.6rem;
  font-size: 1.25rem;
}

.related p {
  margin: 0.75rem 0 0;
}

.more {
  font-weight: 700;
}

/* Answer-first blocks above the article: the summary states the idea in
   words, the contents list jumps to each section. Same box language as the
   article, so both themes work without new colour tokens. */
.rezumat {
  max-width: 50rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-left: 5px solid var(--marker-edge);
  border-radius: 4px;
  background: var(--sheet);
}

.rezumat h2 {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
}

.rezumat p {
  margin: 0;
}

.cuprins {
  max-width: 50rem;
  margin: 0 0 1.5rem;
}

.cuprins h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.cuprins ol {
  margin: 0;
  padding-left: 1.4rem;
}

.cuprins ol ol {
  margin-top: 0.15rem;
}

.cuprins li {
  margin-bottom: 0.25rem;
}

/* Anchored headings must land below the sticky header. */
.material-body h2[id],
.material-body h3[id] {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

/* Conceptual Q&A after the article: native details elements, no JS needed. */
.faq {
  max-width: 50rem;
  margin: 1.75rem 0 0;
}

.faq h2 {
  margin: 0 0 0.6rem;
  font-size: 1.25rem;
}

.faq details {
  margin: 0 0 0.6rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--sheet);
}

.faq summary {
  font-weight: 700;
  cursor: pointer;
}

.faq details p {
  margin: 0.5rem 0 0;
}

/* Search: header dropdown and search page */

/* The dropdown is a box with two parts: the list scrolls, the "see all" line
   below it does not, so the number of matches stays readable at any length. */
.search-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(70vh, 32rem);
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

/* The grade filter: a quiet row above the list that never scrolls with it.
   Small, hollow pills, so the panel still reads as a list of materials. */
.search-grades {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.2rem 0.4rem;
  border-bottom: 1px solid var(--rule);
}

.search-grades-label {
  margin-right: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.search-grades .chip {
  min-height: 0;
  min-width: 1.5rem;
  padding: 0.05rem 0.35rem;
  border-width: 1px;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.search-grades .chip:hover {
  color: var(--ink);
}

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

.search-grades .chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.search-list {
  margin: 0;
  padding: 0.35rem 0 0;
  overflow-y: auto;
  list-style: none;
}

@media (max-width: 60rem) {
  .search-panel {
    left: 0;
    width: auto;
  }
}

.search-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0.1rem 0.7rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

/* A fixed leading column, like a list row, so every title starts at the same
   place however wide the type badge of that row happens to be. A phone has no
   room for two columns: there the badges sit above the title. */
@media (min-width: 40rem) {
  .search-option {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
}

.search-option + .search-option {
  border-top: 1px solid var(--rule);
}

.search-option:hover,
.search-all:hover {
  background: var(--paper);
}

.search-list [aria-selected="true"] {
  background: var(--paper);
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.search-title {
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: break-word;
}

.search-all {
  flex: none;
  margin-top: 0.35rem;
  padding: 0.55rem 0.6rem;
  border-top: 1px solid var(--rule);
  border-radius: 0 0 4px 4px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.search-none {
  padding: 0.6rem;
  color: var(--muted);
}

.search-browse {
  margin-top: 0;
}

#search-page {
  /* + margin-x: .page's left padding sits inside the border box,
     so the content stays 50rem like .year on grade pages. */
  max-width: calc(50rem + var(--margin-x));
}

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

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 50rem;
  margin: 0 0 1rem;
}

.search-form input,
.search-form select {
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--text);
  font: inherit;
}

.search-form input {
  flex: 1 1 16rem;
}

.search-form input:focus,
.search-form select:focus {
  border-color: var(--ink);
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}

/* The count and the order of the results share one line above the list. */
.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin: 0 0 0.75rem;
}

.search-count {
  margin: 0;
  color: var(--muted);
}

.sort-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sort-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.sort-select {
  min-height: 2.1rem;
  padding: 0.15rem 0.5rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.sort-select:focus {
  border-color: var(--ink);
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}

/* Footer */

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

.site-footer p {
  margin: 0;
}

@media print {
  body {
    background: none;
  }

  .site-header,
  .site-footer,
  .skip,
  .crumbs,
  .material-actions,
  .note,
  .check-btn,
  #check-reset,
  .related,
  .clips-overview,
  .clip-top,
  .clip-slot,
  .clip-hero,
  .clip-open,
  .video-link {
    display: none !important;
  }

  .page {
    padding: 0;
  }

  .page::before {
    display: none;
  }

  .material-body {
    max-width: none;
    padding: 0;
    border: 0;
  }
}

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

/* The logical thread: the one part a student must learn by heart. It is the
   loudest block on the page (thick ink frame, yellow label, numbered steps
   joined by arrows) so it never reads as one more shaded note. Colour tokens
   only, so both themes work. */
.firul-logic {
  margin: 1.5rem 0;
  padding: 1.25rem 1rem 1rem;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: var(--sheet);
  position: relative;
}

.firul-logic-label {
  position: absolute;
  top: -0.9rem;
  left: 1rem;
  margin: 0;
  padding: 0.1rem 0.8rem;
  border-radius: 999px;
  background: var(--marker-edge);
  color: var(--text);
  font-weight: 700;
  line-height: 1.5;
}

.firul-logic-lead {
  margin: 0.25rem 0 0.9rem;
  font-weight: 700;
}

.firul-logic-steps {
  display: grid;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: fir;
}

.firul-logic-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--marker-soft);
  border: 2px solid var(--marker-edge);
  counter-increment: fir;
  font-weight: 600;
}

.firul-logic-steps li::before {
  content: counter(fir);
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--sheet);
  text-align: center;
  line-height: 1.8rem;
  font-weight: 700;
}

.firul-logic-steps li:not(:last-child)::after {
  content: "↓";
  position: absolute;
  left: 50%;
  bottom: -1.5rem;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.5rem;
}
