/* ============================================================
   Never Lose the Plot
   Direction: Index. A reference book that happens to be a website.
   One serif for reading, one mono for structure, real rules,
   numbered sections, notes in the margin. One thing moves.
   ============================================================ */

:root {
  --ground:      #0f0f11;
  --ground-soft: #16161a;
  --bone:        #ece7dd;
  --bone-dim:    #9c978e;
  --rule:        #2b2b31;
  --thread:      #9bb7c4;

  --serif: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;
  --gutter:  clamp(1.25rem, 5vw, 4rem);
  --margin-col: 12rem;
}

/* The site is dark by intent, not by preference. A light mode would be a
   different design, so we do not fake one. We do respect contrast needs. */
@media (prefers-contrast: more) {
  :root { --bone-dim: #cdc8bf; --rule: #4a4a52; }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--bone);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.1875rem);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---------- structure ---------- */

.page {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 6rem;
  position: relative;
}

/* The thread lives in the left margin on wide screens and is hidden on
   narrow ones, where there is no margin to live in. */
.thread {
  position: fixed;
  top: 0;
  left: max(1rem, calc(50vw - 33rem));
  width: 3rem;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}
.thread path {
  fill: none;
  stroke: var(--thread);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
@media (max-width: 68rem) { .thread { display: none; } }

.content { position: relative; z-index: 1; }

/* ---------- type ---------- */

h1, h2, h3 { font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; }

h1 {
  font-size: clamp(2.5rem, 1.6rem + 4vw, 4.25rem);
  margin: 0 0 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

h3 { font-size: 1.15rem; margin: 2rem 0 0.5rem; }

p { margin: 0 0 1.15rem; max-width: var(--measure); }

a { color: var(--bone); text-decoration-color: var(--thread); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 600; }

.lede {
  font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);
  line-height: 1.5;
  color: var(--bone);
  max-width: 30rem;
}

.eyebrow,
.section-no,
.mono { font-family: var(--mono); }

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin: 0 0 1.5rem;
}

/* ---------- numbered sections, the spine of the Index direction ---------- */

.section {
  padding: 4.5rem 0 0;
  border-top: 1px solid var(--rule);
  margin-top: 4.5rem;
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  gap: 0 2.5rem;
  align-items: start;
}
.section:first-of-type { border-top: 0; margin-top: 0; }

.section-head { position: sticky; top: 2.5rem; }

.section-no {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  color: var(--bone-dim);
  display: block;
  margin-bottom: 0.4rem;
}

.section-body > :last-child { margin-bottom: 0; }

@media (max-width: 52rem) {
  .section { grid-template-columns: 1fr; gap: 0; padding-top: 3rem; margin-top: 3rem; }
  .section-head { position: static; margin-bottom: 1rem; }
}

/* ---------- margin notes ---------- */

.note {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--bone-dim);
  border-left: 1px solid var(--rule);
  padding-left: 0.9rem;
  margin: 1.75rem 0;
  max-width: 24rem;
}

/* ---------- the plates: how unmade art is shown ---------- *
   A reference book shows a plate that has not arrived as a labelled frame,
   not as a hole. These placeholders are meant to look deliberate, because
   they are: the frame is the spec, and the real piece drops straight in. */

.plate { margin: 2.5rem 0; max-width: 100%; }

.plate img,
.plate svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--ground-soft);
}

.plate figcaption {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.plate--mark { max-width: 7rem; margin: 0 0 2rem; }
.plate--card { max-width: 32rem; }

/* ---------- the offer ---------- */

.offer {
  border: 1px solid var(--rule);
  padding: 2rem;
  margin: 2.5rem 0 0;
  max-width: 30rem;
  background: var(--ground-soft);
}

.price {
  font-family: var(--mono);
  font-size: 2rem;
  display: block;
  margin-bottom: 0.15rem;
}

.price-note { font-family: var(--mono); font-size: 0.78rem; color: var(--bone-dim); margin: 0 0 1.5rem; }

/* The assurance sits directly above the button, because that is the last
   thing read before the decision. It is the opposite of urgency: it takes
   pressure off rather than manufacturing it. */
.assurance {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--bone);
  margin: 0 0 1rem;
}

.button {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bone);
  color: var(--ground);
  padding: 0.95rem 1.75rem;
  border: 1px solid var(--bone);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: transparent; color: var(--bone); }
.button:focus-visible { outline: 2px solid var(--thread); outline-offset: 3px; }

/* ---------- lists set as a reference book sets them ---------- */

.list { list-style: none; padding: 0; margin: 0 0 1.5rem; max-width: var(--measure); }
.list li {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  gap: 0 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.list li:first-child { border-top: 1px solid var(--rule); }
.list .n { font-family: var(--mono); font-size: 0.78rem; color: var(--bone-dim); padding-top: 0.35em; }

/* ---------- the numbered card ---------- */

.card {
  border: 1px solid var(--rule);
  background: var(--ground-soft);
  padding: 2.5rem;
  max-width: 30rem;
  margin: 2rem 0;
}
.card-number {
  font-family: var(--mono);
  font-size: clamp(2.5rem, 2rem + 3vw, 4rem);
  letter-spacing: 0.04em;
  display: block;
  line-height: 1;
}
.card-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  display: block;
  margin-bottom: 0.75rem;
}

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

.field { max-width: 24rem; margin: 0 0 1.25rem; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 0.4rem;
}
.field input {
  width: 100%;
  font: inherit;
  color: var(--bone);
  background: var(--ground-soft);
  border: 1px solid var(--rule);
  padding: 0.75rem 0.85rem;
}
.field input:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }

/* ---------- header and footer ---------- */

.masthead { padding: 3.5rem 0 0; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.masthead .wordmark { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none; color: var(--bone); }
.masthead nav { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.08em; }
.masthead nav a { color: var(--bone-dim); text-decoration: none; margin-left: 1.25rem; }
.masthead nav a:hover { color: var(--bone); }

.colophon {
  border-top: 1px solid var(--rule);
  margin-top: 5rem;
  padding-top: 2rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--bone-dim);
}
.colophon a { color: var(--bone-dim); }
.colophon p { max-width: 36rem; }

.skip {
  position: absolute; left: -9999px;
  background: var(--bone); color: var(--ground); padding: 0.75rem 1rem; font-family: var(--mono); font-size: 0.8rem;
}
.skip:focus { left: var(--gutter); top: 0.5rem; z-index: 10; }

/* ---------- the sample block in the memory section ---------- */

.sample {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--bone);
  background: var(--ground-soft);
  border-left: 1px solid var(--thread);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  max-width: var(--measure);
  overflow-x: auto;
  white-space: pre;
}

/* ---------- the door offer ---------- *
   In the page, never over it. It is offered where someone is already reading
   about the price, and it can be walked past without a click. Nothing here
   appears on its own, covers anything, or waits for an exit. */

.door {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--thread);
  padding: 1.5rem;
  margin: 2.5rem 0 0;
  max-width: 30rem;
}

.door-head {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin: 0 0 0.6rem;
}

.door p { font-size: 0.95rem; }

.door-form { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.15rem 0 1rem; }

.door-form input {
  flex: 1 1 13rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--bone);
  background: var(--ground);
  border: 1px solid var(--rule);
  padding: 0.75rem 0.85rem;
}
.door-form input::placeholder { color: var(--bone-dim); }
.door-form input:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }
.door-form .button { flex: 0 0 auto; }

.door-fine { font-size: 0.72rem; line-height: 1.6; color: var(--bone-dim); margin: 0; }

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

/* ---------- the story ---------- *
   A long, calm read. No section numbers: this is the one page on the site
   that is not a reference work, and numbering it would make it clinical. */

.story { max-width: 34rem; }

.story h1 { margin-bottom: 2.5rem; }

.story .chapter {
  padding-top: 2.75rem;
  margin-top: 2.75rem;
  border-top: 1px solid var(--rule);
}
.story .chapter:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }

.story h2 { margin-bottom: 1.25rem; }

.story p { font-size: 1.05em; line-height: 1.7; }

.story .promise {
  border-left: 2px solid var(--thread);
  padding-left: 1.15rem;
  font-size: 1.1em;
}

/* The button after every chapter, so it is reachable wherever someone stops. */
.story .buy { margin: 2rem 0 0; }

/* ---------- the sticky buy bar ---------- *
   Phones only, where the in-copy buttons can be a long scroll apart. It does
   not appear over anything on a wide screen, and the body reserves room for it
   so it never covers the last line of the page. */

.sticky-buy { display: none; }

@media (max-width: 52rem) {
  .sticky-buy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 0.75rem var(--gutter);
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--ground-soft);
    border-top: 1px solid var(--rule);
  }
  .sticky-buy .button { padding: 0.75rem 1.25rem; font-size: 0.8rem; }
  .sticky-price { font-size: 0.85rem; color: var(--bone-dim); }

  body.has-sticky-buy .page { padding-bottom: 8rem; }
}

/* Someone who cannot see a fixed bar still gets every in-copy button, so
   nothing is only reachable through the sticky one. */

/* Checkout: the country question (js/buy.js). Hidden until the switch is live. */
.country-gate { margin-top: 1rem; }
.country-q { margin: 0 0 0.9rem; }
.country-choices { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.button-quiet { background: transparent; color: var(--bone); }
.button[disabled] { opacity: 0.55; cursor: progress; }
.country-status { min-height: 1.4em; margin: 0.9rem 0 0; font-size: 0.95rem; }
.country-refusal { margin-top: 1rem; }
.country-refusal p { margin: 0 0 0.6rem; }
.tagline { margin: 1.1rem 0 0.9rem; font-style: italic; }
