/* ───────────────────────────────────────────────
   TinyDocx — Warm Literary Library
   Every rule has a place. Every decision has a path.
   ─────────────────────────────────────────────── */

:root {
  /* Paper + Ink */
  --paper: #f4ead3;
  --paper-deep: #ebdfc2;
  --paper-soft: #faf3e0;
  --ink: #221810;
  --ink-soft: #3e2e20;
  --ink-muted: #6b5742;
  --rule: #c9b998;

  /* Colours lifted directly from the six book spines */
  --medicare-green: #4a5a3d;
  --memory-purple: #6a4e6e;
  --json-blue: #5d7a92;
  --academy-cream: #d9c79a;
  --mascot-silver: #c9c3b8;
  --ai-navy: #1f2a48;

  /* Accents */
  --brass: #b88a2e;
  --brass-deep: #8c6420;
  --oxblood: #8a3a2a;
  --forest: #3a4a3a;
  --sunbeam: #f6d88a;
  --sun-glow: #fae5a8;

  /* Motion */
  --ease-slow: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 1200px 600px at 20% -10%, rgba(250, 229, 168, .55), transparent 60%),
    radial-gradient(ellipse 800px 500px at 85% 8%, rgba(246, 216, 138, .32), transparent 65%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .13  0 0 0 0 .09  0 0 0 0 .04  0 0 0 .06 0'/></filter><rect width='260' height='260' filter='url(%23n)'/></svg>");
  background-blend-mode: multiply, normal, multiply;
  min-height: 100vh;
}

::selection { background: var(--sunbeam); color: var(--ink); }

/* ─── Type scale ─── */
.display {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.02;
  color: var(--ink);
}
.serif-italic {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
}
.label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.typewriter {
  font-family: "Special Elite", "Courier New", monospace;
}
.marginalia {
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  font-style: italic;
  color: var(--ink-muted);
}

/* ─── Layout helpers ─── */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 48px;
}
.container-narrow {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ─── Dust motes (the sunlight through the door) ─── */
.motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}
.mote {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(250, 229, 168, .95) 0%, rgba(246, 216, 138, .2) 60%, transparent 80%);
  filter: blur(.4px);
  animation: drift var(--d, 18s) linear infinite;
  opacity: 0;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(.8); opacity: 0; }
  10%  { opacity: .9; }
  50%  { opacity: .7; }
  100% { transform: translate3d(var(--dx, 40px), var(--dy, -220px), 0) scale(1.1); opacity: 0; }
}

/* ─── Sunbeam (the Grimm golden-light-through-the-door) ─── */
.sunbeam {
  position: absolute;
  top: -40px;
  left: 8%;
  width: 420px;
  height: 720px;
  background: linear-gradient(172deg,
    rgba(250, 229, 168, .72) 0%,
    rgba(246, 216, 138, .35) 35%,
    rgba(246, 216, 138, .15) 65%,
    transparent 95%);
  transform: rotate(8deg);
  filter: blur(18px);
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 1;
}
.sunbeam-2 {
  position: absolute;
  top: -20px;
  right: 12%;
  width: 280px;
  height: 580px;
  background: linear-gradient(188deg,
    rgba(250, 229, 168, .45) 0%,
    rgba(246, 216, 138, .2) 40%,
    transparent 90%);
  transform: rotate(-10deg);
  filter: blur(22px);
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 1;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--paper-soft);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .22s var(--ease-slow), box-shadow .22s var(--ease-slow), background .22s;
}
.btn:hover { background: var(--brass-deep); border-color: var(--brass-deep); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper-soft); }

/* ─── Ornamental dividers ─── */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-muted);
  margin: 24px 0;
}
.ornament::before, .ornament::after {
  content: "";
  display: block;
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule), transparent);
  max-width: 120px;
}

/* ─── Reveal on scroll ─── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .8s var(--ease-slow), transform .8s var(--ease-slow);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Chapter markers ─── */
.chapter-no {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass-deep);
}

/* ─── Footnote ─── */
sup.fn {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--oxblood);
  padding-left: 2px;
  cursor: help;
  vertical-align: super;
}
.footnote {
  font-family: "IM Fell English", Georgia, serif;
  font-size: 14px;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  padding: 10px 0;
  display: flex; gap: 10px;
}
.footnote .n { color: var(--oxblood); font-family: "JetBrains Mono", monospace; font-size: 11px; padding-top: 2px; }

/* ─── Ex-libris stamp ─── */
.bookplate {
  display: inline-block;
  padding: 14px 20px;
  border: 2px double var(--brass-deep);
  color: var(--brass-deep);
  background: rgba(244, 234, 211, .6);
  font-family: "Cormorant Garamond", serif;
  text-align: center;
  transform: rotate(-1.2deg);
}
.bookplate .ex { font-style: italic; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--oxblood); }
.bookplate .nm { font-size: 22px; font-weight: 500; margin: 4px 0 2px; }
.bookplate .sm { font-size: 12px; color: var(--ink-muted); font-style: italic; }

/* ─── Card catalog drawer ─── */
.catalog {
  background: linear-gradient(180deg, #7a5a38 0%, #5a3f22 100%);
  border-radius: 4px;
  padding: 18px;
  color: var(--paper-soft);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 18px 40px rgba(40,28,14,.28);
}
.drawer {
  background: #6b4a28;
  border: 1px solid #3e2914;
  border-radius: 3px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.drawer + .drawer { margin-top: 8px; }
.drawer .knob {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e6c36a, #8c6420 70%, #4a3410);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  flex-shrink: 0;
}
.drawer .card-label {
  flex: 1;
  background: var(--paper-soft);
  color: var(--ink);
  padding: 4px 10px;
  font-family: "Special Elite", monospace;
  font-size: 12px;
  letter-spacing: .05em;
  border-radius: 1px;
  border: 1px solid rgba(107, 74, 40, .3);
}

/* ─── Library checkout card (waitlist) ─── */
.checkout-card {
  position: relative;
  background: var(--paper-soft);
  border: 1px solid #d9c79a;
  padding: 28px 32px 32px;
  box-shadow: 0 14px 40px rgba(40, 28, 14, .18), 0 2px 0 rgba(0,0,0,.04);
  transform: rotate(-.4deg);
  overflow: hidden;
}
.checkout-card::before {
  /* ruled lines */
  content: "";
  position: absolute;
  left: 32px; right: 32px; bottom: 0; top: 110px;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent 31px,
    #b6a98a 31px, #b6a98a 32px
  );
  opacity: .5;
  pointer-events: none;
}
.checkout-card::after {
  /* red margin rule */
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 70px; width: 1px;
  background: #b23a2a;
  opacity: .6;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  position: relative; z-index: 2;
}
.card-head h3 {
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  letter-spacing: .02em;
}
.card-head .call-no {
  font-family: "Special Elite", monospace;
  font-size: 11px;
  color: var(--oxblood);
  text-align: right;
}

/* ─── Stamp (appears on waitlist submit) ─── */
.stamp {
  position: absolute;
  top: 20px; right: 24px;
  font-family: "Special Elite", monospace;
  font-size: 14px;
  color: var(--oxblood);
  border: 2px solid var(--oxblood);
  padding: 6px 12px;
  transform: rotate(-18deg) scale(2.4);
  opacity: 0;
  pointer-events: none;
  letter-spacing: .12em;
  background: transparent;
  mix-blend-mode: multiply;
  z-index: 5;
}
.stamp.small { font-size: 11px; padding: 4px 8px; }
.stamp.thunk {
  animation: thunk .55s var(--ease-slow) forwards;
}
@keyframes thunk {
  0%   { opacity: 0; transform: rotate(-18deg) scale(3.2); }
  55%  { opacity: 1; transform: rotate(-15deg) scale(.92); }
  75%  { transform: rotate(-14deg) scale(1.02); }
  100% { opacity: .92; transform: rotate(-14deg) scale(1); }
}

/* ─── Shelf (homepage centerpiece) ─── */
.shelf-wrap {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
}
.shelf-img {
  width: 100%;
  display: block;
  border-radius: 3px;
  box-shadow: 0 40px 80px -30px rgba(40, 28, 14, .35);
}
.shelf-hotspots {
  position: absolute;
  inset: 0;
}
.hot {
  position: absolute;
  cursor: pointer;
  border-radius: 2px;
  transition: transform .35s var(--ease-slow), filter .35s var(--ease-slow), box-shadow .35s var(--ease-slow);
  text-decoration: none;
}
.hot:hover {
  transform: translateY(-8px) rotate(-.3deg);
  filter: drop-shadow(0 14px 22px rgba(40, 28, 14, .45));
  z-index: 3;
}
.hot .name {
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-soft);
  padding: 3px 10px;
  border: 1px solid var(--rule);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  box-shadow: 0 4px 10px rgba(40,28,14,.15);
}
.hot:hover .name { opacity: 1; }

/* "Who this is for" — three shelves */
.three-shelf {
  display: grid;
  gap: 34px;
}
.wooden-shelf {
  position: relative;
  padding: 18px 28px 30px;
  background:
    linear-gradient(180deg, rgba(250,243,224,0) 0%, rgba(250,243,224,0) 78%, rgba(120, 86, 48, .0) 78%, rgba(120, 86, 48, .0) 100%);
}
.wooden-shelf::after {
  /* the wooden plank */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18px;
  background:
    linear-gradient(180deg, #8a6236 0%, #6b4a28 40%, #4e341c 100%);
  border-radius: 1px;
  box-shadow: 0 10px 20px -6px rgba(40, 28, 14, .35);
}
.wooden-shelf::before {
  /* wood grain */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='18'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.02 .8' numOctaves='2'/><feColorMatrix values='0 0 0 0 .18  0 0 0 0 .1  0 0 0 0 .04  0 0 0 .35 0'/></filter><rect width='400' height='18' filter='url(%23g)'/></svg>");
  opacity: .6;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.shelf-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 240px;
  padding-bottom: 0;
}

/* Spine book for audience shelves */
.spine {
  width: 54px;
  height: 210px;
  border-radius: 2px 3px 3px 2px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Cormorant Garamond", serif;
  color: var(--paper-soft);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 14px;
  letter-spacing: .08em;
  padding: 14px 0;
  box-shadow:
    inset -2px 0 3px rgba(0,0,0,.25),
    inset 2px 0 2px rgba(255,255,255,.08),
    0 4px 6px rgba(40,28,14,.2);
  flex-shrink: 0;
  transform-origin: bottom center;
  transition: transform .4s var(--ease-slow);
}
.spine::before {
  content: "";
  position: absolute;
  inset: 6px 3px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 1px;
  pointer-events: none;
}
.spine:hover {
  transform: translateY(-6px) rotate(-1.2deg);
}
.spine.tall { height: 230px; }
.spine.short { height: 190px; }
.spine.wide { width: 62px; }

.audience-card {
  flex: 1;
  padding: 22px 26px;
  border-left: 1px solid var(--rule);
  margin-left: 18px;
  max-width: 440px;
}
.audience-card h4 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 4px;
}
.audience-card .tagline {
  font-style: italic;
  color: var(--ink-muted);
  margin: 0 0 12px;
  font-size: 16px;
}
.audience-card p { margin: 0; }

/* ─── Foreword (founder note) ─── */
.foreword {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 44px;
  align-items: start;
}
.foreword .portrait {
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 18px 40px -10px rgba(40, 28, 14, .35);
  transform: rotate(-1.1deg);
}
.foreword .portrait img {
  width: 100%;
  display: block;
  filter: sepia(.18) saturate(.9) contrast(1.02);
}
.foreword .portrait .mat {
  position: absolute; inset: 0;
  border: 8px solid var(--paper-soft);
  outline: 1px solid var(--rule);
  pointer-events: none;
}
.foreword .caption {
  font-family: "Special Elite", monospace;
  font-size: 11px;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 8px;
  transform: rotate(-1.1deg);
}
.drop-cap::first-letter {
  font-family: "Cormorant Garamond", serif;
  font-size: 78px;
  line-height: .85;
  float: left;
  padding: 8px 10px 0 0;
  color: var(--brass-deep);
  font-weight: 500;
}

/* Signature */
.signature {
  font-family: "Dancing Script", "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 500;
  font-size: 30px;
  color: var(--ink);
  letter-spacing: .01em;
}

/* ─── Tweaks panel ─── */
.tweaks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 40px -10px rgba(40,28,14,.3);
  padding: 16px 18px 18px;
  font-family: "EB Garamond", serif;
  font-size: 14px;
  z-index: 100;
  transform: rotate(-.4deg);
}
.tweaks h5 {
  margin: 0 0 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: 20px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: space-between;
}
.tweaks .group { margin: 12px 0 4px; }
.tweaks .group > .label { margin-bottom: 6px; display: block; }
.tweaks .swatches { display: flex; gap: 6px; }
.tweaks .sw {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.tweaks .sw.on { border-color: var(--ink); }
.tweaks .seg {
  display: flex; border: 1px solid var(--rule);
}
.tweaks .seg button {
  flex: 1; background: transparent; border: 0;
  padding: 6px 4px; cursor: pointer;
  font-family: "EB Garamond", serif; font-size: 13px;
  color: var(--ink-muted);
}
.tweaks .seg button.on { background: var(--ink); color: var(--paper-soft); }
.tweaks button.close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 18px; color: var(--ink-muted); padding: 0;
}

/* Palette themes */
body.theme-deep { --paper: #ead6a8; --paper-deep: #d9c290; --paper-soft: #f1e2b8; }
body.theme-cool { --paper: #e8e4d0; --paper-deep: #d6d1ba; --paper-soft: #f2eedc; --sunbeam: #d8e3c4; --sun-glow: #e9f0d8; }

body.density-airy .section-pad { padding: 140px 0; }
body.density-snug .section-pad { padding: 80px 0; }
.section-pad { padding: 110px 0; }

.companion-cover-frame {
  height: 280px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.companion-cover {
  height: 100%;
  width: auto;
  max-width: 100%;
  display: block;
  border-radius: 3px;
  box-shadow: 0 24px 50px -18px rgba(40,28,14,.5), 0 2px 0 rgba(0,0,0,.1);
  transition: transform .4s var(--ease-slow), box-shadow .4s var(--ease-slow);
}
.companion-cover:hover {
  transform: translateY(-8px) rotate(-.6deg);
  box-shadow: 0 36px 60px -16px rgba(40,28,14,.55);
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .foreword { grid-template-columns: 1fr; }
  .container { padding: 0 24px; }
  .shelf-row { flex-wrap: wrap; min-height: unset; }
  .audience-card { margin-left: 0; border-left: 0; padding-top: 6px; }
}
