/* ============================================================
   04 — Learning Cohort · "Swiss Syllabus"
   International Typographic Style. Grid made visible.
   No webfont — Helvetica-neutral is the point.
   ============================================================ */

:root {
  --bg: #FFFFFF;
  --ink: #111111;
  --rule: #D8D8D8;
  --accent: #D40000;
  --grey: #717171;

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` loses to any author `display` rule
   below, and every demo here toggles `element.hidden` to show and hide
   panels. Without this, hiding silently stops working. */
[hidden] { display: none !important; }

/* A long unbroken token -- a pasted URL, a 200-character "word" -- must wrap
   rather than push its container past its grid track and break the row.
   `anywhere` rather than `break-word` on purpose: only `anywhere` reduces the
   element's min-content width, and a grid or flex item defaults to
   `min-width: auto`, which refuses to shrink below its longest word. With
   `break-word` alone, demo-06 and demo-10 still blew 1.4k px past the viewport.
   The `min-width: 0` below is the other half of the same fix. */
h1, h2, h3, h4, p, li, a, span, strong, em, code, label, time,
button, input, textarea { overflow-wrap: anywhere; }
.card, .post, .listing, .idea, .topic, .question, .profile-card, .submission,
.lesson, .resource, .nominee, .archive-item, .member-card, .comment, .reply,
.answer, .idea-body-wrap { min-width: 0; }


body {
  margin: 0;
  padding-block-end: 72px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  position: relative;
  max-width: 1160px; margin-inline: auto;
  padding: 0 24px;
}
@media (min-width: 900px) { .wrap { padding: 0 56px; } }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Visible 12-column grid overlay (the signature) ---------- */

.grid-guides {
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
  max-width: 1160px; margin-inline: auto;
  padding: 0 24px;
  display: none;
}
@media (min-width: 900px) {
  .grid-guides { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; padding: 0 56px; }
}
.grid-guides span {
  border-left: 1px solid var(--ink);
  opacity: 0.13;
  transform-origin: top;
}
/* The right edge of the twelfth column, so the grid reads as closed. */
.grid-guides span:last-child { border-right: 1px solid var(--ink); }

/* Lift page content above the .grid-guides overlay. Scoped to the two real
   content blocks: as `body > *` it also caught .toast-stack and overrode its
   `position: fixed`, so every toast rendered in normal flow at the foot of the
   document where nobody would ever see it. */
body > .wrap, body > .new-comment { position: relative; z-index: 1; }

/* ---------- Masthead ---------- */

.topbar { padding-block: clamp(26px, 4vw, 52px) 18px; }
.topbar h1 {
  font-size: clamp(30px, 3.8vw, 48px);
  line-height: 1.06;
  max-width: 20ch;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--accent);
}
.topbar > div > p { color: var(--grey); max-width: 56ch; margin-top: 16px; }

.identity-picker { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey); margin-top: 20px; }
.identity-picker select {
  font: inherit; font-size: 14px; letter-spacing: 0; text-transform: none;
  margin-left: 8px; min-height: 44px; padding: 8px 10px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0;
}

.privacy-note {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-block: 16px;
  margin-block: 28px;
  font-size: 14px;
  color: var(--grey);
  max-width: 62ch;
}
.privacy-note strong { color: var(--ink); }
.privacy-note code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: var(--accent); }

/* ---------- Lessons: strict grid rows ---------- */

.lesson-list { list-style: none; margin: 0; padding: 0; }

.lesson {
  border-top: 1px solid var(--rule);
  padding-block: 30px;
  display: grid; gap: 6px 24px;
}
.lesson:last-child { border-bottom: 1px solid var(--rule); }

@media (min-width: 900px) {
  .lesson {
    grid-template-columns: repeat(12, 1fr);
    align-items: start;
  }
  .lesson-order   { grid-column: 1 / 3; }
  .lesson-title   { grid-column: 2 / 8; }
  .lesson > p[itemprop="body"] { grid-column: 2 / 8; }
  .lesson-due     { grid-column: 10 / 13; text-align: right; }
  .submit-form    { grid-column: 2 / 8; }
  .my-submission  { grid-column: 2 / 8; }
}

/* Large red numerals in the margin. */
.lesson-order {
  /* Never hyphen-break the label itself. The global `overflow-wrap: anywhere`
     rule exists for pasted URLs in body copy; applied to a 34px label in a
     narrow track it rendered "Lesson 1" as "Les / son / 1". */
  overflow-wrap: normal;
  font-size: 34px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--accent); line-height: 1;
}
.lesson-title { font-size: clamp(19px, 2vw, 25px); line-height: 1.18; margin-bottom: 8px; }
.lesson > p[itemprop="body"] { color: var(--ink); max-width: 58ch; }
.lesson-due { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey); }

/* ---------- Forms ---------- */

.submit-form { margin-top: 18px; }
.field { display: block; margin-bottom: 12px; }
.field label { display: block; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey); margin-bottom: 6px; }
.field textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--ink);
  border-radius: 0; padding: 10px 12px; resize: vertical; min-height: 4.5rem;
}
.field textarea:focus { border-color: var(--accent); border-width: 2px; }

.btn {
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  min-height: 44px; padding: 12px 22px;
  background: var(--ink); color: var(--bg);
  border: 0; border-radius: 0;
  transition: background-color 140ms linear;
}
.btn:hover { background: var(--accent); }

.btn-ghost {
  font: inherit; font-size: 12px; letter-spacing: 0.05em; cursor: pointer;
  min-height: 44px; padding: 10px 14px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 0;
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }

.my-submission {
  margin-top: 16px; padding: 16px;
  border-left: 3px solid var(--accent);
  background: #FAFAFA;
  font-size: 14px;
}
.status-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 0;
}
.status-badge.on-time { background: var(--ink); color: var(--bg); }
.status-badge.late { background: var(--accent); color: var(--bg); }

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 88px; display: grid; gap: 8px; z-index: 50; }
.toast {
  font-size: 13px; background: var(--ink); color: var(--bg);
  border-radius: 0; padding: 12px 16px;
}
.toast.error { background: var(--accent); }

/* ---------- Motion ---------- */

.motion .lesson { opacity: 0; }
.motion .grid-guides span { transform: scaleY(0); }

@media (prefers-reduced-motion: reduce) {
  .motion .lesson { opacity: 1 !important; }
  .motion .grid-guides span { transform: none !important; }
  .btn, .btn-ghost { transition: none !important; }
}

/* Footnote under a submitted result. Was an inline style attribute emitted from
   app.js, which CSP drops outright, against a --ink-muted token that no
   stylesheet defines -- so it rendered as plain body text. */
.result-note { font-size: 13px; color: var(--grey); margin-top: 10px; }


/* ---------- Course progress rail ---------- */
/* The 12-column overlay was reading as banding rather than structure. Dropped
   to near-invisible, and the page gets an actual Swiss device instead: a
   full-bleed progress bar stating where the cohort is. */

.course-rail {
  display: grid; gap: 10px;
  margin: 0 0 34px;
}
.course-rail-head {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: baseline; justify-content: space-between;
  font-family: var(--sans); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--grey);
}
.course-rail-head b { color: var(--accent); font-size: 13px; letter-spacing: 0.1em; }
.course-bar { display: flex; gap: 3px; height: 10px; max-width: 100%; }
.course-bar i { flex: 1; background: var(--rule); display: block; }
.course-bar i.done { background: var(--accent); }
.course-bar i.now  { background: var(--ink); }


/* ---------- Course meta block ---------- */
/* The fold was a headline, a rule and a lot of white. A syllabus states its
   parameters up front; the grid is the design. */

.course-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  margin: 0 0 30px;
}
@media (min-width: 760px) { .course-meta { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.course-meta div {
  padding: 16px 18px 18px 0;
  border-right: 1px solid var(--rule);
}
.course-meta div:last-child { border-right: 0; }
.course-meta dt {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--grey); margin: 0 0 8px;
}
.course-meta dd {
  margin: 0; font-size: 21px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
}
.course-meta dd .unit {
  display: block; font-size: 11px; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--grey); margin-top: 5px;
}
.course-meta .accent { color: var(--accent); }


/* ---------- Rail and note share a band ---------- */
/* Stacked, these two blocks put Lesson 1 at 790px on a 900px viewport. Side by
   side they occupy one band, and the note picks up a measure that agrees with
   the grid instead of trailing off at 600px. */

.course-row {
  display: grid; gap: 12px 40px;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 30px;
}
@media (min-width: 900px) {
  .course-row { grid-template-columns: minmax(0, 1fr) minmax(0, 21rem); align-items: start; }
}
.course-row .course-rail { margin-bottom: 0; }
.course-row .privacy-note {
  margin: 0; max-width: none;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 16px;
}


/* ---------- Lessons on the grid ---------- */
/* The syllabus ran its headings to the full 12 columns and its body text to
   600px, so every lesson read as a wide rule over a narrow paragraph. Put the
   lesson on the grid it is drawn over: number in the margin, brief in the
   measure, dates and the submit control in a third column. */

@media (min-width: 900px) {
  .lesson {
    grid-template-columns: 6.5rem minmax(0, 1fr) 15rem;
    column-gap: 2.5rem;
    align-items: start;
  }
  .lesson > .lesson-order { grid-column: 1; grid-row: 1 / span 5; justify-self: start; }
  .lesson > .lesson-title,
  .lesson > p[itemprop="body"] { grid-column: 2; }
  .lesson > p[itemprop="body"] { max-width: 54ch; }

  /* Column 3: everything to do with handing the work in. */
  .lesson > .lesson-due,
  .lesson > .submit-form,
  .lesson > .my-submission,
  .lesson > .btn-ghost { grid-column: 3; grid-row: auto; }
  .lesson > .lesson-due { padding-top: 4px; }
  .lesson > .submit-form { display: grid; gap: 8px; }
  .lesson > .submit-form textarea { min-height: 7rem; }
}


/* --- corrections after review --- */
@media (min-width: 900px) {
  /* "Lesson 1" wrapped onto two lines in a 6.5rem margin. */
  .lesson { grid-template-columns: 8.25rem minmax(0, 1fr) 15rem; }
  .lesson > .lesson-order { white-space: nowrap; grid-row: 1 / span 4; }

  /* Auto-placement put the submit form four rows below the due date it belongs
     with, leaving a 200px hole in the middle of every lesson. Place the two
     content rows and the four hand-in rows explicitly. */
  .lesson > .lesson-title      { grid-row: 1; }
  .lesson > p[itemprop="body"] { grid-row: 2; }
  .lesson > .lesson-due        { grid-column: 3; grid-row: 1; }
  .lesson > .submit-form       { grid-column: 3; grid-row: 2; }
  .lesson > .my-submission     { grid-column: 3; grid-row: 3; }
  .lesson > .btn-ghost         { grid-column: 3; grid-row: 4; justify-self: start; }

  /* The due date was ranged right against the page edge while the form under
     it started 240px to the left. */
  .lesson > .lesson-due { justify-self: start; text-align: left; }
}
