/* ============================================================
   14 — Book Club · "Reading Room"
   Warm library light. Editorial serif, drop cap, gold stars.
   Font: Fraunces.
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 300 800; font-style: normal; font-display: swap;
}

:root {
  --bg: #FAF4E9;
  --paper: #FFFCF6;
  --hairline: #E6DAC5;
  --ink: #2A2118;
  --muted: #796853;
  --wine: #7A2E36;
  --gold: #C08A2E;
  --star-empty: #A07C28;   /* 3.79:1 on paper — gold, not the grey it was */
  --star-full:  #7A4A08;   /* 7.30:1 — deep enough to read as filled */

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` loses to any author `display` rule
   below, and every demo here toggles `element.hidden` to show and hide
   panels. Without this, hiding silently stops working. */
[hidden] { display: none !important; }

/* A long unbroken token -- a pasted URL, a 200-character "word" -- must wrap
   rather than push its container past its grid track and break the row.
   `anywhere` rather than `break-word` on purpose: only `anywhere` reduces the
   element's min-content width, and a grid or flex item defaults to
   `min-width: auto`, which refuses to shrink below its longest word. With
   `break-word` alone, demo-06 and demo-10 still blew 1.4k px past the viewport.
   The `min-width: 0` below is the other half of the same fix. */
h1, h2, h3, h4, p, li, a, span, strong, em, code, label, time,
button, input, textarea { overflow-wrap: anywhere; }
.card, .post, .listing, .idea, .topic, .question, .profile-card, .submission,
.lesson, .resource, .nominee, .archive-item, .member-card, .comment, .reply,
.answer, .idea-body-wrap { min-width: 0; }


body {
  margin: 0;
  padding-block-end: 88px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.72;
  font-optical-sizing: auto;
}

.wrap { max-width: 720px; margin-inline: auto; padding: 0 20px; }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }
a { color: var(--wine); }

:focus-visible { outline: 2px solid var(--wine); outline-offset: 3px; border-radius: 5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar {
  padding-block: clamp(44px, 7vw, 82px) 26px;
  display: flex; flex-wrap: wrap; gap: 18px;
  justify-content: space-between; align-items: flex-end;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 34px;
}
.topbar h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.04;
  font-weight: 600;
  letter-spacing: -0.028em;
}
.topbar > div > p { color: var(--muted); max-width: 44ch; margin-top: 12px; font-size: 16px; }

.identity-picker {
  font-family: var(--sans);
  font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted);
}
.identity-picker select {
  font-family: var(--sans); font-size: 14px;
  letter-spacing: 0; text-transform: none;
  margin-left: 6px; min-height: 44px; padding: 9px 12px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 7px;
}

.section-label {
  font-family: var(--sans);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--wine);
  margin: 0 0 14px;
}

/* ---------- Current pick ---------- */

.current-pick {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 32px 34px 30px;
  margin-bottom: 40px;
  box-shadow: 0 26px 54px -42px rgba(42,33,24,0.7);
}

.media-type {
  display: inline-block;
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--paper); background: var(--wine);
  border-radius: 3px; padding: 3px 9px;
  margin-bottom: 12px;
}

.pick-title {
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

.avg-rating {
  font-family: var(--sans); font-size: 12.5px;
  letter-spacing: 0.09em;
  color: var(--muted);
  display: block; margin-bottom: 20px;
}

/* ---------- Stars ---------- */

.star-rate { display: flex; gap: 2px; margin-bottom: 22px; }
.star-btn {
  font: inherit; font-size: 0; line-height: 1; cursor: pointer;
  min-width: 44px; min-height: 44px; padding: 4px;
  background: transparent; border: 0;
  transition: transform 120ms ease;
}
/* The literal glyph in the markup is hidden and redrawn here so the two states
   differ by SHAPE as well as colour — hollow when unrated, solid when rated.
   Colour alone would fail WCAG 1.4.1, and the old pale fill measured 1.26:1
   against the paper, which made the whole control nearly invisible. */
.star-btn::before {
  content: "\2606";                    /* hollow star */
  font-size: 30px;
  color: var(--star-empty);
  transition: color 120ms ease;
}
.star-btn:hover::before,
.star-btn.is-active::before {
  content: "\2605";                    /* solid star */
  color: var(--star-full);
}
.star-btn:hover { transform: translateY(-2px); }

/* ---------- Discussion ---------- */

.comments { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 18px; }
.comments:empty { margin: 0; }
.comment { border-top: 1px solid var(--hairline); padding-top: 16px; }
.comments > .comment:first-child { border-top: 0; padding-top: 0; }

.comment-meta {
  font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.comment-meta strong { color: var(--ink); font-weight: 700; }
.comment-body { margin: 0; font-size: 16.5px; }

/* A drop cap on the opening comment — the reading-room flourish. */
.comments > .comment:first-child .comment-body::first-letter {
  float: left;
  font-size: 3.05em;
  line-height: 0.82;
  font-weight: 600;
  color: var(--wine);
  padding: 0.06em 0.09em 0 0;
}

/* ---------- Forms ---------- */

.field { display: block; margin-bottom: 14px; }
.field label {
  font-family: var(--sans); display: block;
  font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 11px 13px; min-height: 44px;
}
.field textarea { resize: vertical; min-height: 4.5rem; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--wine); }

.btn {
  font-family: var(--sans); font-size: 12.5px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.1em; text-transform: uppercase;
  min-height: 44px; padding: 12px 22px;
  background: var(--wine); color: var(--paper);
  border: 0; border-radius: 6px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -14px var(--wine); }

.btn-ghost {
  font-family: var(--sans); font-size: 12px; cursor: pointer;
  letter-spacing: 0.06em;
  min-height: 44px; padding: 10px 16px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 6px;
  transition: color 140ms ease, border-color 140ms ease;
}
.btn-ghost:hover { color: var(--wine); border-color: var(--wine); }

/* ---------- Archive ---------- */

.archive-list { list-style: none; margin: 0 0 40px; padding: 0; }
.archive-item {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: baseline;
  padding: 15px 0;
  border-bottom: 1px solid var(--hairline);
}
.archive-item:first-child { border-top: 1px solid var(--hairline); }
.archive-item .media-type { margin-bottom: 0; }
.archive-item strong { font-weight: 600; font-size: 18px; }
.archive-item .avg-rating { margin-bottom: 0; }

/* ---------- Nominations ---------- */

.nominate-section > h2 {
  font-size: clamp(23px, 3.2vw, 32px);
  letter-spacing: -0.025em;
  margin-bottom: 18px;
}
.nominee-list { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 10px; }
.nominee {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: center;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 14px 18px;
}
.nominee-votes {
  /* inline-block, not inline: motion.js scales this on every vote and
     `transform` does not apply to a non-replaced inline box. */
  display: inline-block;
  font-family: var(--sans); font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--wine);
  margin-right: 6px;
}

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 88px; display: grid; gap: 8px; z-index: 50; }
.toast {
  font-family: var(--sans); font-size: 13px;
  background: var(--ink); color: var(--bg);
  border-radius: 6px; padding: 12px 16px;
  box-shadow: 0 18px 38px -22px rgba(42,33,24,0.8);
}
.toast.error { background: var(--wine); color: var(--paper); }

/* ---------- Motion ---------- */

.motion .current-pick, .motion .archive-item, .motion .nominee { opacity: 0; }

@media (max-width: 560px) {
  .current-pick { padding: 24px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .motion .current-pick, .motion .archive-item, .motion .nominee { opacity: 1 !important; transform: none !important; }
  .btn, .btn-ghost, .star-btn { transition: none !important; }
}


/* ---------- Stars with presence, archive as spines ---------- */
/* The rating control was small and grey on an otherwise elegant page. Larger
   and warmer, and the archive now reads as books on a shelf. */

.star-btn::before { font-size: 40px; -webkit-text-stroke: 0.5px rgba(122,46,54,0.30); }
.star-btn { min-width: 54px; }
.star-rate { gap: 6px; margin-bottom: 26px; }

.archive-list { display: grid; gap: 10px; }
.archive-item {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 7px solid var(--wine);
  border-radius: 3px;
  padding: 16px 20px;
}
.archive-item:first-child { border-top: 1px solid var(--hairline); }
.archive-item:nth-child(2n) { border-left-color: var(--gold); }

.section-label { border-bottom: 2px solid var(--wine); padding-bottom: 7px; }


/* ---------- The book on the table ---------- */
/* A reading room that never shows a book. The current pick now sits as an
   object — a drawn cover with a spine and board edge — beside the rating and
   the discussion, and the archive reads as titles on a shelf. */

@media (min-width: 900px) {
  .wrap { max-width: 1000px; }

  .current-pick {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    column-gap: 46px;
    align-items: start;
  }
  /* The cover is drawn rather than loaded, and carries no text: the section is
     itemscope'd as a Selection, so nothing here may add an attribute to it and
     `content: attr(...)` is out. The <h2> next to it is the title. */
  .current-pick::before {
    content: "";
    grid-column: 1; grid-row: 1 / span 30;
    align-self: start;
    aspect-ratio: 2 / 3;
    background:
      linear-gradient(90deg, rgba(0,0,0,0.34) 0 15px, rgba(255,255,255,0.11) 15px 18px, transparent 18px),
      linear-gradient(255deg, rgba(255,255,255,0.10), transparent 46%),
      repeating-linear-gradient(0deg, rgba(0,0,0,0.05) 0 2px, transparent 2px 4px),
      var(--wine);
    border-radius: 3px 7px 7px 3px;
    box-shadow: 0 26px 44px -26px rgba(40,16,20,0.85),
                inset -1px 0 0 rgba(255,255,255,0.10);
  }
  /* A blind-stamped rule on the cloth, the way a plain hardback is finished. */
  .current-pick { position: relative; }
  .current-pick::after {
    content: "";
    position: absolute; left: 2.4rem; top: 2.2rem;
    width: 8.6rem; height: 1px;
    background: rgba(243,233,216,0.34);
  }
  .current-pick > * { grid-column: 2; }
}

/* Archive as a shelf: the wine/gold edge already reads as a spine, so give the
   run a shelf line to stand on and set the titles like lettering. */
.archive-list { border-bottom: 3px solid var(--wine); padding-bottom: 10px; }
.archive-item { border-radius: 2px 5px 5px 2px; }
.archive-item strong, .archive-item b { letter-spacing: -0.01em; }


/* --- corrections after review --- */
@media (min-width: 900px) {
  /* Both were grid items at default stretch: the BOOK chip rendered as a
     620px maroon bar across the column, and Submit rating as a full-width
     slab. Neither is a full-width control. */
  .current-pick > .media-type { justify-self: start; }
  .current-pick > #pl-submit-rating { justify-self: start; }

  /* Clear of the spine. */
  .current-pick::after { left: 3.6rem; width: 7.4rem; }
}
