/* ============================================================
   Dark, quiet, precise. Hairlines instead of borders, one accent,
   a strict radius scale (md 6 / lg 8 / xl 12) and nothing louder
   than the book covers.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #09090a;
  --surface:   #101012;
  --raised:    #151517;
  --line:      rgba(255, 255, 255, 0.07);
  --line-firm: rgba(255, 255, 255, 0.12);
  --fg:        #ededef;
  --fg-dim:    #a1a1a8;
  --fg-faint:  #6b6b73;
  --accent:    #e9b872;

  --r-md: 0.375rem;
  --r-lg: 0.5rem;
  --r-xl: 0.75rem;

  --sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.65;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

/* one fixed grain sheet — never attached to scrolling content */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-md); }
::selection { background: rgba(233, 184, 114, 0.22); }

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.035em; line-height: 1.05; text-wrap: balance; }

.mono {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

.sub { margin: 0; color: var(--fg-dim); font-size: 1.0625rem; line-height: 1.6; max-width: 46ch; }
.prose { margin: 0; color: var(--fg-dim); line-height: 1.75; max-width: 62ch; white-space: pre-line; }

/* ---------- chrome ---------- */

.shell { max-width: 72rem; margin: 0 auto; padding-inline: var(--gutter); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.nav__brand { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.02em; }
.nav__brand span { color: var(--fg-faint); font-weight: 400; }

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(3.5rem, 7vw, 5.5rem);
  padding-block: 1.75rem 3rem;
  border-top: 1px solid var(--line);
}

/* ---------- atoms ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.tag::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--accent);
}
.tag--plain::before { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  height: 2.5rem;
  padding: 0 0.3125rem 0 0.875rem;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--fg);
  color: #09090a;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.45s var(--ease), background-color 0.45s var(--ease), color 0.45s var(--ease);
}
.btn:hover { background: #fff; }
.btn:active { transform: scale(0.985); }

.btn__well {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--r-md);
  background: rgba(9, 9, 10, 0.1);
  transition: transform 0.45s var(--ease), background-color 0.45s var(--ease);
}
.btn__well svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.btn:hover .btn__well { transform: translate(2px, -1px); background: rgba(9, 9, 10, 0.16); }

.btn--ghost {
  background: var(--surface);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn--ghost:hover { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-firm); }
.btn--ghost .btn__well { background: rgba(255, 255, 255, 0.06); }
.btn--ghost:hover .btn__well { background: rgba(255, 255, 255, 0.1); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  font-size: 0.8125rem;
  color: var(--fg-faint);
  transition: color 0.4s var(--ease);
}
.back:hover { color: var(--fg); }

/* ---------- covers ---------- */

.cover {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 3 / 4;
  padding: 1.125rem;
  overflow: hidden;
  border-radius: var(--r-lg);
  background:
    linear-gradient(152deg, color-mix(in oklab, var(--tint, #3a3a42) 58%, #141417) 0%, #101013 64%, #0c0c0e 100%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover__no { position: relative; }
.cover__title {
  position: relative;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.2;
  text-wrap: balance;
}

/* ---------- lead title ---------- */

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
  gap: clamp(2.5rem, 6vw, 5.5rem);
  align-items: center;
  padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3.5rem, 7vw, 6rem);
}
.feature h1 {
  margin-block: 1.375rem 0.75rem;
  font-size: clamp(3rem, 1.4rem + 5.6vw, 5.75rem);
  font-weight: 500;
  letter-spacing: -0.05em;
}
.feature__sub { margin: 0; color: var(--fg-dim); font-size: 1.0625rem; max-width: 34ch; }
.feature__hook {
  margin: 1.875rem 0 0;
  max-width: 26ch;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  line-height: 1.45;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.feature .facts { margin: 1.625rem 0 0; }
.feature__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.25rem; margin-top: 2.25rem; }

/* the art sits in its own tray, lit from behind */
.feature__art { position: relative; display: block; justify-self: end; width: min(100%, 25rem); }
.feature__art::before {
  content: '';
  position: absolute;
  inset: -12% -14%;
  background: radial-gradient(52% 48% at 50% 46%, rgba(233, 184, 114, 0.14), transparent 72%);
  pointer-events: none;
}
.feature__frame {
  position: relative;
  display: block;
  padding: 0.375rem;
  border-radius: calc(var(--r-xl) + 0.375rem);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), 0 40px 80px -44px rgba(0, 0, 0, 0.95);
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
}
.feature__frame .cover { aspect-ratio: 2 / 3; border-radius: var(--r-xl); }
.feature__art:hover .feature__frame {
  transform: translateY(-4px);
  box-shadow: inset 0 0 0 1px var(--line-firm), 0 52px 92px -44px rgba(0, 0, 0, 1);
}

/* ---------- how it works ---------- */

.strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
  border-block: 1px solid var(--line);
}
.strip li {
  display: flex;
  gap: 0.75rem;
  padding: 1.75rem 1.75rem 1.75rem 0;
  max-width: 34ch;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--fg-dim);
}
.strip li + li { padding-left: 1.75rem; box-shadow: inset 1px 0 0 var(--line); }
.strip .mono { color: var(--accent); flex: none; padding-top: 0.2em; }

/* ---------- catalogue ---------- */

.more { padding-top: clamp(3.5rem, 7vw, 5.5rem); }
.more__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.card { display: flex; }

.card__link {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  padding: 0.25rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color 0.5s var(--ease), box-shadow 0.5s var(--ease), transform 0.5s var(--ease);
}
.card__link:hover { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-firm); transform: translateY(-2px); }

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem 0.875rem;
}
.card__body p { margin: 0; color: var(--fg-dim); font-size: 0.875rem; line-height: 1.5; }
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
}
.price {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

/* ---------- book ---------- */

.book {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-block: clamp(2.5rem, 5vw, 4rem) clamp(3rem, 6vw, 5rem);
}
.book h1 {
  margin-block: 1.125rem 1rem;
  font-size: clamp(2.25rem, 1.5rem + 2.6vw, 3.5rem);
  letter-spacing: -0.042em;
}
.facts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.75rem 0; }

.buy { position: sticky; top: 1.5rem; display: grid; gap: 0.75rem; }
.buy__card {
  padding: 0.25rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.buy__inner {
  padding: 1.25rem 1.125rem;
  border-radius: var(--r-lg);
  background: var(--raised);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.buy__price { font-size: 2rem; font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.buy__note { margin: 0.5rem 0 1.25rem; font-size: 0.8125rem; color: var(--fg-faint); }
.buy__status { margin: 0.875rem 0 0; font-size: 0.8125rem; color: var(--fg-dim); }
.buy__status:empty { display: none; }
#download { width: 100%; justify-content: space-between; margin-top: 0.75rem; }

.buy__list { display: grid; gap: 0.5rem; margin: 0; padding: 0 0.25rem; list-style: none; }
.buy__list li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--fg-faint); }
.buy__list svg { width: 12px; height: 12px; stroke: var(--accent); stroke-width: 1.5; fill: none; flex: none; }

.notice { margin: 0; font-size: 0.8125rem; color: var(--fg-dim); }
.notice code { font-family: var(--mono); font-size: 0.75rem; color: var(--fg); }

/* ---------- stats ---------- */

.page { padding-block: clamp(2.5rem, 6vw, 4.5rem) 0; }
.page h1 { margin-block: 1.25rem 1rem; font-size: clamp(2.25rem, 1.5rem + 2.2vw, 3rem); }
.page .sub code { font-family: var(--mono); font-size: 0.8125rem; color: var(--fg); }

.stats-wrap { margin-top: 2.5rem; overflow-x: auto; }
.stats { width: 100%; min-width: 34rem; border-collapse: collapse; }
.stats th, .stats td {
  padding: 0.875rem 0 0.875rem 1.25rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.stats th:first-child, .stats td:first-child { padding-left: 0; text-align: left; white-space: normal; }
.stats th {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.stats td { font-size: 0.9375rem; }
.stats td:first-child { font-weight: 500; }
.stats .num { font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.stats__when { color: var(--fg-faint); }
.stats tbody tr:last-child td { border-bottom: 0; }
.stats tfoot td { border-top: 1px solid var(--line-firm); border-bottom: 0; color: var(--fg-dim); }
.stats__note { display: block; margin-top: 1.5rem; }

/* ---------- reader ---------- */

.desk {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  padding: 0.25rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.desk__inner {
  overflow: hidden;
  border-radius: var(--r-lg);
  background: #0b0b0d;
  box-shadow: inset 0 0 0 1px var(--line);
}
.desk__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.125rem;
  border-bottom: 1px solid var(--line);
}
.desk__head h2 { font-size: 0.9375rem; font-weight: 500; letter-spacing: -0.02em; }
.desk__head p { margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--fg-faint); }

/* plain block stack: as a grid item the stage sized itself to epub.js's
   pixel-width container instead of to the column */
.reader { display: block; }

.reader__stage {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content; /* two pages sit like an open book */
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  min-width: 0; /* grid items default to min-width:auto and would burst the desk */
  min-height: min(74vh, 44rem);
  padding: clamp(1rem, 2.5vw, 2rem);
  background:
    radial-gradient(130% 80% at 50% 0%, rgba(255, 255, 255, 0.035) 0%, transparent 60%);
}
.reader__stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.95), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
/* epub paginates itself — it needs a plain block box, not a spread column */
.reader__stage--flow { display: block; }
.reader__epub {
  width: 100%;
  height: min(70vh, 42rem);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.95);
  overflow: hidden;
}

.reader__spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  animation: pulse 1.8s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.85; } }

.rail { position: relative; height: 1px; background: var(--line); }
.rail__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.6s var(--ease);
}

.reader__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--line);
}
.reader__group { display: flex; align-items: center; gap: 0.375rem; }

.pager {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.4s var(--ease), box-shadow 0.4s var(--ease), opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.pager svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.pager:hover:not(:disabled) { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-firm); }
.pager:active:not(:disabled) { transform: scale(0.94); }
.pager:disabled { opacity: 0.3; cursor: default; }

.reader__label {
  min-width: 8rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

.ghost {
  height: 2rem;
  padding-inline: 0.75rem;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-faint);
  font-family: var(--sans);
  font-size: 0.8125rem;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.4s var(--ease), background-color 0.4s var(--ease);
}
.ghost:hover { color: var(--fg); background: var(--surface); }

.desk:fullscreen { padding: 0; border-radius: 0; background: #0b0b0d; }
.desk:fullscreen .desk__inner { height: 100%; border-radius: 0; display: grid; grid-template-rows: auto 1fr auto auto; }
.desk:fullscreen .reader { display: grid; grid-template-rows: 1fr auto auto; height: 100%; min-height: 0; }
.desk:fullscreen .reader__stage { min-height: 0; height: 100%; }
.desk:fullscreen .reader__epub { height: 100%; }

/* ---------- entrances ---------- */

@media (prefers-reduced-motion: no-preference) {
  /* gated on .js so a failed script can never leave the page blank */
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(0.875rem);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
    transition-delay: var(--delay, 0ms);
  }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
}

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

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book { grid-template-columns: 1fr; }
  .buy { position: static; }

  /* art leads, then the words — the cover is the pitch on a phone */
  .feature { grid-template-columns: 1fr; gap: 2.5rem; padding-block: 2.5rem 3.5rem; }
  .feature__art { order: -1; justify-self: start; width: min(100%, 17rem); }
  .feature__hook, .feature__sub { max-width: none; }

  .strip { grid-template-columns: 1fr; }
  .strip li { max-width: none; padding: 1.25rem 0; }
  .strip li + li { padding-left: 0; box-shadow: inset 0 1px 0 var(--line); }
}

@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .cover { aspect-ratio: 16 / 10; }
  .feature__frame .cover { aspect-ratio: 2 / 3; }
  .nav .mono { display: none; } /* the strip says it better than a wrapped line */
  .desk__head .mono { display: none; } /* no keyboard to turn pages with */
  /* the bar wraps instead of dropping controls: label on its own line */
  .reader__bar { flex-wrap: wrap; row-gap: 0.5rem; }
  .reader__label { order: -1; flex: 1 0 100%; min-width: 0; text-align: left; }
  .ghost { padding-inline: 0.5rem; }
}
