/* Abby Geigerman — site styles
   Brand tokens come from brand/tokens.css (Light A default, Evening dark mode).
   Mobile first: base styles are for phones, wider screens are layered on with min-width queries.
   Rules: script font only for wordmark, monogram and footer signature. No gradients, shadows or emoji. */

/* ---------- Fonts ---------- */
/* Abby's own handwriting (Handwriting 2), self-hosted. Missing characters fall back to the system cursive. */
@font-face {
  font-family: "Abby Hand";
  src: url("../fonts/abby-handwriting.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root,
:root[data-theme="light-a"] {
  color-scheme: light;
  --ground: #eee8d1;
  --nav: #eee8d1;
  --depth: #29100c;
  --on-depth: #eee8d1;
  --field: #b3c1ac;
  --on-field: #3f1922;
  --ink: #3f1922;
  --accent: #464c49;
  --spine-1: #3f1922;
  --spine-2: #b3c1ac;
  --spine-3: #b39b88;
  --spine-4: #464c49;
  --rule: rgba(63, 25, 34, 0.2);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --radius-sm: 2px;
  --radius-md: 4px;

  --font-script: "Pinyon Script", cursive;
  --font-serif: "EB Garamond", Garamond, Georgia, serif;
  --font-hand: "Abby Hand", cursive;

  --gutter: max(16px, 5vw);
  --max: 1180px;
  --nav-h: 60px;
}

:root[data-theme="evening"] {
  color-scheme: dark;
  --ground: #3f1922;
  --nav: #29100c;
  --ink: #eee8d1;
  --accent: #b3c1ac;
  --spine-1: #b3c1ac;
  --spine-2: #eee8d1;
  --rule: rgba(238, 232, 209, 0.2);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 12px);
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 17px/1.6 var(--font-serif);
  font-optical-sizing: auto;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { font-weight: 500; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(34px, 7vw, 44px); line-height: 1.1; }
h2 { font-size: clamp(26px, 5vw, 34px); line-height: 1.15; }
h3 { font-size: 22px; line-height: 1.2; }
p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip {
  position: absolute; left: var(--space-3); top: -60px; z-index: 50;
  background: var(--accent); color: var(--ground);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
}
.skip:focus { top: var(--space-3); }

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

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: 720px; }
.band { padding: clamp(48px, 9vw, 96px) 0; }
.caption { font-size: 14px; line-height: 1.4; }
.lede { font-size: clamp(18px, 2.4vw, 20px); }
.hand { font-family: var(--font-hand); font-size: 26px; line-height: 1.15; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 12px 24px;
  border: 0; border-radius: var(--radius-md);
  background: var(--accent); color: var(--ground);
  font: 500 17px/1.1 var(--font-serif); text-decoration: none; text-align: center;
  cursor: pointer; touch-action: manipulation;
}
.btn:hover { text-decoration: underline; text-underline-offset: 4px; }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1px currentColor; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Nav ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--nav); border-bottom: 1px solid var(--rule);
}
.site-nav .wrap { display: flex; align-items: center; gap: var(--space-3); min-height: var(--nav-h); }
.monogram {
  font: 400 36px/1 var(--font-script); text-decoration: none;
  padding: 8px 4px 0; min-height: 44px; display: inline-flex; align-items: center;
}
.nav-tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: none; border: 1px solid var(--rule); border-radius: var(--radius-md);
  color: var(--ink); font: 15px var(--font-serif); cursor: pointer; touch-action: manipulation;
}
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .moon, :root[data-mode="evening"] .theme-toggle .sun { display: block; }
.theme-toggle .sun, :root[data-mode="evening"] .theme-toggle .moon { display: none; }

.nav-links {
  list-style: none; margin: 0; padding: 0;
  display: none;
}
.nav-links a { text-decoration: none; display: flex; align-items: center; min-height: 48px; }
.nav-links a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }

/* Phone menu: panel under the bar. Without JS, links show inline as a scrolling row. */
.no-js .menu-toggle { display: none; }
.no-js .nav-links {
  display: flex; gap: var(--space-4); overflow-x: auto; order: 3; width: 100%;
}
.no-js .site-nav .wrap { flex-wrap: wrap; }

.nav-open .nav-links {
  display: block; position: absolute; left: 0; right: 0; top: 100%;
  background: var(--nav); border-bottom: 1px solid var(--rule);
  padding: var(--space-2) var(--gutter) var(--space-5);
  max-height: calc(100dvh - var(--nav-h)); overflow-y: auto;
}
.nav-open .nav-links li + li { border-top: 1px solid var(--rule); }
.nav-open .nav-links a { font-size: 22px; min-height: 56px; }

@media (min-width: 760px) {
  .menu-toggle { display: none; }
  .nav-links,
  .no-js .nav-links {
    display: flex; gap: var(--space-5); position: static; padding: 0; border: 0;
    order: 0; width: auto; margin-left: auto; overflow: visible;
  }
  .nav-links a { font-size: 16px; min-height: 44px; }
  .nav-links a:hover { text-decoration: underline; text-underline-offset: 6px; }
  .nav-tools { margin-left: var(--space-2); }
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding-top: clamp(32px, 6vw, 56px); }
.wordmark {
  font: 400 clamp(54px, 15vw, 140px)/1.05 var(--font-script);
  margin: 0; padding-top: 0.08em;
}
.role { font-style: italic; font-size: clamp(21px, 4vw, 28px); margin: var(--space-2) 0 var(--space-3); }
.tagline { font: clamp(24px, 4.5vw, 32px)/1.2 var(--font-hand); color: var(--accent); margin: 0 0 var(--space-5); }
.hero .btn-row { justify-content: center; max-width: 480px; margin: var(--space-5) auto 0; }

.shelf {
  position: relative; margin-top: clamp(32px, 6vw, 48px);
  height: clamp(220px, 44vw, 320px);
}
.shelf svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.faceout {
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  height: 96%; aspect-ratio: 3300 / 5100; display: block;
}
.faceout img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.faceout .hand {
  position: absolute; left: calc(100% + 10px); top: 4%;
  white-space: nowrap; transform: rotate(-4deg); font-size: 30px; color: var(--ink);
}
.faceout .hand::before { content: "\2190\00a0"; font-family: var(--font-serif); font-size: 18px; }
@media (max-width: 420px) { .faceout .hand { display: none; } }

/* ---------- Books band ---------- */
.on-field { background: var(--field); color: var(--on-field); }
.on-depth { background: var(--depth); color: var(--on-depth); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-6); }

.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-4); list-style: none; margin: 0; padding: 0; }
.book-card { display: flex; flex-direction: column; gap: var(--space-2); }
.book-card .cover { aspect-ratio: 2 / 3; width: 100%; object-fit: cover; border-radius: var(--radius-sm); outline: 1px solid rgba(63, 25, 34, 0.2); }
.book-card h3 { margin-top: var(--space-2); font-size: 20px; }
.book-card h3 a { text-decoration: none; }
.book-card h3 a:hover { text-decoration: underline; }
.book-card p { font-size: 16px; }
.chip {
  align-self: flex-start; font-size: 14px; line-height: 1.3; padding: 3px 10px;
  border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px currentColor;
}
.chip-solid { background: var(--ink); color: var(--ground); box-shadow: none; }
.on-field .chip-solid { background: var(--on-field); color: var(--field); }

/* Phone: featured book spans the row, cover beside text */
.book-card.featured { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-4); align-items: center; }
.book-card.featured h3 { margin-top: 0; font-size: 24px; }
.book-card.featured .body { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-start; }

@media (min-width: 760px) {
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
  .book-card.featured { grid-column: auto; display: flex; }
  .book-card.featured h3 { margin-top: var(--space-2); font-size: 22px; }
}

/* ---------- Opening line ---------- */
.opening { display: grid; gap: var(--space-6); }
.opening blockquote { margin: 0; font: italic 500 clamp(32px, 7vw, 54px)/1.08 var(--font-serif); text-wrap: balance; }
.opening blockquote::before { content: ""; display: block; width: 56px; height: 2px; background: currentColor; margin-bottom: var(--space-5); }
.meta-line { font-size: 15px; opacity: 0.85; }
@media (min-width: 860px) {
  .opening { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-8); align-items: center; }
}

/* ---------- Newsletter ---------- */
.letters .wrap { display: grid; gap: var(--space-6); }
.letters .mono-lg { font: 400 56px/1 var(--font-script); display: block; margin-bottom: var(--space-2); }
.sub-embed { border-radius: var(--radius-md); overflow: hidden; background: #fff; }
.sub-embed iframe { display: block; width: 100%; height: 340px; border: 0; background: #fff; }
.letters .caption { opacity: 0.8; margin-top: var(--space-3); }
@media (min-width: 860px) {
  .letters .wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-8); align-items: center; }
}

/* ---------- Cards ---------- */
.pair { display: grid; gap: var(--space-4); }
.card { border-radius: var(--radius-md); padding: clamp(24px, 5vw, 40px); display: flex; flex-direction: column; gap: var(--space-3); }
.card.outline { box-shadow: inset 0 0 0 1px var(--rule); }
.card .btn { align-self: stretch; margin-top: auto; }
.card.on-field .btn { background: var(--on-field); color: var(--field); }
.steps { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.steps li { font-size: 15px; padding: 2px 10px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px currentColor; }
.mini-shelf { display: flex; align-items: flex-end; gap: 5px; height: 72px; margin-bottom: var(--space-2); }
.mini-shelf span { width: 14px; border-radius: var(--radius-sm); }
@media (min-width: 700px) {
  .pair { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
  .card .btn { align-self: flex-start; }
}

/* ---------- About ---------- */
.about { display: grid; gap: var(--space-6); }
.portrait { width: 100%; max-width: 420px; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 30%; border-radius: var(--radius-md); }
.favs { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-style: italic; }
@media (min-width: 760px) {
  .about { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: var(--space-8); align-items: center; }
}

/* ---------- Page header + prose ---------- */
.page-head { padding: clamp(40px, 8vw, 72px) 0 clamp(24px, 4vw, 40px); }
.page-head .sub { font-style: italic; font-size: clamp(19px, 3vw, 22px); margin-top: var(--space-3); }
.page-head .hand { color: var(--accent); margin-top: var(--space-2); display: block; }
.prose { font-size: 18px; }
.prose h2 { margin: var(--space-7) 0 var(--space-4); }
.prose h3 { margin: var(--space-6) 0 var(--space-3); }
.prose ul, .prose ol { padding-left: 1.2em; margin: 0 0 var(--space-4); }
.prose li { margin-bottom: var(--space-2); }
.prose blockquote { margin: var(--space-5) 0; padding-left: var(--space-4); border-left: 2px solid var(--field); font-style: italic; }
.prose img { border-radius: var(--radius-md); margin: var(--space-5) 0; }
.prose a { overflow-wrap: anywhere; }
.post-meta { font-size: 15px; opacity: 0.85; margin-top: var(--space-3); }

/* ---------- Book page ---------- */
.book-hero { display: grid; gap: var(--space-6); padding-block: clamp(32px, 7vw, 72px); }
.book-hero .cover-lg { width: min(70vw, 340px); margin: 0 auto; border-radius: var(--radius-sm); outline: 1px solid var(--rule); }
.book-hero .kicker { font-style: italic; font-size: 19px; margin: var(--space-2) 0 var(--space-4); }
.book-hero .opening-line { font: italic 500 clamp(26px, 5vw, 36px)/1.15 var(--font-serif); margin: var(--space-5) 0; text-wrap: balance; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-1) var(--space-4); font-size: 15px; margin: var(--space-5) 0 0; }
.facts dt { opacity: 0.8; }
.facts dd { margin: 0; }
@media (min-width: 820px) {
  .book-hero { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: var(--space-8); align-items: start; }
  .book-hero .cover-lg { width: 100%; position: sticky; top: calc(var(--nav-h) + 24px); }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--nav); border-top: 1px solid var(--rule);
  padding: var(--space-7) 0 calc(var(--space-6) + env(safe-area-inset-bottom));
}
.site-footer .wrap { display: grid; gap: var(--space-5); }
.signature { font: 400 clamp(44px, 10vw, 60px)/1 var(--font-script); }
.social { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-5); }
.social a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.social a:hover { text-decoration: underline; }
.legal { border-top: 1px solid var(--rule); padding-top: var(--space-4); font-size: 14px; opacity: 0.8; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); justify-content: space-between; }
@media (min-width: 760px) {
  .site-footer .wrap { grid-template-columns: auto minmax(0, 1fr); align-items: end; }
  .social { justify-content: flex-end; }
  .legal { grid-column: 1 / -1; }
}

/* ---------- 404 ---------- */
.lost { text-align: center; }
.lost .shelf { max-width: 520px; margin: var(--space-6) auto; height: 200px; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- Announcement bar ---------- */
.announce { background: var(--depth); color: var(--on-depth); font-size: 15px; }
.announce .wrap { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; text-align: center; padding-right: 52px; position: relative; }
.announce a { text-decoration: underline; text-underline-offset: 3px; padding: var(--space-2) 0; }
.announce button { position: absolute; right: max(4px, calc(var(--gutter) - 12px)); top: 0; width: 44px; height: 44px; background: none; border: 0; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; }
.announce[hidden] { display: none; }

/* ---------- Text links with arrows ---------- */
.more { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; text-decoration: none; }
.more::after { content: "\00a0\2192"; }
.more:hover { text-decoration: underline; }
.hook { font-style: italic; font-size: 18px; }

/* ---------- Books index ---------- */
.book-row { display: grid; gap: var(--space-5); padding: var(--space-7) 0; border-top: 1px solid var(--rule); }
.book-row:first-child { border-top: 0; padding-top: 0; }
.book-row .cover { width: min(56vw, 260px); border-radius: var(--radius-sm); outline: 1px solid var(--rule); }
.book-row .body { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
@media (min-width: 760px) {
  .book-row { grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-7); align-items: center; }
  .book-row .cover { width: 100%; }
}

/* ---------- Writing reset ---------- */
.wr-page { display: grid; gap: var(--space-5); }
.wr-page .card ul { margin-bottom: 0; }
.wr-cta { text-align: center; align-items: center; }
.wr-cta .btn { background: var(--field); color: var(--on-field); align-self: stretch; }
@media (min-width: 560px) { .wr-cta .btn { align-self: center; } }
.no-js .theme-toggle { display: none; }
@media (min-width: 760px) { #books .wrap { max-width: 1000px; } }
