/* Library — Old Bookshop tone */

:root {
  --paper:     oklch(94% 0.014 80);          /* aged paper */
  --paper-2:   oklch(91% 0.018 75);
  --cream:     oklch(97% 0.012 85);
  --ink:       oklch(22% 0.020 55);           /* dark sepia ink */
  --ink-soft:  oklch(22% 0.020 55 / 0.65);
  --muted:     oklch(40% 0.020 55);
  --rule:      oklch(45% 0.025 50);
  --hairline:  oklch(78% 0.015 70);
  --accent:    oklch(45% 0.13 35);            /* deep red — book spine */
  --accent-soft: oklch(45% 0.13 35 / 0.10);
  --gold:      oklch(72% 0.13 78);            /* gilt foil */
  --gold-soft: oklch(72% 0.13 78 / 0.20);
  --olive:     oklch(50% 0.07 110);
  --teal:      oklch(45% 0.07 200);
  --plum:      oklch(40% 0.10 340);

  --font-display: 'Iowan Old Style', 'Charter', 'Source Serif Pro', Georgia, 'Noto Serif KR', serif;
  --font-body:    'Iowan Old Style', 'Charter', 'Source Serif Pro', Georgia, 'Noto Serif KR', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --maxw: 1280px;
  --pad-x: clamp(20px, 4vw, 56px);
}

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

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* warm paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(oklch(22% 0.020 55 / 0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  color: var(--ink);
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* ───────── Masthead ───────── */
.masthead {
  border-bottom: 1px solid var(--rule);
  border-top: 5px double var(--rule);
  background: var(--paper);
  padding: 22px 0 18px;
}
.mast-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand small {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-style: normal;
  margin-left: 14px;
  font-weight: 500;
}
.mast-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.mast-meta a:hover { color: var(--accent); }

/* ───────── Hero ───────── */
.hero {
  padding: 56px 0 28px;
  border-bottom: 1px solid var(--hairline);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.hero h1 {
  font-size: clamp(40px, 6vw, 84px);
  letter-spacing: -0.03em;
  line-height: 0.98;
  margin: 16px 0 0;
  max-width: 18ch;
  font-style: italic;
}
.standfirst {
  margin-top: 22px;
  font-family: var(--font-display);
  font-size: clamp(17px, 1.5vw, 22px);
  line-height: 1.5;
  color: var(--muted);
  max-width: 60ch;
  font-style: italic;
}
.hero-stats {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  border: 1px solid var(--hairline);
  background: var(--cream);
}
.hero-stats .cell {
  padding: 14px 18px;
  border-right: 1px solid var(--hairline);
}
.hero-stats .cell:last-child { border-right: 0; }
.hero-stats .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-stats .v {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  display: block;
  margin-top: 4px;
}

/* ───────── Toolbar ───────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 16px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  background: var(--cream);
  cursor: pointer;
  border-radius: 2px;
  transition: all 100ms ease;
}
.filter-btn:hover { color: var(--ink); border-color: var(--rule); }
.filter-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.toolbar .hint {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ───────── Shelf section heading ───────── */
.shelf-section {
  padding: 48px 0 16px;
}
.shelf-section h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 40px);
  font-style: italic;
  letter-spacing: -0.015em;
}
.shelf-section .sub {
  font-style: italic;
  color: var(--muted);
  font-size: 16px;
  max-width: 60ch;
  margin-top: 6px;
}

/* ───────── Bookshelf grid ───────── */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px 24px;
  padding: 24px 0 12px;
}
@media (max-width: 540px) {
  .shelf { grid-template-columns: 1fr; }
}

/* ───────── Book card (spine + cover hybrid) ───────── */
.book {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 200ms ease;
  position: relative;
}
.book:hover { transform: translateY(-4px); }
.book:hover .spine { box-shadow: 8px 12px 24px oklch(22% 0.020 55 / 0.25); }

.spine {
  position: relative;
  aspect-ratio: 2 / 3;
  padding: 28px 22px 22px;
  background: var(--book-bg, var(--accent));
  color: var(--book-fg, var(--cream));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: 4px 6px 14px oklch(22% 0.020 55 / 0.18);
  transition: box-shadow 200ms ease;
  border-radius: 1px 3px 3px 1px;
}
/* book spine ridges */
.spine::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 8px;
  background: linear-gradient(90deg,
    oklch(22% 0.020 55 / 0.30),
    oklch(22% 0.020 55 / 0) 60%);
  pointer-events: none;
}
.spine::after {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid var(--cream);
  opacity: 0.18;
  pointer-events: none;
}

.spine .kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.85;
}
.spine .title {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.015em;
}
.spine .author {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.04em;
  opacity: 0.9;
}
.spine .ornament {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: 1px solid currentColor;
  opacity: 0.45;
  border-radius: 50%;
}
.spine .ornament::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

/* Below-spine label (like library card) */
.book .card-info {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.book .card-info .row1 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.book .card-info .title2 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-top: 4px;
  line-height: 1.25;
}
.book .card-info .author2 {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.book .card-info .blurb {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.55;
  font-style: italic;
}

/* Spine color presets */
.book.col-red    { --book-bg: var(--accent); --book-fg: var(--cream); }
.book.col-olive  { --book-bg: var(--olive);  --book-fg: var(--cream); }
.book.col-teal   { --book-bg: var(--teal);   --book-fg: var(--cream); }
.book.col-plum   { --book-bg: var(--plum);   --book-fg: var(--cream); }
.book.col-cream  { --book-bg: var(--cream);  --book-fg: var(--ink); }
.book.col-ink    { --book-bg: var(--ink);    --book-fg: var(--gold); }

/* "Coming soon" placeholder book */
.book.placeholder { opacity: 0.45; }
.book.placeholder .spine {
  background: var(--cream);
  color: var(--muted);
  box-shadow: none;
  border: 1px dashed var(--hairline);
}
.book.placeholder .spine::after { display: none; }
.book.placeholder:hover { transform: none; }
.book.placeholder:hover .spine { box-shadow: none; }

/* ───────── Footer ───────── */
.colophon {
  margin-top: 80px;
  padding: 28px 0 56px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

/* ───────── Book detail page ───────── */
.book-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  padding: 56px 0 36px;
}
@media (max-width: 760px) {
  .book-detail { grid-template-columns: 1fr; }
}
.book-detail .cover .spine {
  aspect-ratio: 2/3;
}
.book-detail .info h1 {
  font-size: clamp(32px, 5vw, 60px);
  font-style: italic;
  letter-spacing: -0.025em;
  line-height: 0.98;
  max-width: 20ch;
}
.book-detail .info .by {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--muted);
  margin: 14px 0 0;
}
.book-detail .info .blurb {
  margin-top: 20px;
  font-size: 17px;
  line-height: 1.65;
  max-width: 62ch;
  color: var(--ink);
}

.spec-table {
  margin-top: 20px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  width: 100%;
  border-collapse: collapse;
}
.spec-table th, .spec-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
  text-align: left;
  vertical-align: top;
}
.spec-table tr:last-child th, .spec-table tr:last-child td { border-bottom: 0; }
.spec-table th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  width: 130px;
  padding-right: 20px;
  font-weight: 500;
}

.formats {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.format-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  text-decoration: none;
  transition: all 120ms ease;
}
.format-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--cream);
}
.format-btn.secondary {
  background: transparent;
  color: var(--ink);
}
.format-btn.secondary:hover {
  background: var(--ink);
  color: var(--paper);
}
.format-btn .arrow { font-family: var(--font-mono); font-size: 14px; }

/* TOC list */
.toc-section { padding: 24px 0 12px; border-top: 1px solid var(--hairline); }
.toc-section h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 28px;
  letter-spacing: -0.015em;
}
.toc-list {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px 24px;
  list-style: none;
}
.toc-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 14.5px;
}
.toc-list li .num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.toc-list li .name { font-style: italic; }

/* "back" link in masthead */
.back-link {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.back-link::before { content: '← '; }
