/* Revision.click: a school notebook page with highlighter marks.
   Ink blue carries the interface; highlighter colours carry meaning:
   in the sheet they mark the kind of box, on the class picker the cycle. */

:root {
  --ink: #1f3a93;          /* encre bleue */
  --ink-deep: #14275f;
  --text: #1e2433;
  --muted: #5b6478;
  --desk: #eaeef5;
  --paper: #ffffff;
  --grid: rgba(31, 58, 147, 0.07);
  --margin: #e7a3a3;
  --line: #d3d9e6;

  --hl-yellow: #fff07a;
  --hl-green: #c6f0c4;
  --hl-pink: #ffd0e6;
  --hl-blue: #d4e7ff;
  --hl-orange: #ffdcb8;
  --correction: #1d7a45;

  --cy-primaire: #ffe45c;
  --cy-college: #8fb6ff;
  --cy-lycee: #ff9ccd;

  --ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --serif-lat: "Literata", Georgia, serif;
  --serif-ar: "Noto Naskh Arabic", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--text);
  font: 16px/1.55 var(--ui);
}

a { color: var(--ink); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[lang="ar"] { font-family: var(--serif-ar); }

.skip { position: absolute; inset-inline-start: 0.5rem; top: -4rem; background: var(--ink); color: #fff; padding: 0.5rem 0.8rem; border-radius: 6px; z-index: 10; }
.skip:focus { top: 0.5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem 3rem; }

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

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

.brand { display: inline-flex; align-items: baseline; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-name {
  padding: 0 0.12em;
  font: 700 1.55rem/1.1 var(--serif-lat);
  color: var(--ink-deep);
  background: linear-gradient(100deg, transparent 0.1em, var(--hl-yellow) 0.2em, var(--hl-yellow) calc(100% - 0.15em), transparent 100%) 0 62% / 100% 0.55em no-repeat;
}
.brand-tld { font: 600 1.05rem/1 var(--ui); color: var(--ink); }

.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.site-head { flex-wrap: wrap; }
.site-nav a { padding: 0.4rem 0.75rem; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; }
.site-nav a:hover { background: var(--paper); color: var(--ink); }

.site-nav .lang-switch { margin-inline-start: 0.35rem; border: 1px solid var(--line); background: var(--paper); }
.site-nav .lang-switch[lang="ar"] { font-family: var(--serif-ar); }
[dir="rtl"] .hero-text h1, [dir="rtl"] .lead { font-family: var(--serif-ar); }
[dir="rtl"] .hero-text h1 { line-height: 1.45; max-width: 24ch; }
[dir="rtl"] .cycle h3 { font-family: var(--serif-ar); }
[dir="rtl"] .cycle h3 span, [dir="rtl"] .class-name, [dir="rtl"] .class-count, [dir="rtl"] .section-row a { font-family: var(--serif-ar); }
[dir="rtl"] .class-tab { border-radius: 10px 4px 4px 10px; padding: 0.7rem 1.15rem 0.7rem 0.75rem; }
[dir="rtl"] .class-tab::before { inset: -1px -1px -1px auto; border-radius: 0 4px 4px 0; }

/* ---------------------------------------------------------------- home hero */

.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1rem 3.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.hero-mark { width: clamp(190px, 22vw, 270px); }
.mini-sheet {
  display: block;
  width: 100%;
  height: auto;
  transform: rotate(-3deg);
  filter: drop-shadow(0 14px 22px rgba(20, 39, 95, 0.18)) drop-shadow(0 1px 1px rgba(20, 39, 95, 0.1));
}
.ms-paper { fill: #fff; }
/* the one load moment: the highlighter swipes across "à retenir" */
.ms-hl { transform-box: fill-box; transform-origin: left center; transform: scaleX(0); animation: swipe 0.7s 0.35s cubic-bezier(0.5, 0, 0.2, 1) forwards; }
@keyframes swipe { to { transform: scaleX(1); } }

.hero-text h1 {
  margin: 0 0 1rem;
  font: 700 clamp(1.8rem, 3.6vw, 2.8rem)/1.15 var(--serif-lat);
  color: var(--ink-deep);
  max-width: 26ch;
  text-wrap: balance;
}

.lead { margin: 0 0 0.75rem; font-size: 1.1rem; color: var(--muted); max-width: 60ch; }
.hero-stat { margin: 1.25rem 0 0; font-size: 1rem; }
.hero-stat strong {
  font: 700 1.5rem/1 var(--serif-lat);
  color: var(--text);
  padding: 0 0.25rem;
  background: linear-gradient(transparent 55%, var(--hl-yellow) 55%, var(--hl-yellow) 92%, transparent 92%);
}

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 1rem 1rem 2rem; }
  .hero-mark { display: none; }
  .hero-text h1 { font-size: clamp(1.6rem, 7vw, 2.1rem); }
  .lead { font-size: 1rem; }
}

/* ---------------------------------------------------------------- class picker */

.classes { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem 3.5rem; }

/* one band per cycle: its name on the left, its classes on the right */
.cycle {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 0.75rem 2rem;
  padding: 1.5rem 0;
  border-top: 2px solid var(--ink);
  scroll-margin-top: 1rem;
}
.cycle > :not(h3) { grid-column: 2; }
.cycle h3 { grid-row: 1 / span 4; margin: 0; font: 700 1.5rem/1.2 var(--serif-lat); color: var(--ink-deep); }
.cycle h3 span { display: block; margin-top: 0.25rem; font-size: 1.05rem; font-weight: 600; color: var(--muted); }

@media (max-width: 720px) {
  .classes { padding: 0 1rem 2.5rem; }
  .tabs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.5rem; }
  .cycle-lycee .tabs { grid-template-columns: repeat(auto-fill, minmax(96px, 150px)); }
  .class-tab { min-height: 6.2rem; padding: 0.6rem 0.6rem 0.6rem 1rem; }
  .class-num { font-size: 2rem; }
  .cycle { grid-template-columns: 1fr; padding: 1.1rem 0; }
  .cycle > :not(h3) { grid-column: 1; }
  .cycle h3 { grid-row: auto; }
  .cycle h3 span { display: inline; margin-inline-start: 0.5rem; }
}

#primaire { --spine: var(--cy-primaire); }
#college { --spine: var(--cy-college); }
#lycee { --spine: var(--cy-lycee); }

.tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0.7rem; }

/* a class is a notebook cover: the spine colour is its cycle */
.class-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 7.2rem;
  padding: 0.7rem 0.75rem 0.7rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px 10px 10px 4px;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}
.class-tab::before {
  content: "";
  position: absolute;
  inset: -1px auto -1px -1px;
  width: 0.45rem;
  background: var(--spine);
  border-radius: 4px 0 0 4px;
}
.class-tab:hover { border-color: var(--ink); transform: translateY(-2px); }
.class-num { font: 700 2.4rem/1 var(--serif-lat); color: var(--ink); }
.class-name { font-size: 0.85rem; color: var(--muted); }
.class-count { margin-top: auto; font-size: 0.8rem; font-weight: 600; }
.class-tab.is-soon .class-num { color: #9aa3b8; }
.class-tab.is-soon .class-count { font-weight: 400; color: var(--muted); }

.cycle-lycee .tabs { grid-template-columns: repeat(auto-fill, minmax(118px, 160px)); margin-bottom: 0.25rem; }

.section-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.section-year { margin: 0; font: 700 1.05rem/1.3 var(--serif-lat); color: var(--ink-deep); }
.section-row ul { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.section-row a {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--spine);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.section-row a:hover { border-color: var(--ink); border-inline-start-color: var(--spine); }
.section-row a.is-soon { color: var(--muted); }
.section-row small { font-weight: 600; color: var(--ink); }

@media (max-width: 520px) { .section-row { grid-template-columns: 1fr; gap: 0.35rem; } }

/* ---------------------------------------------------------------- inner pages */

.crumbs ol { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.25rem 0 1.25rem; padding: 0; list-style: none; font-size: 0.9rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-inline-end: 0.35rem; color: #a5adc0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }

.page-head { margin-bottom: 2rem; }
.page-head h1 { margin: 0; font: 700 clamp(1.9rem, 3.4vw, 2.6rem)/1.15 var(--serif-lat); color: var(--ink-deep); }
.page-head h1 [lang="ar"] { font-family: var(--serif-ar); }
.h1-fr { font-size: 0.55em; font-weight: 600; color: var(--muted); }
.page-head-ar { margin: 0.25rem 0 0.75rem; font-size: 1.3rem; color: var(--muted); text-align: left; }
.page-head .lead { margin-top: 0.5rem; }
.intro-line { margin: 0.5rem 0 0; max-width: 70ch; color: var(--muted); font-size: 0.98rem; }
.intro-line[dir="rtl"] { font-size: 1.08rem; }
.intro { display: grid; gap: 0.5rem; max-width: 72ch; margin: 0 0 1.5rem; color: var(--muted); }
.intro p { margin: 0; }
.intro [dir="rtl"] { font-size: 1.08rem; }
.primary-link { display: inline-block; margin-top: 0.5rem; padding: 0.6rem 1rem; border-radius: 8px; background: var(--ink); color: #fff; text-decoration: none; font-weight: 600; }

/* subjects: ruled lines of a notebook index */
.subject-list { margin: 0; padding: 0; list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.subject-list li + li { border-top: 1px solid var(--line); }
.subject-list a {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 0.25rem 1.25rem;
  align-items: baseline;
  padding: 0.9rem 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.subject-list a:hover { background: #f5f7fc; }
.subj-name { font-size: 1.25rem; font-weight: 600; color: var(--ink-deep); }
.subj-name[dir="rtl"] { text-align: left; }
.subj-fr { color: var(--muted); }
.subj-count { grid-column: 3; font-size: 0.9rem; font-weight: 500; text-align: end; }
.subject-list .is-soon .subj-name { color: #7d869b; }
.subject-list .is-soon .subj-count { color: var(--muted); font-weight: 400; }

@media (max-width: 640px) {
  .subject-list a { grid-template-columns: 1fr; }
  .subj-count { grid-column: 1; text-align: start; }
}

.sheet-group { margin-bottom: 2.25rem; }
.sheet-group h2 a { color: inherit; text-decoration: none; }
.sheet-group h2 a:hover { color: var(--ink); text-decoration: underline; }
.sheet-group h2 [lang="ar"] { font-size: 0.85em; color: var(--muted); }

/* level page: shortcuts to every résumé / exercise series of the class */
.collection-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: -0.75rem 0 1.5rem; padding: 0; list-style: none; }
.collection-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.collection-links a:hover { background: var(--ink); color: #fff; }
.collection-links span { font-size: 0.85rem; font-weight: 500; opacity: 0.8; }

/* text pages: about, privacy, FAQ */
.prose { max-width: 50rem; }
.prose h2 { margin: 2rem 0 0.5rem; font: 700 1.3rem/1.3 var(--serif-lat); color: var(--ink-deep); }
.prose p, .prose li { font-size: 1.05rem; }
.prose li { margin-bottom: 0.5rem; }
.faq details { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.6rem; }
.faq summary { cursor: pointer; padding: 0.9rem 1.1rem; font-weight: 600; color: var(--ink-deep); list-style-position: inside; }
.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq details p { margin: 0; padding: 0.9rem 1.1rem 1rem; }
.sheet-group h2, .ask h2 { margin: 0 0 0.6rem; font: 700 1.3rem/1.3 var(--serif-lat); color: var(--ink-deep); }

/* the lessons, in programme order, on ruled paper */
.ruled {
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  counter-reset: lesson;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ruled li { counter-increment: lesson; border-bottom: 1px solid #e4e9f3; }
.ruled li:last-child { border-bottom: 0; }
.ruled a {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.65rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}
.ruled a::before { content: counter(lesson); min-width: 1.4rem; color: var(--margin); font: 600 0.95rem var(--serif-lat); }
.ruled a:hover { color: var(--ink); background: linear-gradient(transparent 20%, #fff6b0 20%, #fff6b0 85%, transparent 85%); }

/* ---------------------------------------------------------------- request form */

.ask { margin-top: 2.5rem; padding: 1.5rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.ask form { display: grid; gap: 1rem; max-width: 40rem; margin-top: 1rem; }
.hint { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--muted); }
.seg-group { display: flex; flex-wrap: wrap; gap: 0.5rem; border: 0; margin: 0; padding: 0; }
.seg-group legend, .field label { display: block; margin-bottom: 0.4rem; font-weight: 600; color: var(--ink-deep); }
.optional { font-weight: 400; color: var(--muted); }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 0.45rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; }
.seg:has(input:checked) span { border-color: var(--ink); background: var(--ink); color: #fff; }
.seg:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 999px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 0.6rem 0.7rem; background: #fff; }
.field input:focus, .field textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 147, 0.15); }
.primary { justify-self: start; border: 0; border-radius: 10px; padding: 0.8rem 1.4rem; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; }
.primary:hover { background: var(--ink-deep); }
.primary:disabled { opacity: 0.7; cursor: progress; }
.form-error { margin: 0; padding: 0.6rem 0.75rem; border-radius: 8px; background: #fdecec; color: #8f1d1d; font-size: 0.92rem; }
#ask-preview { margin-top: 1.5rem; }

/* ---------------------------------------------------------------- sheet page */

.sheet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 2rem; align-items: start; }
@media (max-width: 980px) { .sheet-layout { grid-template-columns: 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.toolbar button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  font-weight: 500;
}
.toolbar button:hover { border-color: var(--ink); color: var(--ink); }
.toolbar .tb-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.toolbar .tb-primary:hover { background: var(--ink-deep); color: #fff; }
.toolbar .tb-wa { border-color: #1e9e57; color: #146c3c; }
.toggle { display: inline-flex; align-items: center; gap: 0.4rem; margin-inline-start: auto; font-size: 0.9rem; color: var(--muted); }

.sheet-aside { position: sticky; top: 1rem; padding: 1.1rem 1.1rem 0.6rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.sheet-aside h2 { margin: 0 0 0.6rem; font: 700 1rem/1.3 var(--serif-lat); color: var(--ink-deep); }
.sheet-aside ul { margin: 0; padding: 0; list-style: none; max-height: 60vh; overflow-y: auto; }
.sheet-aside li + li { border-top: 1px solid #e8ecf4; }
.sheet-aside li a { display: block; padding: 0.45rem 0; color: var(--text); text-decoration: none; line-height: 1.35; }
.sheet-aside li a:hover { color: var(--ink); }
.aside-kind { display: block; font: 500 0.75rem var(--ui); color: var(--muted); }
.aside-all { font-size: 0.9rem; font-weight: 600; }
@media (max-width: 980px) { .sheet-aside { position: static; } }

/* the sheet itself: squared paper with a red margin line */
.sheet {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(20, 39, 95, 0.08), 0 12px 32px -16px rgba(20, 39, 95, 0.25);
  padding: 2.75rem 3rem 2rem 4.75rem;
  font-family: var(--serif-lat);
  font-size: 1.05rem;
  line-height: 1.7;
}
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3.4rem; border-left: 2px solid var(--margin); }
.sheet[dir="rtl"] { padding: 2.75rem 4.75rem 2rem 3rem; font-family: var(--serif-ar); font-size: 1.22rem; line-height: 1.95; }
.sheet[dir="rtl"]::before { left: auto; right: 3.4rem; }

.doc { overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .wrap { padding: 0 0.9rem 2rem; }
  .site-head { padding: 0.75rem 0.9rem; }
  .brand-name { font-size: 1.35rem; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 0.35rem 0.4rem; font-size: 0.88rem; }
  .page-head { margin-bottom: 1.25rem; }
  .ruled a { padding: 0.6rem 0.9rem; gap: 0.6rem; }
  .subject-list a { padding: 0.8rem 0.9rem; }
  .toolbar { gap: 0.4rem; }
  .toolbar button { flex: 1 1 auto; padding: 0.55rem 0.7rem; font-size: 0.9rem; }
  .toggle { margin-inline-start: 0; }
  .ask { padding: 1.1rem; }
  .sheet { padding: 1.75rem 1.1rem 1.5rem 2.6rem; }
  .sheet[dir="rtl"] { padding: 1.75rem 2.6rem 1.5rem 1.1rem; }
  .sheet::before { left: 1.6rem; }
  .sheet[dir="rtl"]::before { right: 1.6rem; }
}

.doc { max-width: 46rem; }
.doc h1 { margin: 0 0 1.25rem; color: var(--ink); font-size: 2rem; line-height: 1.2; font-weight: 700; text-wrap: balance; }
.doc h2 { display: inline-block; margin: 2rem 0 0.6rem; padding-bottom: 0.2rem; border-bottom: 2px solid var(--ink); color: var(--ink); font-size: 1.35rem; line-height: 1.3; font-weight: 700; }
.doc h3 { margin: 1.4rem 0 0.4rem; font-size: 1.12rem; color: var(--ink-deep); }
.doc h4 { margin: 1.2rem 0 0.3rem; font-size: 1rem; }
.doc p { margin: 0 0 0.85rem; }
.doc ul, .doc ol { margin: 0 0 0.9rem; padding-inline-start: 1.4rem; }
.doc li { margin-bottom: 0.25rem; }
.doc strong { font-weight: 700; color: var(--ink-deep); }
.table-wrap { overflow-x: auto; margin: 0 0 1rem; }
.doc table { border-collapse: collapse; width: 100%; background: #fff; font-size: 0.97em; }
.doc th, .doc td { border: 1px solid var(--line); padding: 0.4rem 0.65rem; text-align: start; vertical-align: top; }
.doc th { background: #f1f4fb; color: var(--ink-deep); }

/* callouts: highlighter marks */
.callout {
  --hl: var(--hl-yellow);
  margin: 1.1rem 0 1.25rem;
  padding: 0.9rem 1.1rem 0.4rem;
  background: color-mix(in srgb, var(--hl) 28%, white);
  border-inline-start: 4px solid var(--hl);
  border-radius: 3px;
}
.callout-label {
  display: inline-block;
  margin: 0 0 0.45rem !important;
  padding: 0 0.4rem;
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  background: linear-gradient(100deg, transparent 0.2em, var(--hl) 0.35em, var(--hl) calc(100% - 0.3em), transparent calc(100% - 0.15em));
  border-radius: 0.2em;
}
.callout-retenir { --hl: var(--hl-yellow); }
.callout-dates { --hl: var(--hl-green); }
.callout-vocab { --hl: var(--hl-pink); }
.callout-definition { --hl: var(--hl-blue); }
.callout-attention { --hl: var(--hl-orange); }
.callout-exemple { --hl: #e6e2f7; }
.callout-methode { --hl: #d9eef0; }
.callout-correction { --hl: #c9ebd6; background: #fff; border: 1.5px dashed var(--correction); border-inline-start-width: 1.5px; padding: 0.6rem 1rem; }
.callout-correction .callout-body { display: none; color: #163d2a; }
.callout-correction.open .callout-body { display: block; margin-top: 0.6rem; }
.reveal { border: 0; background: none; padding: 0.15rem 0; color: var(--correction); font-family: var(--ui); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.writing { padding-top: 0.5rem; color: var(--ink); font-family: var(--ui); }
.writing svg { width: 220px; height: 40px; }
.writing path { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 320; stroke-dashoffset: 320; animation: write 1.8s ease-in-out infinite; }
@keyframes write { 0% { stroke-dashoffset: 320; } 55% { opacity: 1; } 60%, 100% { stroke-dashoffset: 0; opacity: 0; } }

.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font: 0.82rem/1.4 var(--ui);
  color: var(--muted);
}

/* ---------------------------------------------------------------- footer */

.site-foot {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.9fr);
  gap: 2rem 3rem;
  max-width: 1180px;
  margin: 1rem auto 0;
  padding: 2rem 1.5rem 2.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--muted);
}
.site-foot nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.5rem; }
.site-foot ul { margin: 0; padding: 0; list-style: none; }
.site-foot li { margin-bottom: 0.2rem; }
.site-foot a { color: var(--text); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }
.foot-brand { margin: 0 0 0.4rem; font: 700 1.25rem var(--serif-lat); color: var(--ink-deep); }
.foot-brand span { font: 600 0.95rem var(--ui); color: var(--ink); }
.foot-title { margin: 0 0 0.4rem; font-weight: 600; color: var(--ink-deep); }
.foot-note { font-size: 0.85rem; }
@media (max-width: 760px) { .site-foot { grid-template-columns: 1fr; padding: 1.5rem 1rem 2rem; } }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); margin: 0; padding: 0.6rem 1.1rem; border-radius: 999px; background: var(--ink-deep); color: #fff; font-size: 0.92rem; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .ms-hl { animation: none; transform: none; }
  .writing path { animation: none; stroke-dashoffset: 0; }
  .class-tab { transition: none; }
  .class-tab:hover { transform: none; }
}

/* ---------------------------------------------------------------- phones: the sheet */

@media (max-width: 600px) {
  .doc h1 { font-size: 1.55rem; }
  .doc h2 { font-size: 1.2rem; margin-top: 1.5rem; }
  .callout { padding: 0.75rem 0.8rem 0.3rem; }
  .sheet-foot { margin-top: 1.75rem; }
}

/* ---------------------------------------------------------------- next / previous sheet */

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1.25rem; }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.pager a:hover { border-color: var(--ink); }
.pager-next { text-align: end; }
.pager-dir { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.pager-prev .pager-dir::before { content: "‹ "; }
.pager-next .pager-dir::after { content: " ›"; }
.pager-title { font-size: 1.02rem; line-height: 1.35; }
.pager-title[dir="rtl"] { text-align: inherit; }

/* ---------------------------------------------------------------- reading bar */

/* a highlighter stroke across the top that fills as the sheet is read */
.reading-bar { position: fixed; inset: 0 0 auto 0; height: 5px; z-index: 30; pointer-events: none; }
.reading-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(180deg, #ffe94d, var(--hl-yellow));
  border-radius: 0 3px 3px 0;
  transform: scaleX(0);
  transform-origin: left center;
  box-shadow: 0 1px 0 rgba(180, 150, 0, 0.25);
}
body:has(.sheet[dir="rtl"]) .reading-bar span { transform-origin: right center; border-radius: 3px 0 0 3px; }

/* ---------------------------------------------------------------- phones: app-like sheet */

.mobile-bar { display: none; }

.toc-sheet {
  width: min(32rem, 100%);
  max-height: 75vh;
  padding: 0.5rem 1.1rem 1.1rem;
  border: 0;
  border-radius: 18px;
  background: var(--paper);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(14, 25, 60, 0.3);
}
.toc-sheet::backdrop { background: rgba(14, 25, 60, 0.45); }
.toc-grip { width: 2.5rem; height: 0.3rem; margin: 0.25rem auto 0.75rem; border-radius: 999px; background: var(--line); }
.toc-title { margin: 0 0 0.5rem; font: 700 1.15rem var(--serif-lat); color: var(--ink-deep); }
.toc-list { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc-list li { counter-increment: toc; border-top: 1px solid #e8ecf4; }
.toc-list a { display: flex; gap: 0.75rem; padding: 0.75rem 0.25rem; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.toc-list a::before { content: counter(toc); min-width: 1.2rem; color: var(--margin); font: 600 0.95rem var(--serif-lat); }
.toc-list[lang="ar"] a { font-family: var(--serif-ar); }
.toc-list a[aria-current] { background: linear-gradient(transparent 18%, var(--hl-yellow) 18%, var(--hl-yellow) 85%, transparent 85%); font-weight: 600; }
.toc-close { width: 100%; margin-top: 0.75rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: 12px; background: #f5f7fc; font-weight: 600; cursor: pointer; }

@media (max-width: 720px) {
  /* the actions move to a floating bar under the thumb */
  .toolbar button { display: none; }
  .toolbar:not(:has(.toggle)) { display: none; }
  body:has(.mobile-bar) { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .mobile-bar {
    position: fixed;
    inset: auto 0.75rem calc(0.75rem + env(safe-area-inset-bottom)) 0.75rem;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: 18px;
    background: rgba(20, 39, 95, 0.96);
    box-shadow: 0 10px 30px rgba(14, 25, 60, 0.35);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  .mobile-bar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.25rem;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #fff;
    font: 600 0.78rem var(--ui);
    cursor: pointer;
  }
  .mobile-bar button[hidden] { display: none; }
  .mobile-bar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-bar button:active { background: rgba(255, 255, 255, 0.12); }
  .mobile-bar .mb-share { background: var(--hl-yellow); color: var(--ink-deep); }
  .mobile-bar .mb-share:active { background: #ffe94d; }

  .toc-sheet { margin: auto auto 0; width: 100%; max-width: none; border-radius: 18px 18px 0 0; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom)); }
  .toc-sheet[open] { animation: rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }

  .pager { grid-template-columns: 1fr; }
  .pager-next { order: -1; }
  .sheet-aside { margin-top: 0.5rem; }

  /* home: each cycle is a pile of notebooks you swipe through */
  .tabs, .cycle-lycee .tabs, .section-row ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.6rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1rem;
    margin-inline: -1rem;
    padding: 0.25rem 1rem 0.6rem;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
    mask-image: linear-gradient(to right, #000 82%, transparent);
  }
  [dir="rtl"] .tabs, [dir="rtl"] .section-row ul { -webkit-mask-image: linear-gradient(to left, #000 82%, transparent); mask-image: linear-gradient(to left, #000 82%, transparent); }
  .tabs::-webkit-scrollbar, .section-row ul::-webkit-scrollbar { display: none; }
  .section-row li { flex: 0 0 auto; scroll-snap-align: start; }

  /* a class card becomes a cahier: coloured cover, white name label */
  .class-tab {
    flex: 0 0 40%;
    scroll-snap-align: start;
    min-height: 9.5rem;
    padding: 0.8rem 0.75rem 0.75rem 1.1rem;
    background: color-mix(in srgb, var(--spine) 30%, white);
    border-color: color-mix(in srgb, var(--spine) 60%, white);
  }
  .class-tab::before { width: 0.6rem; background: var(--spine); }
  .class-num {
    align-self: flex-start;
    min-width: 3.2rem;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(20, 39, 95, 0.12);
    font-size: 2.1rem;
    text-align: center;
  }
  .class-name { margin-top: 0.45rem; color: var(--text); font-weight: 500; }
  .class-count { font-size: 0.82rem; }
  .class-tab.is-soon { background: #f3f5f9; border-color: var(--line); }
  .class-tab.is-soon .class-num { box-shadow: none; }
  .class-tab:hover { transform: none; }
  .class-tab:active { transform: scale(0.97); }
}

/* error reports */
.report-line { margin: 1.25rem 0 0; text-align: center; }
.report-open { border: 0; background: none; padding: 0.4rem; color: var(--muted); font: 500 0.92rem var(--ui); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.report-open:hover { color: var(--ink); }
.report-sheet form { display: grid; gap: 0.75rem; }
.report-sheet .hint { margin: 0; }
.report-sheet textarea, .report-sheet input:not(.hp) { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 0.6rem 0.7rem; background: #fff; font-size: 16px; }
.report-actions { display: flex; gap: 0.5rem; align-items: center; }
.report-actions .primary { flex: 1; }
.report-actions .toc-close { flex: 1; margin-top: 0; }
.report-done p { margin: 0 0 0.75rem; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }

@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .toc-sheet[open] { animation: none; }
}

/* ---------------------------------------------------------------- print: only the sheet */

@media print {
  @page { margin: 14mm 14mm 16mm; }
  body { background: #fff; }
  .site-head, .site-foot, .crumbs, .toolbar, .sheet-aside, .toast, .reveal, .skip, .pager, .mobile-bar, .reading-bar, .toc-sheet, .report-line { display: none !important; }
  body { padding-bottom: 0 !important; }
  .wrap { padding: 0; max-width: none; }
  .sheet-layout { display: block; }
  .sheet { box-shadow: none; background: #fff; padding: 0; font-size: 11.5pt; }
  .sheet::before { display: none; }
  .doc { max-width: none; }
  .doc h1 { font-size: 20pt; }
  .doc h2 { font-size: 14pt; break-after: avoid; }
  .callout, .doc table { break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .callout-label { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .callout-correction .callout-body { display: block; margin-top: 0; }
  .print-no-corrections .callout-correction { display: none; }
  .sheet-foot { margin-top: 1.5rem; }
}
