/* Colour chapters: every section is one book's own palette, floor to ceiling. Colours come from the books' in-app palettes. */
@font-face {
  font-family: "Epilogue";
  src: url("/fonts/epilogue-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --m: clamp(16px, 2.2vw, 32px);
  --gap: var(--m);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-display: clamp(3.1rem, 8vw, 6rem);
  --t-h2: clamp(2.35rem, 4.6vw, 4.25rem);
  --t-lead: clamp(1.1875rem, 1.05rem + 0.55vw, 1.5rem);
  --t-body: 1.125rem;
  --t-small: 0.9375rem;
  --face: "Epilogue", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Chapters. --bg ground, --ink text, --btn button fill, --btn-ink its text. Book chapters set theirs inline from books.json. */
.night   { --bg: #15111c; --ink: #ece9e4; --btn: #e0a84a; --btn-ink: #1b1408; }
.bone    { --bg: #e8dcc8; --ink: #1a1410; --btn: #1a1410; --btn-ink: #f4eee3; }
.violet  { --bg: #2e1a47; --ink: #f1eef4; --btn: #a6e36e; --btn-ink: #120e1f; }
.ink     { --bg: #100e14; --ink: #ece9e4; --btn: #e0a84a; --btn-ink: #1b1408; }

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

html { scroll-behavior: smooth; background: #100e14; scrollbar-color: #e0a84a #100e14; }

body {
  margin: 0;
  font-family: var(--face);
  font-size: var(--t-body);
  line-height: 1.55;
  color: #efe7da;
  background: #100e14;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #e0a84a; color: #1b1408; }

img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p, blockquote { margin: 0; }
a { color: inherit; }

:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { padding-inline: max(var(--m), env(safe-area-inset-left, 0px)) max(var(--m), env(safe-area-inset-right, 0px)); }

/* A chapter is a full-bleed field in its own colour. No dividers: the hard edge is the look. */
.ch {
  background: var(--bg);
  color: var(--ink);
  padding-block: clamp(72px, 9vw, 144px);
}

h1, h2, h3 { font-weight: 900; letter-spacing: -0.04em; line-height: 0.92; text-wrap: balance; }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-lead); line-height: 1.05; letter-spacing: -0.03em; }

.lead { font-size: var(--t-lead); line-height: 1.38; max-width: 34ch; text-wrap: pretty; }

/* Buttons: flat, square, one shape on the whole page. */
.btn {
  display: inline-block;
  padding: 1rem 1.6rem;
  font: 800 var(--t-body)/1 var(--face);
  letter-spacing: -0.01em;
  color: var(--btn-ink);
  background: var(--btn);
  border: 0;
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms var(--ease), opacity 160ms;
}
.btn:hover { transform: translateY(-3px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.small { padding: 0.8rem 1.1rem; font-size: var(--t-small); }
.btn.quiet { color: var(--ink); background: transparent; padding: calc(1rem - 2px) calc(1.6rem - 2px); border: 2px solid currentColor; }
.btn.off { cursor: default; color: var(--ink); background: transparent; padding: calc(1rem - 2px) calc(1.6rem - 2px); border: 2px dashed currentColor; }
.btn.off:hover { transform: none; }
.note { font-size: var(--t-small); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }

/* ---------- Sticky bar: appears once the hero is gone, so the buy button is always one tap away ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 10px var(--m);
  background: var(--bg); color: var(--ink);
  transform: translateY(-100%); visibility: hidden;
  transition: transform 300ms var(--ease), visibility 0s linear 300ms;
}
.bar.on { transform: none; visibility: visible; transition: transform 300ms var(--ease); }
.bar nav { display: flex; gap: 28px; margin-inline: auto 0; }
.bar nav a { font-weight: 600; text-decoration: none; }
.bar nav a:hover, .bar nav a[aria-current] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.bar .mark { font-size: 1.25rem; }

/* ---------- Hero ---------- */
.hero { padding-block: 0 clamp(48px, 6vw, 96px); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-block: 24px;
}
.nav nav { display: flex; gap: clamp(20px, 3vw, 44px); margin-inline: auto 0; padding-right: clamp(16px, 3vw, 44px); }
.nav nav a { font-weight: 600; text-decoration: none; }
.nav nav a:hover { text-decoration: underline; text-underline-offset: 6px; }
.mark { font-weight: 900; letter-spacing: -0.04em; font-size: var(--t-lead); text-decoration: none; }

.hero-copy {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gap);
  align-items: end;
  padding-block: clamp(24px, 3.5vw, 56px) clamp(32px, 4vw, 56px);
}
.hero h1 { grid-column: 1 / 8; font-size: var(--t-display); line-height: 0.88; }
.hero h1 .line { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.hero h1 .line > span { display: block; animation: up 900ms var(--ease) both; }
.hero h1 .line:nth-child(2) > span { animation: up 900ms var(--ease) 110ms both, ink 14s ease-in-out 1.2s infinite; color: #e0a84a; }
.hero-side { grid-column: 9 / 13; display: grid; gap: 28px; justify-items: start; padding-bottom: 0.6rem; }
.hero-side .lead { max-width: 24ch; }

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(10rem, calc((100% - 3 * var(--gap)) / 4)), 1fr));
  gap: var(--gap);
  align-items: start;
}
.shelf li:nth-child(even) { margin-top: clamp(24px, 4vw, 64px); }
.shelf a { display: block; transition: transform 300ms var(--ease); }
.shelf a:hover { transform: translateY(-8px); }
.shelf img { width: 100%; animation: drift 9s ease-in-out infinite alternate; }
.shelf li:nth-child(3n+2) img { animation-delay: -3s; }
.shelf li:nth-child(3n) img { animation-delay: -6s; }

/* "color in." fills with each book's own hue in turn: the page does what the headline says. */
@keyframes ink {
  0%, 22% { color: #e0a84a; }
  28%, 47% { color: #d98a9c; }
  53%, 72% { color: #9cc3e0; }
  78%, 97% { color: #f28c28; }
  100% { color: #e0a84a; }
}
@keyframes up { from { transform: translateY(105%); } to { transform: none; } }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-8px); } }

/* ---------- Book chapters ---------- */
.book { min-height: min(92svh, 60rem); display: grid; align-items: center; }
.book-grid, .try-grid, .app-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gap);
  align-items: center;
}
.book .cover { grid-column: 1 / 7; display: block; rotate: -1.6deg; margin: 10px; transition: transform 350ms var(--ease), rotate 350ms var(--ease); }
.book.flip .cover { rotate: 1.6deg; }
.book .cover:hover { transform: translateY(-8px); rotate: 0deg; }
.book .cover img { width: 100%; }
.book .copy { grid-column: 8 / 13; display: grid; gap: clamp(20px, 2.4vw, 32px); justify-items: start; }
.book.flip .cover { grid-column: 7 / 13; grid-row: 1; }
.book.flip .copy { grid-column: 1 / 6; grid-row: 1; }

blockquote { font-size: var(--t-lead); line-height: 1.3; max-width: 28ch; font-weight: 500; }
blockquote footer { margin-top: 10px; font-size: var(--t-small); font-weight: 400; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; max-width: 15.5rem; }
.swatches li { width: 36px; height: 36px; background: var(--c); }

.pages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 36rem; }
.pages li { background: #fff; }
.pages img { width: 100%; transition: transform 300ms var(--ease); }
.pages li { overflow: hidden; }
.pages li:hover img { transform: scale(1.06); }
.thumb { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; color: inherit; font: inherit; }
.thumb:focus-visible { outline-offset: -4px; }

/* ---------- Try a page (the live thing) ---------- */
.try-grid { align-items: start; }
.stage { grid-column: 1 / 7; }
.paper {
  position: relative;
  background: #fff;
  aspect-ratio: 1;
  touch-action: manipulation;
  cursor: crosshair;
}
.paper img, .paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.marker {
  position: absolute;
  width: 28px; height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 3px solid #1a1410;
  outline: 3px solid #fff;
  pointer-events: none;
}
.tip {
  position: absolute; left: 50%; bottom: 14px; translate: -50% 0;
  padding: 0.55rem 0.9rem; background: #1a1410; color: #f4eee3;
  font-weight: 700; font-size: var(--t-small); white-space: nowrap; pointer-events: none;
}
.tip[hidden] { display: none; }
.skip { position: fixed; left: 8px; top: -64px; z-index: 20; padding: 0.8rem 1.1rem; background: #e0a84a; color: #1b1408; font-weight: 800; text-decoration: none; transition: top 160ms var(--ease); }
.skip:focus { top: 8px; }
.paper:focus-visible { outline: 4px solid #1a1410; outline-offset: 6px; }

.try .head, .try .tools { grid-column: 8 / 13; display: grid; gap: clamp(20px, 2.4vw, 28px); justify-items: start; align-content: start; }
.try .head { grid-row: 1; }
.try .tools { grid-row: 2; }
.try .stage { grid-row: 1 / 3; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.seg label span {
  display: block;
  padding: calc(0.85rem - 2px) calc(1.2rem - 2px);
  font-weight: 800;
  cursor: pointer;
  border: 2px solid var(--ink);
  transition: background 160ms, color 160ms;
}
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }

.palette { display: grid; grid-template-columns: repeat(6, 44px); gap: 8px; border: 0; padding: 0; margin: 0; }
.palette label { position: relative; display: block; width: 44px; height: 44px; cursor: pointer; }
.palette input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.palette span { position: absolute; inset: 0; background: var(--c); transition: transform 140ms var(--ease); }
.palette label:hover span { transform: scale(1.1); }
.palette input:checked + span { outline: 3px solid var(--ink); outline-offset: 4px; }
.palette input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 6px; }
.picked { font-size: var(--t-lead); font-weight: 800; letter-spacing: -0.03em; min-height: 1.4em; }

/* ---------- App ---------- */
.app-grid { align-items: start; row-gap: clamp(48px, 6vw, 96px); }
.app .copy { grid-column: 1 / 7; display: grid; gap: clamp(20px, 2.4vw, 32px); justify-items: start; }
.pull { grid-column: 1 / 9; grid-row: 3; align-self: start; font-size: clamp(1.5rem, 2.5vw, 2.25rem); font-weight: 900; letter-spacing: -0.035em; line-height: 1.05; max-width: 18ch; }
.pull footer { letter-spacing: 0; font-size: var(--t-small); font-weight: 400; line-height: 1.4; }
.feats { grid-column: 1 / 7; grid-row: 2; display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px var(--gap); }

/* The app's coloring screen, drawn in HTML: Back, the page, the color row. */
.phone { grid-column: 8 / 13; grid-row: 1 / 3; align-self: center; justify-self: center; width: min(100%, 21rem); aspect-ratio: 9 / 16.5; padding: 10px; background: #0b0910; border-radius: 44px; }
.phone .screen { position: relative; height: 100%; display: flex; flex-direction: column; gap: 14px; padding: 38px 14px 18px; background: #15111c; color: #e0a84a; border-radius: 34px; overflow: hidden; }
.phone .screen::before { content: ""; position: absolute; top: 11px; left: 50%; translate: -50% 0; width: 84px; height: 22px; background: #0b0910; border-radius: 11px; }
.phone .back { font-weight: 800; font-size: var(--t-small); }
.phone img { width: 100%; margin-block: auto; }
.phone .row { display: flex; justify-content: space-between; gap: 4px; padding-top: 8px; }
.phone .row i { flex: 1; max-width: 28px; aspect-ratio: 1; border-radius: 50%; background: var(--c); }
.phone .row i.on { outline: 2px solid #e0a84a; outline-offset: 3px; }
.feats h3 { margin-bottom: 12px; }
.feats p { max-width: 26ch; }

/* ---------- Close ---------- */
.close { padding-bottom: 0; }
.close h2 { font-size: clamp(2.75rem, 8vw, 6rem); max-width: 13ch; }
.buy { margin-top: clamp(40px, 6vw, 88px); display: grid; }
.buy a {
  display: grid;
  grid-template-columns: 5fr 4fr 3fr;
  gap: var(--gap);
  align-items: baseline;
  padding-block: clamp(20px, 2.4vw, 32px);
  text-decoration: none;
  transition: background 200ms, padding 300ms var(--ease);
}
.buy a:hover { background: #1c1824; padding-inline: 16px; }
.buy .t { font-size: var(--t-h2); font-weight: 900; letter-spacing: -0.04em; line-height: 0.95; }
.buy .d { font-size: var(--t-lead); }
.buy .go { font-weight: 800; color: #e0a84a; justify-self: end; text-align: right; }

.foot { padding-block: clamp(72px, 9vw, 144px) 32px; display: grid; gap: 28px; }
.big { font-size: 9.4vw; font-weight: 900; letter-spacing: -0.05em; line-height: 0.85; white-space: nowrap; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 28px; font-weight: 600; }
.foot nav a:hover { text-decoration-thickness: 3px; }
.fine { font-size: var(--t-small); }

/* ---------- Entrances: visible by default, hidden only when scripting is on and about to reveal them ---------- */
@media (scripting: enabled) {
[data-rise] { opacity: 0; transform: translateY(28px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); }
[data-rise].in { opacity: 1; transform: none; }
.copy [data-rise]:nth-child(2) { transition-delay: 70ms; }
.copy [data-rise]:nth-child(3) { transition-delay: 140ms; }
.copy [data-rise]:nth-child(4) { transition-delay: 210ms; }
.copy [data-rise]:nth-child(5) { transition-delay: 280ms; }
.feats li:nth-child(2) { transition-delay: 80ms; }
.feats li:nth-child(3) { transition-delay: 160ms; }
.feats li:nth-child(4) { transition-delay: 240ms; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
  [data-rise] { opacity: 1; transform: none; }
}

/* ---------- Tablet and phone ---------- */
@media (max-width: 960px) {
  .hero h1 { grid-column: 1 / 13; }
  .hero-side { grid-column: 1 / 13; margin-top: 32px; }
  .book .cover, .book.flip .cover { grid-column: 1 / 13; grid-row: 1; max-width: 34rem; margin: 0 0 40px; rotate: 0deg; }
  .book .copy, .book.flip .copy { grid-column: 1 / 13; grid-row: 2; }
    .stage { grid-column: 1 / 13; margin-bottom: 40px; }
  .try .head, .try .tools { grid-column: 1 / 13; }
  .try .head { grid-row: 1; margin-bottom: 32px; }
  .try .stage { grid-row: 2; }
  .try .tools { grid-row: 3; }
  .app .copy { grid-column: 1 / 13; }
  .phone { grid-column: 1 / 13; grid-row: 2; width: min(72vw, 19rem); }
  .feats { grid-column: 1 / 13; grid-row: 3; }
  .pull { grid-column: 1 / 13; grid-row: 4; max-width: 16ch; }
  .buy a { grid-template-columns: 1fr; gap: 4px; padding-block: 48px; }
  .buy .go { justify-self: start; text-align: left; margin-top: 12px; }
}

@media (max-width: 640px) {
  .nav nav, .bar nav { display: none; }
  .nav { padding-block: 16px; }
  .shelf { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 76%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--m); padding-bottom: 8px; }
  .shelf li { scroll-snap-align: start; }
  .shelf li:nth-child(even) { margin-top: 0; }
  .shelf img { animation: none; }
  .feats { grid-template-columns: 1fr; }
  .palette { grid-template-columns: repeat(6, 1fr); }
  .seg label span { padding: calc(0.7rem - 2px) calc(0.95rem - 2px); font-size: 1rem; }
  .palette label { width: auto; aspect-ratio: 1; height: auto; min-height: 44px; }
  .big { font-size: 9vw; }
}
