/* Andrei Media — reader library
   One memorable thing: the shelf. Everything else stays quiet. */

@font-face {
  font-family: "Literata";
  src: url("/assets/fonts/literata.woff2") format("woff2-variations");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("/assets/fonts/literata-italic.woff2") format("woff2-variations");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/fonts/instrument-sans.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #eceee9;
  --paper-deep: #e1e4dd;
  --card: #f6f7f3;
  --ink: #15181b;
  --ink-2: #4f575e;
  --ink-3: #737c82;
  --rule: #c8cdc5;
  --shelf: #2a2e31;
  --shelf-top: #3b4044;
  --foil: #9c7737;
  --ok: #2f5d46;
  --danger: #9a2f2a;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.125rem;
  --step-1: 1.375rem;
  --step-2: 1.75rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.5rem, 5.6vw, 4.75rem);

  --wrap: 1160px;
  --gutter: clamp(20px, 5vw, 56px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131517;
    --paper-deep: #191c1f;
    --card: #1b1e21;
    --ink: #e8eae5;
    --ink-2: #a8afb3;
    --ink-3: #80888d;
    --rule: #2f3438;
    --shelf: #3a3f43;
    --shelf-top: #4b5156;
    --foil: #cfa968;
    --ok: #7fb79a;
    --danger: #e08a80;
    color-scheme: dark;
  }
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--ink); color: var(--paper); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 14px; z-index: 10; font-family: var(--sans); }
.skip:focus { left: 8px; }

/* ---------- header / footer ---------- */
.site-head { padding-block: 28px; }
.site-head .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; }
.wordmark { font-family: var(--serif); font-size: 1.3125rem; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; font-variation-settings: "opsz" 36; }
.site-nav { display: flex; gap: 26px; font-family: var(--sans); font-size: var(--step--1); font-weight: 500; }
.site-nav a { text-decoration: none; color: var(--ink-2); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

.site-foot { margin-top: clamp(72px, 12vw, 140px); border-top: 1px solid var(--rule); padding-block: 36px 48px; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-2); }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 22px; }
.site-foot a { color: var(--ink-2); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- hub: hero ---------- */
.hero { padding-top: clamp(32px, 7vw, 88px); display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(40px, 6vw, 88px); align-items: end; }
.hero-wide { grid-template-columns: 1fr; }
.hero h1 {
  font-size: var(--step-4);
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72;
  margin: 0;
  max-width: 15ch;
  text-wrap: balance;
}
.hero-copy p { max-width: 36em; margin: 28px 0 0; color: var(--ink-2); font-size: var(--step-1); line-height: 1.55; font-variation-settings: "opsz" 18; }

/* ---------- the shelf ---------- */
.shelf-wrap { min-width: 0; }
.shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 420px;
  padding: 48px 6px 0;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.shelf::after { content: ""; flex: 0 0 8px; }
.board {
  height: 16px;
  background: var(--shelf);
  border-top: 2px solid var(--shelf-top);
  border-radius: 1px;
  box-shadow: 0 14px 22px -16px rgba(0,0,0,.55);
}
.bookend {
  flex: 0 0 auto;
  width: 22px;
  height: 120px;
  margin-left: 18px;
  background: var(--shelf);
  border-radius: 3px 3px 0 0;
  opacity: .9;
}

.spine {
  --w: calc(var(--pages) * 0.13px + 26px);
  position: relative;
  flex: 0 0 auto;
  width: var(--w);
  height: calc(var(--h) * 360px);
  background-color: var(--cloth);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.16) 0, rgba(255,255,255,.04) 14%, rgba(0,0,0,0) 46%, rgba(0,0,0,.08) 78%, rgba(0,0,0,.26) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, rgba(0,0,0,.02) 1px 3px);
  color: var(--spine-ink);
  border-radius: 3px 3px 1px 1px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), 0 2px 0 rgba(0,0,0,.3);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 14px;
  transform-origin: 50% 100%;
  transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s;
  view-transition-name: var(--vt);
}
.spine::before, .spine::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px;
  height: 1px;
  background: currentColor;
  opacity: .55;
}
.spine::before { top: 10px; box-shadow: 0 4px 0 currentColor; }
.spine::after { bottom: 44px; }
.spine .t {
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  line-height: 1;
  margin-top: 14px;
  font-variation-settings: "opsz" 24;
  white-space: nowrap;
}
.spine .a {
  writing-mode: vertical-rl;
  margin-top: auto;
  margin-bottom: 18px;
  font-family: var(--sans);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .85;
}
.spine .mark {
  position: absolute;
  bottom: 14px;
  font-family: var(--serif);
  font-style: italic;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1;
}
/* a ribbon bookmark means: this book has a reader vault */
.spine .ribbon {
  position: absolute;
  top: -1px;
  right: 9px;
  width: 9px;
  height: 46px;
  background: var(--foil);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  transform: translateY(-62%);
  transition: transform .28s cubic-bezier(.2,.7,.2,1);
}
.spine:hover, .spine:focus-visible { transform: translateY(-16px); box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), 0 18px 24px -14px rgba(0,0,0,.5); }
.spine:focus-visible { outline-offset: 4px; }
.spine.is-pulled { transform: translateY(-40px) scale(1.03); }
.spine.is-hidden { display: none; }

.shelf-note { margin: 16px 0 0; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-3); display: flex; align-items: center; gap: 10px; }
.shelf-note i { display: inline-block; width: 8px; height: 18px; background: var(--foil); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); }

/* ---------- hub: index ---------- */
.index { margin-top: clamp(64px, 10vw, 120px); display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 32px clamp(32px, 6vw, 80px); align-items: start; }
.index h2, .about h2 { font-size: var(--step-2); font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; margin: 0; font-variation-settings: "opsz" 36; }
.index .intro p { color: var(--ink-2); margin: 14px 0 0; max-width: 28em; }
.search { margin-top: 26px; position: relative; }
.search label { display: block; font-family: var(--sans); font-size: var(--step--1); font-weight: 600; margin-bottom: 8px; }
.input {
  width: 100%;
  font: 500 1.0625rem/1.2 var(--sans);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 14%, transparent); }

.booklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.booklist li { border-bottom: 1px solid var(--rule); }
.booklist a.row { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 20px; align-items: center; padding: 20px 4px; text-decoration: none; }
.booklist a.row:hover .row-title { text-decoration: underline; text-decoration-thickness: 1px; }
.swatch { width: 46px; height: 62px; border-radius: 2px 4px 4px 2px; background: var(--cloth); box-shadow: inset 4px 0 0 rgba(0,0,0,.22), inset 0 0 0 1px rgba(0,0,0,.18); position: relative; }
.swatch.has-vault::after { content: ""; position: absolute; top: 0; right: 8px; width: 6px; height: 18px; background: var(--foil); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.row-title { font-size: var(--step-1); font-weight: 560; line-height: 1.25; font-variation-settings: "opsz" 28; display: block; }
.row-blurb { color: var(--ink-2); font-size: 1rem; line-height: 1.5; display: block; margin-top: 4px; }
.row-meta { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-3); display: block; margin-top: 6px; }
.row-go { font-family: var(--sans); font-size: var(--step--1); font-weight: 600; white-space: nowrap; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--rule); }
.row-go.vault { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.booklist .empty { padding: 28px 4px; color: var(--ink-2); }

.about { margin-top: clamp(80px, 12vw, 140px); display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 24px clamp(32px, 6vw, 80px); }
.about p { margin: 0 0 1em; max-width: 34em; }
.about p:last-child { margin-bottom: 0; }

/* ---------- book page ---------- */
.back { font-family: var(--sans); font-size: var(--step--1); font-weight: 600; text-decoration: none; color: var(--ink-2); display: inline-flex; gap: 8px; align-items: center; padding: 6px 0; }
.back:hover { color: var(--ink); }
.back svg { width: 16px; height: 16px; }

.book { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(40px, 7vw, 96px); margin-top: clamp(24px, 4vw, 44px); align-items: start; }
.book-art { position: sticky; top: 32px; padding: 12px 0 40px; perspective: 1400px; }
.object {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 6 / 9;
  margin-inline: auto;
  transform: rotateY(-16deg);
  transform-style: preserve-3d;
  view-transition-name: var(--vt);
}
.object .face {
  position: absolute; inset: 0;
  background-color: var(--cloth);
  background-image: linear-gradient(90deg, rgba(0,0,0,.18) 0, rgba(255,255,255,.06) 3%, rgba(255,255,255,0) 9%, rgba(0,0,0,0) 80%, rgba(0,0,0,.12) 100%);
  color: var(--spine-ink);
  border-radius: 2px 5px 5px 2px;
  box-shadow: 0 30px 60px -28px rgba(0,0,0,.55), 0 10px 18px -10px rgba(0,0,0,.35);
  padding: 13% 11% 10% 14%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.object .face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.object .edge {
  position: absolute; top: 1.2%; bottom: 1.2%; right: -14px; width: 14px;
  background: repeating-linear-gradient(90deg, #f3f0e6 0 1px, #dcd8cc 1px 2px);
  transform: rotateY(90deg) translateZ(-7px);
  transform-origin: left center;
  border-radius: 0 2px 2px 0;
}
.cover-series { font-family: var(--sans); font-size: clamp(.625rem, 1.4vw, .75rem); font-weight: 600; letter-spacing: .03em; opacity: .85; }
.cover-rule { height: 1px; background: currentColor; opacity: .55; margin: 14px 0 0; }
.cover-title { margin-top: auto; font-family: var(--serif); font-weight: 600; font-size: clamp(1.75rem, 3.6vw, 2.75rem); line-height: 1.02; letter-spacing: -0.01em; font-variation-settings: "opsz" 60; }
.cover-author { margin-top: 18px; font-family: var(--sans); font-weight: 600; font-size: clamp(.6875rem, 1.4vw, .8125rem); letter-spacing: .04em; opacity: .9; }
.object-shadow { width: 70%; height: 26px; margin: 26px auto 0; background: radial-gradient(closest-side, rgba(0,0,0,.28), transparent); filter: blur(4px); }

.book-copy .series-line { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-3); margin: 6px 0 0; }
.book-copy h1 { font-size: clamp(2.25rem, 4.6vw, 3.75rem); font-weight: 560; line-height: 1.04; letter-spacing: -0.02em; margin: 10px 0 0; font-variation-settings: "opsz" 72; text-wrap: balance; }
.book-copy .sub { color: var(--ink-2); font-size: var(--step-1); line-height: 1.5; margin: 20px 0 0; max-width: 32em; font-variation-settings: "opsz" 18; }

.vault { margin-top: clamp(48px, 7vw, 72px); }
.vault h2 { font-size: var(--step-2); font-weight: 560; line-height: 1.15; margin: 0; letter-spacing: -0.01em; font-variation-settings: "opsz" 36; }
.vault > p { color: var(--ink-2); margin: 12px 0 0; max-width: 34em; }
.contents { margin: 28px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.contents li { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.contents .n { font-size: var(--step-2); font-weight: 450; line-height: 1; font-variant-numeric: lining-nums tabular-nums; font-variation-settings: "opsz" 48; color: var(--ink); }
.contents .k { font-weight: 600; font-size: 1.0625rem; }
.contents .d { display: block; color: var(--ink-2); font-size: 1rem; line-height: 1.5; margin-top: 2px; }

/* the bookplate: where the reader unlocks the vault */
.plate {
  margin-top: clamp(32px, 5vw, 48px);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: clamp(24px, 4vw, 40px);
  position: relative;
}
.plate::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--rule); border-radius: 6px; pointer-events: none;
}
.plate h2 { margin: 0; font-size: var(--step-2); font-weight: 560; line-height: 1.15; letter-spacing: -0.01em; font-variation-settings: "opsz" 36; }
.plate .plate-lede { margin: 10px 0 0; color: var(--ink-2); max-width: 32em; }
.steps { list-style: none; margin: 28px 0 0; padding: 0; counter-reset: step; }
.step { position: relative; padding: 0 0 0 52px; counter-increment: step; }
.step + .step { margin-top: 26px; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 .875rem/1 var(--sans);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: var(--paper);
}
.step.is-active::before { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.step.is-done::before { content: ""; background: var(--ok); border-color: var(--ok); }
.step.is-done::after { content: ""; position: absolute; left: 11px; top: 9px; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg); }
.step h3 { margin: 0; padding-top: 5px; font-family: var(--sans); font-size: 1rem; font-weight: 650; line-height: 1.375; }
.step.is-locked h3 { color: var(--ink-3); }
.step .hint { margin: 2px 0 0; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-2); line-height: 1.5; }
.step .body { margin-top: 14px; }
.step.is-locked .body, .step.is-done .body { display: none; }
.step .done-note { display: none; margin: 2px 0 0; font-family: var(--sans); font-size: var(--step--1); color: var(--ok); font-weight: 600; }
.step.is-done .done-note { display: block; }

.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row .input { flex: 1 1 240px; }
.input.code { font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.btn {
  flex: 0 0 auto;
  font: 650 1rem/1 var(--sans);
  padding: 15px 22px;
  border-radius: 6px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.msg { margin: 10px 0 0; font-family: var(--sans); font-size: var(--step--1); line-height: 1.5; min-height: 1.5em; }
.msg.err { color: var(--danger); font-weight: 600; }
.consent { margin: 12px 0 0; font-family: var(--sans); font-size: .8125rem; color: var(--ink-3); line-height: 1.55; max-width: 36em; }
.consent a { color: var(--ink-2); }

.sent { display: none; margin-top: 14px; }
.step.is-active .sent.on { display: block; }
.seal {
  width: 76px; height: 76px; color: var(--foil);
  animation: press .5s cubic-bezier(.2,.9,.3,1.2) both;
}
.sent p { margin: 14px 0 0; max-width: 32em; }
.sent .small { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-2); }
@keyframes press { from { transform: scale(1.35) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

.buy { margin-top: 28px; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-2); }

/* the welcome plate: where a confirmed reader picks up the files */
.welcome .seal { display: block; margin-bottom: 18px; }
.dl-row { margin: 22px 0 0; }
.dl-row .btn { display: inline-block; text-decoration: none; }
.quick-title { margin: 36px 0 0; padding-top: 28px; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 1rem; font-weight: 650; }
.steps.quick { margin-top: 18px; }
.steps.quick .step::before { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- text pages ---------- */
.prose { max-width: 40em; margin-top: clamp(32px, 6vw, 64px); }
.prose h1 { font-size: clamp(2rem, 4.2vw, 3rem); font-weight: 560; line-height: 1.08; letter-spacing: -0.015em; margin: 0 0 24px; font-variation-settings: "opsz" 60; }
.prose h2 { font-size: var(--step-1); font-weight: 600; margin: 40px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose .fill { background: color-mix(in srgb, var(--foil) 22%, transparent); color: var(--ink); padding: 0 4px; border-radius: 3px; }

.notfound { margin-top: clamp(48px, 10vw, 120px); max-width: 32em; }
.notfound h1 { font-size: var(--step-3); font-weight: 560; margin: 0; line-height: 1.1; }
.notfound p { color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .index, .about, .hero { grid-template-columns: 1fr; }
  .book { grid-template-columns: 1fr; }
  .book-art { position: static; padding-bottom: 8px; }
  .object { width: min(44vw, 210px); }
  .book { gap: 28px; }
  .shelf { min-height: 340px; }
  .spine { height: calc(var(--h) * 290px); }
  .spine .t { font-size: .875rem; }
  .spine .a { display: none; }
}
@media (max-width: 520px) {
  .site-nav { gap: 18px; }
  .booklist a.row { grid-template-columns: 38px minmax(0,1fr); }
  .booklist .row-go { grid-column: 2; justify-self: start; margin-top: 4px; }
  .swatch { width: 38px; height: 52px; }
  .field-row .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  @view-transition { navigation: none; }
}
