/* Padawan — an engineer's computation pad: pale green grid paper, graphite ink,
   highlighter for "you are here", red pencil for the mentor. Dark mode = chalkboard. */

/* Self-hosted fonts: no third-party requests from the student's browser */
@font-face { font-family: "Atkinson Hyperlegible"; src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(/fonts/atkinson-hyperlegible-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url(/fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(/fonts/caveat-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(/fonts/caveat-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/fonts/jetbrains-mono-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --paper: #eef3e6;
  --paper-2: #e4ecd9;
  --grid: #d3dfc8;
  --ink: #2b2f2a;
  --ink-2: #5d6659;
  --ink-3: #8a9485;
  --rule: #b9c9ab;
  --sheet: #fbfdf7;
  --red: #c2352b;
  --highlight: #f3e35a;
  --ok: #2f7a4a;
  --focus: #1f5fbf;
  --radius-s: 4px;
  --radius-m: 10px;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-head: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;
  --font-code: "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1e2a23; --paper-2: #24322a; --grid: #2a3a31; --ink: #e6ece0; --ink-2: #b3bfae;
    --ink-3: #85927f; --rule: #3c4f43; --sheet: #233028; --red: #ff7a6b; --highlight: #8a7d1c;
    --ok: #6fcf8f; --focus: #8ab4ff;
  }
}
:root[data-theme="dark"] {
  --paper: #1e2a23; --paper-2: #24322a; --grid: #2a3a31; --ink: #e6ece0; --ink-2: #b3bfae;
  --ink-3: #85927f; --rule: #3c4f43; --sheet: #233028; --red: #ff7a6b; --highlight: #8a7d1c;
  --ok: #6fcf8f; --focus: #8ab4ff;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--ink-3); border: 2px solid transparent; border-radius: 8px; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--ink-2); }
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.55 var(--font-body);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- bilingual display ---- */
.en { color: var(--ink-2); }
.lang-both .bi > .en { display: block; font-style: italic; font-size: .92em; }
.lang-both .bi-inline > .en::before { content: " / "; color: var(--ink-3); font-style: normal; }
.lang-both .bi-inline > .en { font-style: italic; }
.lang-es .en { display: none !important; }
.lang-en .es { display: none !important; }
.lang-en .en { color: inherit; font-style: normal; font-size: inherit; }
.lang-en .bi-inline > .en::before { content: none; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  border-right: 2px solid var(--rule); background: var(--paper);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { font: 800 26px/1 var(--font-head); letter-spacing: -.02em; padding: 4px 10px 18px; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand svg { flex: none; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-s);
  text-decoration: none; font-weight: 700; color: var(--ink-2);
}
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: linear-gradient(transparent 55%, var(--highlight) 55%, var(--highlight) 92%, transparent 92%); }
.nav .count { margin-left: auto; font-size: 13px; background: var(--ink); color: var(--paper); border-radius: 99px; padding: 0 8px; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 6px; font-size: 14px; color: var(--ink-2); }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 99px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 3px 10px; cursor: pointer; font-size: 13px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--ink-2); text-align: left; }

main { padding: 32px clamp(16px, 4vw, 48px) 96px; max-width: 980px; width: 100%; }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; padding: 6px; border-right: 0; border-top: 2px solid var(--rule); }
  .side .brand, .side-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px; }
  .nav .label .en { display: none !important; }
  .nav .count { position: absolute; transform: translate(14px, -4px); font-size: 10px; }
  .nav a { position: relative; }
  main { padding-top: 20px; }
  .stats { gap: 18px; flex-wrap: nowrap; }
  .stat b { font-size: 26px; }
  .stat span { font-size: 12px; }
}

/* ---- type ---- */
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.015em; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 800; }
h2 { font-size: 26px; font-weight: 700; margin-top: 1.4em; }
h3 { font-size: 20px; font-weight: 700; margin-top: 1.2em; }
h1 .en, h2 .en, h3 .en { font-family: var(--font-body); font-weight: 400; letter-spacing: 0; }
.lang-both h1 .en { font-size: .5em; margin-top: .25em; }
p { margin: 0 0 1em; max-width: 68ch; }
code { font: .88em var(--font-code); background: var(--paper-2); padding: 1px 5px; border-radius: 3px; }
pre { font: 14px/1.6 var(--font-code); background: var(--ink); color: var(--paper); padding: 16px 18px; border-radius: var(--radius-m); overflow-x: auto; }
pre code { background: none; padding: 0; color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

/* ---- sheets: a page torn from the pad ---- */
.sheet {
  background: var(--sheet); border: 1.5px solid var(--rule); border-radius: var(--radius-m);
  padding: 22px 24px; margin: 0 0 20px;
}
.sheet.flat { padding: 16px 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* ---- buttons & inputs ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none;
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  font-weight: 700; padding: 9px 18px; border-radius: 99px; line-height: 1.2;
}
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .en { color: inherit; opacity: .75; }
.lang-both .btn .bi-inline > .en::before { color: inherit; }
label.field { display: grid; gap: 4px; font-weight: 700; font-size: 15px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; border: 1.5px solid var(--rule); background: var(--sheet); border-radius: var(--radius-s);
  padding: 9px 11px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.error { color: var(--red); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 99px; font-weight: 700; z-index: 50; animation: toast 2.4s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .sheet { width: min(420px, 100%); }
.login h1 { font-size: 52px; }

/* ---- home ---- */
.hello { margin-bottom: 24px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 0; }
.stat b { font: 800 32px/1 var(--font-head); display: block; }
.stat span { font-size: 14px; color: var(--ink-2); }
.next-up { border-width: 2px; border-color: var(--ink); position: relative; }
.next-up .week { font-weight: 700; color: var(--ink-2); font-size: 14px; }
.next-up h2 { margin-top: 4px; }

/* the trail: 40 weeks as one ruled line */
.trail { display: grid; gap: 22px; }
.trail-track h3 { margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.trail-track h3 .swatch { width: 12px; height: 12px; border-radius: 2px; flex: none; align-self: center; }
.weeks { display: flex; flex-wrap: wrap; gap: 6px; }
.wk {
  width: 46px; height: 46px; border-radius: var(--radius-s); display: grid; place-items: center;
  font: 700 15px var(--font-head); text-decoration: none; border: 1.5px solid var(--rule);
  background: var(--sheet); color: var(--ink-3); position: relative;
}
.wk.ready { color: var(--ink); border-color: var(--ink-2); }
.wk.done { background: var(--tc); border-color: var(--tc); color: #fff; }
.wk.current { background: var(--highlight); border-color: var(--ink); color: #2b2f2a; box-shadow: 3px 3px 0 var(--ink); }
.wk.locked::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--grid) 5px 6px); border-radius: inherit; }
.wk:hover { transform: translateY(-1px); }
.mod-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 2px; }
.mod-list li { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.mod-list .w { font: 700 14px var(--font-head); color: var(--ink-3); }
.mod-list a { text-decoration: none; font-weight: 700; }
.mod-list a:hover { text-decoration: underline; }
.pill { font-size: 12px; font-weight: 700; border: 1.5px solid currentColor; border-radius: 99px; padding: 0 8px; white-space: nowrap; }
.pill.ok { color: var(--ok); }
.pill.soon { color: var(--ink-3); }

/* activity heatmap */
.heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; }
.heat i { border-radius: 2px; background: var(--paper-2); outline: 1px solid var(--grid); }
.heat i.l1 { background: color-mix(in srgb, var(--ok) 35%, var(--sheet)); }
.heat i.l2 { background: color-mix(in srgb, var(--ok) 65%, var(--sheet)); }
.heat i.l3 { background: var(--ok); }

/* ---- module ---- */
.crumbs { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.crumbs a { text-decoration: none; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--ink); margin: 18px 0 22px; overflow-x: auto; overflow-y: hidden; }
.tabs a {
  padding: 8px 14px; text-decoration: none; font-weight: 700; color: var(--ink-2); white-space: nowrap;
  border: 2px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; margin-bottom: -2px; display: flex; gap: 6px; align-items: center;
}
.tabs a[aria-current="page"] { color: var(--ink); background: var(--sheet); border-color: var(--ink); }
.tabs .check { color: var(--ok); }
.lesson-table { width: 100%; border-collapse: collapse; margin: 0 0 1.2em; font-size: 16px; }
.lesson-table th, .lesson-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.lesson-table th { font-family: var(--font-head); border-bottom: 2px solid var(--ink); }
.table-wrap { overflow-x: auto; }
.tip { border-left: 5px solid var(--highlight); background: var(--paper-2); padding: 12px 16px; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 0 0 1.2em; max-width: 68ch; }
.tip::before { content: "💡 "; }
ul.lesson-list { padding-left: 1.2em; max-width: 66ch; }
ul.lesson-list li { margin-bottom: .35em; }

.paper-box { border: 2px dashed var(--ink-2); border-radius: var(--radius-m); padding: 18px 20px; margin: 24px 0; background: var(--sheet); }
.paper-box h3 { margin-top: 0; }
.paper-box ol { padding-left: 1.3em; margin: 0 0 14px; }
.paper-box li { margin-bottom: 8px; }

.lab-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px dashed var(--rule); }
.lab-step .n { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font: 800 15px var(--font-head); }
.lab-step .q { margin-bottom: 8px; }
.lab-step input, .lab-step textarea { margin-top: 4px; }

.quiz-q { padding: 16px 0 18px; border-bottom: 1px dashed var(--rule); }
.quiz-q .q { font-weight: 700; margin-bottom: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1.5px solid var(--rule); border-radius: var(--radius-s); margin-bottom: 6px; cursor: pointer; background: var(--sheet); }
.opt:hover { border-color: var(--ink-2); }
.opt input { margin-top: 5px; accent-color: var(--ink); }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--sheet)); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--sheet)); }
.why { margin-top: 8px; font-size: 15px; color: var(--ink-2); }
.score { font: 800 56px/1 var(--font-head); }

/* mentor marks: red pencil */
.mentor-note { font-family: var(--font-hand); font-size: 24px; line-height: 1.25; color: var(--red); }
.mentor-note .who { font-size: 18px; opacity: .8; display: block; }
.feedback-item { border-left: 3px solid var(--red); padding: 4px 0 4px 14px; margin: 0 0 16px; }
.feedback-item .meta { font-size: 13px; color: var(--ink-2); font-family: var(--font-body); }
.mentor-only { border: 2px solid var(--red); border-radius: var(--radius-m); padding: 12px 16px; margin: 0 0 18px; }

/* ---- flashcards ---- */
.card-stage { perspective: 1200px; max-width: 560px; margin: 20px auto; }
.flash { position: relative; height: 300px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.7,.3,1); cursor: pointer; }
.flash.flipped { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0; backface-visibility: hidden; border: 2px solid var(--ink); border-radius: var(--radius-m);
  background: var(--sheet); display: grid; place-items: center; padding: 28px; text-align: center; font-size: 22px;
  background-image: linear-gradient(transparent 39px, var(--grid) 39px, var(--grid) 40px, transparent 40px); background-size: 100% 40px;
}
.flash .back { transform: rotateY(180deg); }
.flash .face .bi > .en { font-size: .8em; margin-top: 8px; }
.flash .hint { position: absolute; bottom: 12px; left: 0; right: 0; font-size: 13px; color: var(--ink-3); }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 560px; margin: 0 auto; }
.grades button { border: 2px solid var(--ink); background: var(--sheet); border-radius: var(--radius-s); padding: 10px 6px; cursor: pointer; font-weight: 700; display: grid; gap: 2px; }
.grades button small { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.grades button:hover { background: var(--paper-2); }
.grades .again { border-color: var(--red); color: var(--red); }
.progress-bar { height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; max-width: 560px; margin: 0 auto; }
.progress-bar i { display: block; height: 100%; background: var(--ink); transition: width .3s; }

/* ---- journal ---- */
.note-list { display: grid; gap: 8px; }
.note-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 16px; text-decoration: none; background: var(--sheet); border: 1.5px solid var(--rule); border-radius: var(--radius-s); }
.note-row:hover { border-color: var(--ink-2); }
.note-row b { display: block; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.photo { position: relative; border: 1.5px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; background: var(--paper-2); aspect-ratio: 3/4; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo button { position: absolute; top: 6px; right: 6px; border: 0; background: var(--ink); color: var(--paper); border-radius: 99px; width: 26px; height: 26px; cursor: pointer; }
.drop { border: 2px dashed var(--ink-2); border-radius: var(--radius-m); padding: 18px; text-align: center; cursor: pointer; background: var(--sheet); }
.drop.over { background: var(--highlight); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 60; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; }
.save-state { font-size: 13px; color: var(--ink-3); }

/* ---- mentor ---- */
.student-card { display: grid; gap: 10px; text-decoration: none; }
.student-card h3 { margin: 0; }
.meter { height: 10px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
details { border-top: 1px dashed var(--rule); padding: 10px 0; }
details summary { cursor: pointer; font-weight: 700; }
.tb { white-space: pre-wrap; background: var(--paper-2); padding: 12px 14px; border-radius: var(--radius-s); max-width: 68ch; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty b { display: block; font: 700 22px var(--font-head); color: var(--ink); margin-bottom: 6px; }

/* ---- admin ---- */
.admin-block { margin: 28px 0; padding-top: 14px; border-top: 2px solid var(--ink); }
.admin-block h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.actions { font-size: 14px; }
.actions summary { cursor: pointer; color: var(--ink-2); font-weight: 700; padding: 4px 0; }
.actions .stack { padding: 8px 0 4px; }
.actions input, .actions select { width: auto; max-width: 220px; }
.btn.armed { background: var(--red); border-color: var(--red); color: var(--paper); }
.readonly-banner { border: 2px dashed var(--ink-2); border-radius: var(--radius-m); padding: 12px 16px; margin: 0 0 18px; background: var(--paper-2); }
