/* ===== The Shelf: warm, dark library with natural oak shelving ===== */
:root {
  --ink: #d8c9a8;
  --brass: #b99a5e;
  --dim: #88795f;
  --serif: "IM Fell English", "Palatino Linotype", Palatino, Georgia, serif;
  --spine: "Cormorant Garamond", "IM Fell English", Georgia, serif;
  --wood-light: #b88750;
  --wood-mid: #80532f;
  --wood-dark: #4b2d19;
  --plank: linear-gradient(180deg, #c18e55 0%, #9a673b 18%, #704626 62%, #4a2b18 100%);
}

* { box-sizing: border-box; }

html {
  background: #080706;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(ellipse 75% 34% at 50% 0%, rgba(116, 79, 39, .17), transparent 72%),
    radial-gradient(ellipse 90% 40% at 50% 100%, rgba(24, 39, 34, .22), transparent 72%),
    #090807;
}

header { text-align: center; padding: 64px 20px 38px; }

header h1 {
  margin: 0;
  font: 400 clamp(44px, 9vw, 82px)/1 var(--serif);
  letter-spacing: .13em;
  color: #d0b47c;
  text-shadow: 0 2px 5px #000, 0 0 28px rgba(190, 145, 75, .2);
}

header h1::after {
  content: "";
  display: block;
  width: min(280px, 60%);
  height: 1px;
  margin: 24px auto 0;
  background: linear-gradient(90deg, transparent, #a98a52, transparent);
}

.sub { margin: 18px 0 0; font-style: italic; font-size: 19px; color: #aa9978; }
.legend { margin: 14px 0 0; font-size: 14px; letter-spacing: .04em; color: #81745e; }
.k { color: var(--brass); }

/* A substantial case with softly rounded edges and believable wood grain. */
.case {
  max-width: 1120px;
  margin: 0 auto 44px;
  padding: 17px;
  border: 1px solid rgba(213, 169, 105, .22);
  border-radius: 7px;
  background:
    linear-gradient(90deg, #58371f, #95633a 12%, #704626 50%, #95633a 88%, #50321e);
  box-shadow: 0 34px 80px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,224,178,.22), inset 0 -2px 5px rgba(0,0,0,.5);
}

.shelves {
  overflow: hidden;
  background: #070605;
  border: 1px solid rgba(0,0,0,.8);
  border-top: 18px solid #8b5b34;
  box-shadow: inset 0 0 42px #000, 0 1px 0 rgba(255,220,175,.12);
}

.shelf {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 34px 3px;
  /* The bottom padding leaves room for one continuous shelf plank. */
  padding: 30px 20px 17px;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(94,66,39,.12), transparent 68%),
    linear-gradient(180deg, #080706 0%, #100c09 62%, #17100b 100%);
  box-shadow: inset 0 13px 24px rgba(0,0,0,.78);
}

.shelf:nth-child(odd) { padding-right: calc(30% + 20px); }
.shelf:nth-child(even) { padding-left: calc(30% + 20px); }

/* Fluted end panels: lighter oak with fine, irregular grain. */
.shelf::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; width: 30%;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,225,180,.12), transparent 12%, transparent 88%, rgba(0,0,0,.28)),
    repeating-linear-gradient(90deg,
      #704626 0 3px, #96643b 3px 7px, #b17d49 7px 9px,
      #82532f 9px 13px, #a16e40 13px 17px, #694123 17px 20px);
  opacity: .95;
}
.shelf:nth-child(odd)::before { right: 0; box-shadow: -12px 0 18px rgba(0,0,0,.65), inset 3px 0 0 rgba(0,0,0,.35); }
.shelf:nth-child(even)::before { left: 0; box-shadow: 12px 0 18px rgba(0,0,0,.65), inset -3px 0 0 rgba(0,0,0,.35); }

.shelf::after {
  /* A single full-width board, not a separate base beneath each book. */
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 17px;
  background: var(--plank);
  border-top: 1px solid rgba(255,225,183,.38);
  box-shadow: 0 9px 13px rgba(0,0,0,.78), inset 0 1px 2px rgba(255,235,200,.22);
  pointer-events: none;
}

/* Books */
.book {
  --t: #d3c39a;
  --g: rgba(190,157,94,.55);
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  writing-mode: vertical-rl;
  text-align: center;
  text-decoration: none;
  color: var(--t);
  font: 700 15px/1.15 var(--spine);
  letter-spacing: .04em;
  padding: 34px 0;
  border-radius: 3px 3px 0 0;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  background:
    linear-gradient(180deg, transparent 10px, var(--g) 10px 11px, transparent 11px 15px, var(--g) 15px 16px,
      transparent 16px calc(100% - 16px), var(--g) calc(100% - 16px) calc(100% - 15px), transparent calc(100% - 15px) calc(100% - 11px),
      var(--g) calc(100% - 11px) calc(100% - 10px), transparent calc(100% - 10px)),
    linear-gradient(90deg, rgba(255,255,255,.14), transparent 20%, rgba(0,0,0,.06) 64%, rgba(0,0,0,.58)),
    linear-gradient(180deg, rgba(255,255,255,.1), transparent 14%, transparent 80%, rgba(0,0,0,.38)),
    repeating-linear-gradient(0deg, rgba(0,0,0,.1) 0 1px, transparent 1px 3px),
    var(--c);
  box-shadow: inset -4px 0 7px rgba(0,0,0,.5), inset 1px 0 1px rgba(255,255,255,.13), 3px 0 6px rgba(0,0,0,.8), 0 1px 0 rgba(0,0,0,.7);
  transition: filter .2s ease, transform .2s ease, box-shadow .2s ease;
}
.book::after, .frame::after {
  /* Individual book/photo plinths removed: the row itself is the shelf. */
  content: none;
}
.book:hover, .book:focus-visible {
  color: #fff0c9;
  outline: none;
  filter: brightness(1.13);
  transform: translateY(-3px);
  box-shadow: inset -4px 0 7px rgba(0,0,0,.5), inset 0 0 22px rgba(220,180,100,.24), 4px 3px 8px rgba(0,0,0,.8);
}
.book:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.read::before, .reading::before {
  position: absolute; top: 21px; left: 50%; transform: translateX(-50%);
  writing-mode: horizontal-tb; font-size: 10px; line-height: 1; color: #d4b16d;
}
.read::before { content: "\25CF"; }
.reading::before { content: "\25D0"; }
.read, .reading { padding-top: 44px; }

.h1 { height: 230px; } .h2 { height: 262px; } .h3 { height: 294px; } .h4 { height: 326px; }
.w1 { width: 46px; } .w2 { width: 54px; } .w3 { width: 62px; font-size: 16px; }

.c1 { --c:#4a1b20; } .c2 { --c:#1b3027; } .c3 { --c:#202b3b; } .c4 { --c:#392719; }
.c5 { --c:#3a2638; } .c6 { --c:#242426; } .c7 { --c:#5a4724; } .c9 { --c:#30382a; } .c10 { --c:#5a3020; }
.c8 { --c:#b5a27a; --t:#21180e; --g:rgba(55,38,17,.65); text-shadow:none; }
.c8.read::before, .c8.reading::before { color:#382610; }

footer { text-align: center; padding: 0 20px 56px; font-style: italic; color: #6c604c; }

/* Pictures use real img elements, so each frame follows its image's natural ratio. */
.frame {
  --pic: none;
  position: relative;
  flex: 0 1 auto;
  align-self: flex-end;
  display: block;
  width: auto;
  height: auto;
  max-width: min(190px, 22%);
  max-height: 250px;
  object-fit: contain;
  object-position: center bottom;
  padding: 8px;
  margin: 0 12px 0 8px;
  background: linear-gradient(135deg, #c0915c, #6e4528 48%, #a87949);
  border: 1px solid rgba(255,224,177,.38);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,235,200,.18), inset 0 0 0 4px rgba(0,0,0,.22), 4px 7px 13px rgba(0,0,0,.82);
}
.frame::before { content: none; }

@media (max-width: 640px) {
  header { padding: 40px 16px 24px; }
  .sub { font-size: 17px; }
  .case { padding: 8px; margin-bottom: 24px; }
  .shelves { border-top-width: 12px; }
  .shelf { gap: 30px 1px; padding: 24px 10px 17px; }
  .shelf:nth-child(odd) { padding-right: calc(13% + 10px); }
  .shelf:nth-child(even) { padding-left: calc(13% + 10px); }
  .shelf::before { width: 13%; }
  .frame { max-width: min(130px, 25%); max-height: 190px; padding: 6px; margin: 0 6px; }
  .book { font-size: 13px; padding: 28px 0; letter-spacing: .02em; }
  .read, .reading { padding-top: 38px; }
  .read::before, .reading::before { top: 19px; }
  .w1 { width: 38px; } .w2 { width: 43px; } .w3 { width: 48px; font-size: 13.5px; }
  .h1 { height: 195px; } .h2 { height: 220px; } .h3 { height: 245px; } .h4 { height: 270px; }
  .leaf { padding: 30px 20px 40px; margin: 16px 10px 40px; font-size: 18px; line-height: 1.7; }
  .empty { padding: 60px 20px; }
}
@media (prefers-reduced-motion: reduce) { .book { transition: none; } }
