/* Study Guardian site — "The Study Spread" world (see DESIGN.md).
   The page IS the planner sheet: dot-grid paper, fountain-pen ink,
   highlighter, exam red. No cream, no serif display, no skeuomorphism. */

:root {
  --paper: #fdfdfb;
  --dot: #c2cbd9;
  --ink: #2140c8;
  --ink-deep: #16309a;
  --ink-body: #1a2740;
  --hl: #f9f13b;
  --red: #b3271e;
  --pencil: #5a6b85;
  --rule: #d7dce6;

  --font-display: 'Archivo Black', sans-serif;
  --font-body: 'Atkinson Hyperlegible', sans-serif;
  --font-hand: 'Shantell Sans', cursive;
  --font-mono: 'Spline Sans Mono', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-body);
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.1px);
  background-size: 24px 24px;
  background-position: 12px 12px;
}

::selection { background: var(--hl); color: var(--ink-body); }

a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--ink-deep); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; color: var(--paper); }

.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ---------- Folio bar ---------- */

.folio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1.25rem, 5vw, 4rem);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.folio-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.folio-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.folio-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.5vw, 1.75rem);
  font-size: 0.95rem;
}

.folio-nav a { text-decoration: none; color: var(--ink-body); }
.folio-nav a:hover { text-decoration: underline; color: var(--ink); }

.folio-cta {
  font-weight: 700;
  color: var(--paper) !important;
  background: var(--ink);
  padding: 0.45rem 1rem;
  border-radius: 3px;
}
.folio-cta:hover { background: var(--ink-deep); text-decoration: none !important; }

@media (max-width: 560px) {
  .folio-nav a:not(.folio-cta) { display: none; }
}

/* ---------- Shared section chrome ---------- */

main { display: block; }

section {
  padding: clamp(3rem, 8vw, 5.5rem) clamp(1.25rem, 5vw, 4rem);
  max-width: 1180px;
  margin: 0 auto;
}

h2.ruled {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 2.25rem;
  padding-bottom: 0.6rem;
  position: relative;
  max-width: 26ch;
  text-wrap: balance;
}

/* hand-ruled ink underline: two slightly offset strokes */
h2.ruled::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(100%, 22rem);
  height: 5px;
  background:
    linear-gradient(to right, var(--ink) 0 100%) 0 0 / 100% 2px no-repeat,
    linear-gradient(to right, transparent 0 4%, var(--ink) 4% 78%, transparent 78%) 0 4px / 100% 1.5px no-repeat;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  padding-top: clamp(3rem, 7vw, 5rem);
  padding-bottom: clamp(1.5rem, 4vw, 2.5rem);
  position: relative;
}

/* Page-wide margin apparatus (≥1240px): every paper section carries the
   printed red margin rule and a vertical folio label in its left gutter,
   so the whole page reads as one spread. The ink cover has no margin rule —
   covers aren't ruled. */
@media (min-width: 1240px) {
  main > section:not(.cover) { position: relative; }
  main > section:not(.cover)::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2.4rem;
    width: 2px;
    background: color-mix(in srgb, var(--red) 45%, transparent);
  }
  main > section[data-folio]::after {
    content: attr(data-folio);
    position: absolute;
    top: clamp(3rem, 8vw, 5.5rem);
    left: 1.15rem;
    writing-mode: vertical-rl;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    color: var(--pencil);
  }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 5.4vw, 4.1rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 1.4rem;
  text-wrap: balance;
}

.lede {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  max-width: 54ch;
  margin-bottom: 2rem;
}

.lede mark,
mark {
  background: linear-gradient(105deg, transparent 0.4%, var(--hl) 3%, var(--hl) 97%, transparent 99.5%);
  padding: 0.05em 0.25em;
  color: var(--ink-body);
  font-weight: 700;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.btn-primary,
.btn-paper,
.btn-ink {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  text-decoration: none;
  border-radius: 4px;
  padding: 0.85rem 1.5rem;
  border: none;
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out), background-color 0.18s var(--ease-out);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 2px 3px 0 var(--ink-deep);
}
.btn-primary:hover {
  background: var(--ink-deep);
  color: var(--paper);
  transform: translate(-1px, -1px);
  box-shadow: 3px 4px 0 rgba(22, 48, 154, 0.55);
}

.btn-sub {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
  opacity: 0.85;
}

.btn-ghost {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.15rem;
}
.btn-ghost:hover { border-color: var(--ink-deep); }

.hand-note {
  font-family: var(--font-hand);
  font-size: 1rem;
  color: var(--pencil);
}

.hero-note { transform: rotate(-0.8deg); }

/* ---------- The spread (hero demo) ---------- */

.spread {
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  padding: 1.4rem 1.5rem 1.1rem;
  box-shadow: 4px 5px 0 rgba(33, 64, 200, 0.14);
}

.spread-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--pencil);
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 0.55rem;
  margin-bottom: 1.1rem;
}

.spread-legend { letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 0.35rem; }

.sq-demo {
  display: inline-block;
  width: 0.7rem; height: 0.7rem;
  border: 1.5px solid var(--ink);
  border-radius: 1px;
  vertical-align: -1px;
}
.sq-demo.filled { background: var(--ink); }
.sq-demo.away { border-color: var(--red); background: transparent; }

.block { margin-bottom: 1.35rem; }

.block-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  margin-bottom: 0.55rem;
}

.block-time {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  white-space: nowrap;
}

.block-task { font-weight: 700; }

/* highlighter swipe over the completed block line */
.hl-target {
  position: relative;
  isolation: isolate;
}
.hl-target::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: -0.45rem;
  right: -0.3rem;
  top: 12%;
  bottom: -4%;
  background: var(--hl);
  border-radius: 2px;
  transform: skewX(-6deg) scaleX(0);
  transform-origin: left center;
  transition: transform 0.7s var(--ease-out);
}
.hl-target.swiped::before { transform: skewX(-6deg) scaleX(1); }

.squares { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.sq {
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  position: relative;
  background: transparent;
}

/* ink fill grows from the bottom, like a pen filling a box */
.sq::after {
  content: '';
  position: absolute;
  inset: 1px;
  background: var(--ink);
  border-radius: 1px;
  transform: scaleY(0);
  transform-origin: bottom center;
  transition: transform 0.45s var(--ease-out);
}
.sq.inked::after { transform: scaleY(1); }

.sq.away { border-color: var(--red); }
.sq.away::after {
  background:
    linear-gradient(45deg, transparent 42%, var(--red) 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--red) 42% 58%, transparent 58%);
}

.block-note {
  margin-top: 0.5rem;
  transform: rotate(-0.6deg);
}

.spread-disclaimer {
  font-size: 0.8rem;
  color: var(--pencil);
  border-top: 1.5px dashed var(--rule);
  padding-top: 0.7rem;
  margin-top: 0.4rem;
}

/* ---------- On screen ---------- */

.shot-wrap {
  position: relative;
  margin-bottom: 2.5rem;
}

.shot {
  width: 100%;
  height: auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 5px 6px 0 rgba(33, 64, 200, 0.12);
}

.shot-note {
  position: absolute;
  color: var(--ink);
  max-width: 15rem;
  line-height: 1.35;
}
.shot-note-1 { top: 14%; right: -1rem; transform: rotate(1.4deg); }
.shot-note-2 { bottom: 6%; right: 2%; transform: rotate(-1deg); }

@media (max-width: 900px) {
  .shot-note { position: static; transform: none; margin-top: 0.6rem; max-width: none; }
}

.moves {
  list-style: none;
  counter-reset: move;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
}

.moves li {
  counter-increment: move;
  border-top: 2px solid var(--ink);
  padding-top: 0.9rem;
}

.moves h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

/* the step index is real sequence information: plan → study → review */
.moves h3::before {
  content: counter(move) '. ';
  font-family: var(--font-mono);
  color: var(--pencil);
  font-weight: 400;
}

.moves p { font-size: 0.97rem; color: var(--ink-body); }

@media (max-width: 760px) {
  .moves { grid-template-columns: 1fr; }
}

/* ---------- Ledger ---------- */

.ledger-lede { max-width: 62ch; margin-bottom: 2.2rem; font-size: 1.08rem; }

.ledger-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-bottom: 2.4rem;
}

@media (max-width: 820px) {
  .ledger-cols { grid-template-columns: 1fr; }
}

.ledger-col h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

.ledger-col h3.never-h { color: var(--red); }

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.ledger-table td {
  border-bottom: 1.5px solid var(--rule);
  padding: 0.55rem 0.75rem 0.55rem 0;
  vertical-align: top;
}

.ledger-table td:first-child {
  color: var(--pencil);
  white-space: nowrap;
  width: 6.5rem;
}

.ledger-table code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--ink-body);
}

.ledger-fine { font-size: 0.88rem; color: var(--pencil); margin-top: 0.9rem; }

.never-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  font-size: 0.98rem;
}

.struck {
  font-weight: 700;
  position: relative;
  white-space: nowrap;
}

/* exam-pen strike: draws in on scroll */
.struck::after {
  content: '';
  position: absolute;
  left: -2%;
  right: -2%;
  top: 52%;
  height: 2.5px;
  background: var(--red);
  transform: rotate(-1.2deg) scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s var(--ease-out);
}
.in-view .struck::after { transform: rotate(-1.2deg) scaleX(1); }

/* ---------- Sticky notes ---------- */

.sticky-note {
  background: var(--hl);
  color: var(--ink-body);
  max-width: 30rem;
  padding: 1.4rem 1.5rem;
  border-radius: 2px;
  transform: rotate(-1.1deg);
  box-shadow: 3px 5px 12px rgba(26, 39, 64, 0.16);
}

.hand-note-strong {
  font-family: var(--font-hand);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--ink-body);
  margin-bottom: 0.5rem;
}

.dare { margin-bottom: 2rem; }
.dare p:not(.hand-note-strong) { font-size: 0.98rem; }

.ledger-exception {
  font-size: 0.92rem;
  color: var(--pencil);
  max-width: 62ch;
  border-left: 1px solid var(--rule);
  padding-left: 1rem;
}

/* ---------- Cover (download) ---------- */

.cover {
  max-width: none;
  background: var(--ink);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

/* the elastic band */
.cover::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: clamp(1.5rem, 8vw, 7rem);
  width: 14px;
  background: var(--ink-deep);
}

.cover-inner { max-width: 1180px; margin: 0 auto; padding-right: clamp(3rem, 10vw, 9rem); }

.cover h2 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 3rem);
  letter-spacing: -0.01em;
  margin-bottom: 0.9rem;
}

.cover-lede { max-width: 56ch; margin-bottom: 2.2rem; color: #c8d3f5; font-size: 1.05rem; }

.dl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem 2.5rem;
  margin-bottom: 2.4rem;
}

.btn-paper {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 2px 3px 0 rgba(10, 20, 60, 0.5);
  font-size: 1.15rem;
  padding: 1rem 1.9rem;
}
.btn-paper:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 4px 0 rgba(10, 20, 60, 0.6);
  color: var(--ink-deep);
}

.dl-meta { font-size: 0.92rem; color: #c8d3f5; max-width: 34rem; }
.dl-meta .mono { color: var(--paper); }
.dl-meta .sha { font-size: 0.78rem; word-break: break-all; }
.dl-meta p + p { margin-top: 0.4rem; }

.honesty {
  border: 1.5px dashed rgba(253, 253, 251, 0.55);
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  max-width: 46rem;
}

.honesty h3 { font-size: 1.02rem; margin-bottom: 0.5rem; }
.honesty p { font-size: 0.95rem; color: #dde5fb; }
.honesty strong, .honesty em { color: var(--paper); }

/* on the ink field, an ink focus ring is invisible */
.cover :focus-visible { outline-color: var(--paper); }

/* ---------- macOS waitlist ---------- */

.mac { display: flex; justify-content: center; }

.mac-note { transform: rotate(0.9deg); width: 100%; }

#waitlist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

#wl-email {
  flex: 1 1 14rem;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--ink-body);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink-body);
}
#wl-email::placeholder { color: var(--pencil); }
#wl-email:focus-visible { outline-color: var(--ink-body); }

.btn-ink {
  background: var(--ink-body);
  color: var(--hl);
}
.btn-ink:hover { background: #10192b; }
.btn-ink[disabled] { opacity: 0.6; cursor: wait; }

.wl-msg { flex-basis: 100%; font-size: 0.92rem; font-weight: 700; min-height: 1.4em; }
.wl-msg.err { color: var(--red); }

/* ---------- FAQ ---------- */

.faq dl {
  display: flex;
  flex-direction: column;
  gap: 1.9rem;
  max-width: 70ch;
}

.qa dt {
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

.qa dd { color: var(--ink-body); }

/* ---------- Footer ---------- */

.foot {
  border-top: 2px solid var(--ink);
  padding: 2rem clamp(1.25rem, 5vw, 4rem) 2.5rem;
  max-width: 1180px;
  margin: 0 auto;
}

.foot-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem 2rem;
  font-size: 0.95rem;
  margin-bottom: 0.7rem;
}

.foot-line nav { display: flex; gap: 1.5rem; }

.foot-fine { font-size: 0.85rem; color: var(--pencil); }

/* ---------- Responsive: hero collapses ---------- */

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .spread { max-width: 34rem; }
}

/* ---------- No-JS fallback: the spread renders complete ---------- */

html:not(.js) .sq::after { transform: scaleY(1); }
html:not(.js) .hl-target::before { transform: skewX(-6deg) scaleX(1); }
html:not(.js) .struck::after { transform: rotate(-1.2deg) scaleX(1); }
html:not(.js) .mac { display: none; }

/* ---------- Reduced motion: everything lands filled ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001s !important; animation: none !important; }
  .sq::after { transform: scaleY(1); }
  .hl-target::before { transform: skewX(-6deg) scaleX(1); }
  .struck::after { transform: rotate(-1.2deg) scaleX(1); }
}
