/* Marginalia Press — notebook stylesheet
   One file, used by every page. Design tokens at the top. */

@font-face {
  font-family: 'Marginalia Hand';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(fonts/hand-normal.woff2) format('woff2-variations');
}
@font-face {
  font-family: 'Marginalia Hand';
  font-style: italic;
  font-weight: 300 800;
  font-display: swap;
  src: url(fonts/hand-italic.woff2) format('woff2-variations');
}
@font-face {
  font-family: 'Marginalia Scrawl';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/scrawl.woff2) format('woff2-variations');
}

:root {
  --paper: #FDFCF7;
  --card: rgba(253, 252, 247, 0.72);
  --rule: #A8C4DC;
  --margin-rule: #DE8C8C;
  --ink: #24365E;
  --ink-soft: #45577E;
  --red: #A83C31;
  --line: 34px;
  --margin-w: 212px;
  --gutter: 40px;
  --hand: 'Marginalia Hand', 'Chalkboard SE', 'Segoe Print', 'Comic Sans MS', system-ui, sans-serif;
  --scrawl: 'Marginalia Scrawl', 'Bradley Hand', 'Segoe Script', 'Comic Sans MS', cursive;
  --ui: system-ui, 'Segoe UI', sans-serif;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--hand);
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) calc(var(--line) - 1px),
    var(--rule) calc(var(--line) - 1px),
    var(--rule) var(--line));
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
a:hover { color: var(--red); }
::placeholder { color: #93A2BC; }

:focus-visible {
  outline: 2.5px solid var(--red);
  outline-offset: 2px;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-family: var(--hand); z-index: 50;
}
.skip:focus { left: 8px; top: 8px; color: var(--paper); }

/* ---------- page frame ---------- */

.sheet {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
  padding-left: var(--margin-w);
  padding-right: var(--gutter);
}

.sheet::before {           /* the red vertical margin rule */
  content: "";
  position: absolute;
  left: var(--margin-w);
  top: 0; bottom: 0;
  width: 2px;
  background: var(--margin-rule);
}

.inner { padding-left: var(--gutter); }

/* ---------- margin notes ----------
   Each note lives inside the block it annotates, so the reading order is
   right on a phone. On a wide screen it floats out into the left margin,
   level with the top of that block. */

.inner > * { position: relative; }

.margin-nav { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0 0; }

.margin-nav a {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; min-height: 30px;
  font-size: 15px; font-weight: 500;
}
.margin-nav a svg { flex-shrink: 0; }
.margin-nav .at { font-size: 15px; font-weight: 600; width: 15px; text-align: center; }

.mnote { margin: 18px 0 0; max-width: 460px; }

.mnote .label {
  display: inline-block;
  font-size: 21px; font-weight: 600;
  transform: rotate(-5.5deg); transform-origin: left center;
  margin-right: 12px;
}
.mnote .scrawl {
  display: block;
  font-family: var(--scrawl);
  font-size: 19px; line-height: 1.24; color: var(--red);
  transform: rotate(-1.4deg); transform-origin: left top;
  margin-top: 6px;
}
.mnote.b .label { transform: rotate(-3.8deg); }
.mnote.b .scrawl { transform: rotate(1.4deg); }

@media (min-width: 901px) {
  .margin-nav {
    position: absolute;
    right: calc(100% + var(--gutter));
    top: 4px;
    width: calc(var(--margin-w) - 46px);
    flex-direction: column;
    gap: 8px; margin: 0;
  }
  /* nav sits level with the wordmark, so notes lower down never meet it */
  .mnote {
    position: absolute;
    right: calc(100% + var(--gutter) + 16px);   /* clear of the red rule */
    width: calc(var(--margin-w) - 46px);
    max-width: none;
    top: 4px; margin: 0;
  }
  .mnote .scrawl { font-size: 18px; }
}

/* ---------- masthead ---------- */

.masthead { padding-top: 34px; }
.masthead h1, .masthead .wordmark {
  margin: 0;
  font-size: 62px; font-weight: 700;
  letter-spacing: -0.005em; line-height: 1.05;
  text-decoration: none; display: block;
}
.masthead .rules { margin-top: 10px; }
.rules { height: 2px; background: var(--ink); }
.rules::after { content: ""; display: block; height: 1px; background: var(--ink); margin-top: 3px; }

.crumb {
  margin: 18px 0 0;
  font-size: 16px;
  font-family: var(--hand);
}
.crumb a { text-decoration: none; border-bottom: 1.5px solid var(--ink); }

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

.hero { display: flex; gap: 52px; align-items: flex-start; margin-top: 46px; flex-wrap: wrap; }
.hero h2 {
  margin: 0; flex: 1 1 380px; max-width: 460px;
  font-size: 34px; font-weight: 600; line-height: 1.32;
}
.hero p {
  margin: 6px 0 0; flex: 1 1 400px; max-width: 560px;
  font-size: 18px; line-height: 1.55; color: var(--ink-soft);
}

.page-title { margin: 40px 0 0; font-size: 40px; font-weight: 700; line-height: 1.15; }
.page-sub { margin: 10px 0 0; font-size: 18.5px; line-height: 1.5; color: var(--ink-soft); max-width: 640px; }

/* ---------- the dark founding-offer box ---------- */

.offer {
  margin-top: 40px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--card);
  padding: 24px 30px;
  display: flex; gap: 44px; align-items: center; flex-wrap: wrap;
}
.offer > div:first-child { flex: 1 1 380px; }
.offer h2 { margin: 0; font-size: 30px; font-weight: 700; }
.offer p { margin: 8px 0 0; font-size: 16px; line-height: 1.45; color: var(--ink-soft); max-width: 480px; }

.price-row { margin-top: 14px; display: flex; align-items: baseline; gap: 11px; flex-wrap: wrap; }
.price { font-size: 38px; font-weight: 700; }
.price-was { font-size: 18px; color: var(--ink-soft); text-decoration: line-through; }
.price-note { font-family: var(--scrawl); font-size: 20px; color: var(--red); }

/* ---------- forms ---------- */

.wl-form { flex: 0 1 330px; display: flex; flex-direction: column; gap: 9px; }
.wl-form label { font-size: 14px; color: var(--ink-soft); }
.wl-form input[type="email"], .wl-form select {
  height: 46px; padding: 0 13px;
  font-family: var(--ui); font-size: 15px; color: var(--ink);
  background: #FFFFFF; border: 1.5px solid var(--ink); border-radius: 3px;
  width: 100%;
}
.wl-form select { font-family: var(--hand); font-size: 15px; }
.wl-form button {
  height: 46px; font-family: var(--hand); font-size: 16px; font-weight: 700;
  color: var(--paper); background: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 3px; cursor: pointer;
}
.wl-form button:hover { background: #172745; }
.wl-form .fine { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); }
.wl-form .status { margin: 0; font-family: var(--scrawl); font-size: 19px; color: var(--red); min-height: 24px; }
.wl-form[data-done="1"] .hide-on-done { display: none; }

/* ---------- section heading ---------- */

.section-head {
  display: inline-block; margin: 46px 0 0;
  font-size: 30px; font-weight: 700;
  border-bottom: 2px solid var(--ink); padding-bottom: 2px;
}
.section-lead { margin: 10px 0 0; font-size: 17px; color: var(--ink-soft); font-style: italic; }

/* ---------- bundle grid ---------- */

.grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 24px;
}

.bcard {
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 18px;
  display: flex; flex-direction: column;
}
.bcard h3 { margin: 0 0 13px; font-size: 21px; font-weight: 700; line-height: 1.12; }
.bcard h3 a { text-decoration: none; }
.bcard .blurb { margin: 15px 0 0; font-size: 14px; font-style: italic; line-height: 1.42; color: var(--ink-soft); flex-grow: 1; }
.bcard .count { font-family: var(--scrawl); font-size: 17px; color: var(--red); }
.cta {
  display: inline-block; text-align: center;
  height: 40px; line-height: 37px; padding: 0 22px;
  font-size: 14.5px; font-weight: 600;
  color: var(--paper); background: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 3px;
  text-decoration: none;
}
.cta:hover { background: #172745; color: var(--paper); }
.bcard .cta { margin-top: 12px; display: block; padding: 0; }

/* ---------- books ---------- */

.shelf { margin: 0; }

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 72px);
  justify-content: space-between;
  gap: 12px 0;
}

/* two rows stay fully readable; a third only peeks out and fades */
.shelf-clip { position: relative; max-height: 290px; overflow: hidden; }
.shelf-clip.faded::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 78px;
  background: linear-gradient(to bottom,
    rgba(253,252,247,0) 0%,
    rgba(253,252,247,0.30) 40%,
    rgba(253,252,247,0.80) 78%,
    rgba(253,252,247,0.98) 100%);
  pointer-events: none;
}

.book {
  position: relative;
  border-radius: 1px 2px 2px 1px;
  /* the hairline keeps pale covers from dissolving into the paper */
  box-shadow: 0 0 0 1px rgba(36,54,94,0.28), 1px 2px 4px rgba(36,54,94,0.20);
  overflow: hidden;
}
.book .spine-edge { position: absolute; left: 0; top: 0; width: 6px; height: 100%; background: rgba(0,0,0,0.22); }
.book .cover-title {
  position: absolute; left: 12px; right: 7px; top: 12px; bottom: 20px;
  font-size: 9px; font-weight: 600; line-height: 1.22; color: #FFF;
  overflow: hidden; overflow-wrap: break-word; hyphens: auto;
}
.book .cover-rule { position: absolute; left: 12px; right: 7px; bottom: 11px; height: 1px; background: rgba(255,255,255,0.55); }
.book img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }

.shelf-grid .book { width: 72px; aspect-ratio: 1 / 1.414; }

/* a shelf page has room, so the covers are bigger and nothing is cut */
.bundle-shelf { max-width: 560px; }
.bundle-shelf .shelf-grid { grid-template-columns: repeat(auto-fill, 120px); gap: 16px 0; }
.bundle-shelf .shelf-grid .book { width: 120px; }
.bundle-shelf .book .cover-title { font-size: 12.5px; left: 16px; right: 10px; top: 16px; }

/* ---------- title list / library ---------- */

.titles { margin: 26px 0 0; padding: 0; list-style: none; max-width: 940px; }
.titles > li { border-top: 1px solid rgba(36,54,94,0.22); }
.titles > li:last-child { border-bottom: 1px solid rgba(36,54,94,0.22); }

.titles details > summary {
  cursor: pointer; list-style: none;
  padding: 12px 0;
  display: flex; align-items: center; gap: 14px;
}
.titles details > summary::-webkit-details-marker { display: none; }
.titles .t-thumb {
  width: 38px; height: 54px; flex: 0 0 auto;
  display: block; position: relative; align-self: center;
}
.titles .t-thumb .cover-title { font-size: 5.5px; left: 6px; right: 4px; top: 6px; bottom: 9px; line-height: 1.18; }
.titles .t-thumb .cover-rule { left: 6px; right: 4px; bottom: 5px; }
.titles .t-thumb .spine-edge { width: 4px; }

.detail .t-big {
  width: 104px; height: 147px; flex: 0 0 auto;
  display: block; position: relative; float: left; margin: 2px 22px 12px 0;
}
.detail .t-big .cover-title { font-size: 12px; left: 14px; right: 9px; top: 14px; bottom: 20px; }
.detail .t-big .cover-rule { left: 14px; right: 9px; bottom: 12px; }
.detail::after { content: ""; display: block; clear: both; }

.titles details > summary::before {
  content: "+"; font-size: 20px; font-weight: 700; color: var(--red);
  width: 16px; flex-shrink: 0; line-height: 1; align-self: center;
}
.titles details[open] > summary::before { content: "\2013"; }
.titles .t-name { font-size: 18px; font-weight: 600; flex: 0 1 44%; }
.titles .t-sub { font-size: 15px; color: var(--ink-soft); font-style: italic; flex: 1 1 auto; }
.titles .t-meta { font-family: var(--scrawl); font-size: 21px; font-weight: 600; color: var(--red);
  white-space: nowrap; flex: 0 0 auto; min-width: 46px; text-align: right; }

.detail { padding: 2px 0 20px 30px; max-width: 760px; }
.detail p { margin: 0 0 12px; font-size: 16.5px; line-height: 1.55; }
.detail .who { color: var(--ink-soft); font-style: italic; }
.detail ul { margin: 0 0 12px; padding-left: 20px; }
.detail li { font-size: 15.5px; line-height: 1.5; margin-bottom: 3px; color: var(--ink-soft); }
.detail .facts { font-family: var(--scrawl); font-size: 18px; color: var(--red); }
.detail .facts a { color: var(--red); }

/* ---------- look inside ---------- */

.peek { margin: 4px 0 6px; }
.peek-h { margin: 0 0 9px; font-family: var(--scrawl); font-size: 18px; color: var(--red); }
.peek-row {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin;
}
.peek-t {
  flex: 0 0 auto; padding: 0; cursor: pointer; background: #FFF;
  width: 112px; height: 158px;
  border: 1px solid var(--ink); border-radius: 2px; overflow: hidden;
  box-shadow: 1px 2px 3px rgba(36,54,94,0.16);
}
.peek-t img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.peek-t:hover { border-color: var(--red); }

#lb {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,28,48,0.88);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
#lb[data-open="1"] { display: flex; }
#lb img { max-width: min(900px, 94vw); max-height: 92vh; width: auto; height: auto;
  border-radius: 3px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); background: #FFF; }
#lb .lb-close {
  position: absolute; top: 16px; right: 18px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper); border: 1.5px solid var(--ink);
  font-family: var(--hand); font-size: 20px; font-weight: 700; color: var(--ink);
  cursor: pointer; line-height: 1;
}

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

.foot {
  margin-top: 64px; padding: 14px 0 40px;
  border-top: 1.5px solid var(--ink);
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
}
.foot .name { font-size: 17px; font-weight: 600; }
.foot .spacer { flex-grow: 1; }
.foot a { font-size: 15px; text-decoration: none; }

/* ---------- narrow screens ---------- */

@media (max-width: 900px) {
  :root { --margin-w: 30px; --gutter: 14px; --line: 30px; }
  .sheet { padding-right: 14px; }
  .inner { padding-left: 14px; }
  .masthead { padding-top: 16px; }
  .masthead h1, .masthead .wordmark { font-size: 26px; }
  .margin-nav { gap: 14px; }
  .margin-nav a { font-size: 13.5px; }
  /* No phone has a margin wide enough to read in, so the note steps out to
     the rule and carries a tick of its own: still clearly an aside, never
     mistaken for a heading. */
  .mnote {
    margin: 14px 0 14px calc(-1 * var(--gutter) + 4px);
    padding-left: 11px;
    border-left: 2px solid var(--red);
  }
  .mnote .label {
    display: block; font-size: 14px; font-weight: 600; color: var(--red);
    transform: none; margin: 0 0 2px;
    letter-spacing: 0.02em; text-transform: lowercase;
  }
  .mnote.b .label { transform: none; }
  .mnote .scrawl { font-size: 15px; margin-top: 0; transform: rotate(-0.6deg); }
  .mnote.b .scrawl { transform: rotate(0.6deg); }
  .hero { gap: 12px; margin-top: 20px; }
  .hero h2 { font-size: 20px; }
  .hero p { font-size: 14.5px; }
  .page-title { font-size: 23px; margin-top: 26px; }
  .page-sub { font-size: 15px; }
  .crumb { font-size: 14px; }
  .offer { padding: 14px; gap: 14px; margin-top: 24px; }
  .offer h2 { font-size: 19px; }
  .offer p { font-size: 14px; }
  .price { font-size: 27px; }
  .price-was { font-size: 15px; }
  .price-note { font-size: 16px; }
  .wl-form { flex: 1 1 100%; }
  .wl-form label, .wl-form .fine { font-size: 12.5px; }
  .section-head { font-size: 20px; margin-top: 30px; }
  .section-lead { font-size: 14.5px; }

  /* two shelves side by side: a phone fits them and the page stops crawling */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
  .bcard { padding: 12px; }
  .bcard h3 { font-size: 16px; margin-bottom: 9px; }
  .bcard .blurb { font-size: 12.5px; margin-top: 10px; }
  .bcard .count { font-size: 14px; }
  .bcard .price { font-size: 19px; }
  .bcard .price-was { font-size: 13px; }
  .bcard .cta { font-size: 13px; height: 38px; line-height: 35px; }

  .shelf-grid { grid-template-columns: repeat(auto-fill, 56px); gap: 8px 0; }
  .shelf-grid .book { width: 56px; }
  .shelf-clip { max-height: 290px; }   /* three rows stay whole; a fourth peeks */
  .shelf-clip.faded::after { height: 52px; }

  .bundle-shelf { max-width: none; }
  .bundle-shelf .shelf-grid { grid-template-columns: repeat(auto-fill, 86px); gap: 12px 0; }
  .bundle-shelf .shelf-grid .book { width: 86px; }
  .bundle-shelf .book .cover-title { font-size: 10px; left: 12px; right: 8px; top: 12px; }

  .titles .t-sub { display: none; }
  .titles .t-name { flex: 1 1 auto; font-size: 16px; }
  .titles .t-meta { font-size: 18px; }
  .titles .t-thumb { width: 32px; height: 46px; }
  .titles .t-thumb .cover-title { font-size: 5px; left: 5px; right: 3px; top: 5px; }
  .detail { padding-left: 16px; }
  .detail p { font-size: 15px; }
  .detail li { font-size: 14px; }
  .detail .t-big { width: 78px; height: 110px; margin-right: 14px; }
  .detail .t-big .cover-title { font-size: 9px; left: 10px; right: 7px; top: 10px; }
  .peek-t { width: 88px; height: 124px; }
  .peek-h { font-size: 15.5px; }
  .foot { margin-top: 36px; }
}

@media (max-width: 420px) {
  .book.up .cover-title { font-size: 8px; left: 10px; right: 6px; top: 9px; }
}

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