/* Review and book surfaces.
   Loud where the design says loud (score gauge, card edges, crop marks) and
   quiet everywhere the reader is actually reading. Tokens only. */

/* ── Archive heads ─────────────────────────────────────────────────────────────
   Archives are traffic surfaces, not afterthoughts: a real H1 and a real intro
   paragraph, both indexable. */
.archive-title {
  font-size: var(--step-h1);
  line-height: var(--lh-heading);
  letter-spacing: var(--track-heading);
  max-width: 20ch;
}

.archive-intro {
  margin-top: var(--space-lg);
  max-width: var(--measure-reading);
  font-size: var(--step-body-lg);
  line-height: 1.62;
  color: var(--text-secondary);
}

.archive-intro + .shelf,
.archive-intro + * {
  margin-top: var(--space-2xl);
}

/* ── Media placeholder ─────────────────────────────────────────────────────── */
.media-slot {
  aspect-ratio: var(--ratio, 16 / 10);
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(
    -45deg,
    var(--surface-sunken) 0 10px,
    var(--surface-card) 10px 20px
  );
  border-bottom: var(--border-width) solid var(--border-hairline);
}

.media-slot-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  /* The kit chips this label on every media slot, not just the framed variant:
     bare text floating on the stripes read as a caption that had lost its box. */
  background: var(--bg-page);
  border: var(--border-width) solid var(--border-hairline);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  max-width: calc(100% - var(--space-xl));
  text-align: center;
}

/* ── Score gauge ───────────────────────────────────────────────────────────── */
.score-gauge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--signal) var(--pct, 0%),
    var(--border-hairline) var(--pct, 0%) 100%
  );
  box-shadow: var(--shadow-card);
  flex: none;
}

.score-gauge[data-size="lg"] {
  width: 96px;
  height: 96px;
}

.score-gauge-face {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface-card);
  display: grid;
  place-items: center;
  align-content: center;
}

.score-gauge[data-size="lg"] .score-gauge-face {
  width: 82px;
  height: 82px;
}

.score-gauge-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.score-gauge[data-size="lg"] .score-gauge-value {
  font-size: 1.75rem;
}

.score-gauge-scale {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: 0.1em;
  color: var(--text-muted);
  line-height: 1;
}

/* ── Shelf ─────────────────────────────────────────────────────────────────── */
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

/* Two real columns, not auto-fill. auto-fill kept reserving a third 420px
   track on a wide viewport, so a two-title shelf sat in the left two thirds
   with dead space beside it. */
.shelf-grid[data-cols="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shelf-item[hidden] {
  display: none;
}

.shelf-empty {
  color: var(--text-secondary);
  max-width: var(--measure-narrow);
}

/* ── Segmented filter ──────────────────────────────────────────────────────── */
.segmented {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--border-hairline);
  border-radius: var(--radius-sm);
}

.segmented-option {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--surface-card);
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.segmented-option:first-child { border-radius: 3px 0 0 3px; }
.segmented-option:last-child  { border-radius: 0 3px 3px 0; }

.segmented-option:hover { color: var(--text-primary); }

.segmented-option[aria-pressed="true"] {
  background: var(--signal);
  color: var(--text-on-signal);
}

/* ── Review card ───────────────────────────────────────────────────────────── */
.review-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.review-card:hover,
.review-card:focus-within {
  transform: translateY(-2px);
  border-color: var(--signal);
  box-shadow: var(--shadow-raised);
}

.review-card-figure {
  position: relative;
}

.review-card-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-bottom: var(--border-width) solid var(--border-hairline);
}

.review-card-figure .score-gauge {
  position: absolute;
  right: var(--space-md);
  bottom: calc(var(--space-lg) * -1);
}

.review-card-body {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 1;
}

.review-card-meta {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

.review-card-topic {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.review-card-title {
  font-size: var(--step-h3);
  line-height: 1.2;
}

.review-card-title a {
  color: inherit;
  text-decoration: none;
}

.review-card-title a:hover {
  color: var(--text-signal);
  text-decoration: none;
}

.review-card-verdict {
  color: var(--text-secondary);
  font-size: var(--step-small);
  line-height: 1.62;
}

/* Spec ticks on the card: hairline-separated rows, mono, right-aligned value. */
.spec-ticks {
  margin: auto 0 0;
  display: grid;
  gap: 1px;
  background: var(--border-hairline);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.spec-ticks > div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 8px 10px;
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: var(--step-mono);
}

.spec-ticks dt { color: var(--text-muted); }
.spec-ticks dd { margin: 0; color: var(--text-primary); text-align: right; }

/* ── Review header ─────────────────────────────────────────────────────────── */
.review-header {
  padding-block: var(--section-y) var(--space-2xl);
  border-bottom: var(--border-width) solid var(--border-hairline);
  background: var(--bg-page-alt);
}

.review-header .eyebrow { margin-bottom: var(--space-lg); }

.review-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
}

.review-header-title {
  font-size: var(--step-display);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  max-width: 18ch;
}

.review-header-dek {
  margin-top: var(--space-lg);
  max-width: var(--measure-reading);
  font-size: 1.3125rem;
  line-height: 1.62;
  font-weight: var(--weight-light);
  color: var(--text-secondary);
}

.review-header-meta {
  margin: var(--space-xl) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: var(--border-width) solid var(--border-hairline);
}

.review-header-meta > div {
  padding: var(--space-md) var(--space-md) 0;
  border-left: var(--border-width) solid var(--border-hairline);
}

.review-header-meta > div:first-child {
  padding-left: 0;
  border-left: none;
}

.review-header-meta dt {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.review-header-meta dd {
  margin: 6px 0 0;
  font-size: var(--step-body);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* ── Spec table (inside the reading column, breaks the measure) ────────────── */
.table-scroll {
  overflow-x: auto;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--step-mono);
}

.spec-table th,
.spec-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: var(--border-width) solid var(--border-hairline);
  vertical-align: top;
}

.spec-table th {
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  width: 34%;
}

.spec-table td { color: var(--text-primary); }

.spec-table tr:first-child th,
.spec-table tr:first-child td {
  border-top: var(--border-width) solid var(--border-hairline);
}

/* ── Pros and cons ─────────────────────────────────────────────────────────── */
.verdict-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.verdict-panel {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
}

/* The one place a left accent is semantic rather than decorative. */
.verdict-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--border-width-thick);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.verdict-panel[data-tone="pro"]::before { background: var(--signal); }
.verdict-panel[data-tone="con"]::before { background: var(--flare); }

.verdict-panel-title {
  font-size: var(--step-h4);
  margin-bottom: var(--space-md);
}

.verdict-panel ul {
  margin: 0;
  padding-left: 1.1em;
  display: grid;
  gap: var(--space-sm);
  color: var(--text-body);
  font-size: var(--step-body);
  line-height: var(--lh-snug);
}

.verdict-panel li::marker { color: var(--text-muted); }

/* ── Verdict block ─────────────────────────────────────────────────────────── */
.verdict {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
}

.verdict::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--border-width-thick);
  background: var(--grad-edge);
}

.verdict-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.verdict-title {
  font-size: var(--step-h2);
}

.verdict-body {
  margin-top: var(--space-md);
  font-size: var(--step-body-lg);
  line-height: 1.62;
  color: var(--text-body);
  max-width: var(--measure-reading);
}

.score-breakdown {
  margin: var(--space-xl) 0 0;
  display: grid;
  gap: var(--space-sm);
}

.score-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: var(--space-md);
}

.score-row dt {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.score-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.score-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border-hairline);
  position: relative;
  overflow: hidden;
}

.score-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--signal);
  transform-origin: left center;
}

/* The bars draw themselves as the breakdown scrolls into view, so the reader
   sees the shape of the score rather than arriving at a finished chart. Scroll
   linked, so it costs nothing on browsers without it and never runs on a loop. */
@supports (animation-timeline: view()) {
  .score-bar::after {
    transform: scaleX(0);
    animation: wipe-in linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 30%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .score-bar::after {
    animation: none;
    transform: none;
  }
}

.score-num {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-primary);
  min-width: 2.5ch;
  text-align: right;
}

/* ── Book card ─────────────────────────────────────────────────────────────── */
.book-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--space-lg);
  padding: var(--space-lg);
  height: 100%;
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.book-card:hover,
.book-card:focus-within {
  transform: translateY(-2px);
  border-color: var(--signal);
  box-shadow: var(--shadow-raised);
}

.book-card-cover-slot .media-slot,
.book-card-cover {
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-hairline);
  width: 100%;
  height: auto;
}

.book-card-body {
  display: grid;
  gap: var(--space-xs);
  align-content: start;
  min-width: 0;
}

.book-card-meta {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  align-items: center;
}

.book-card-publisher {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.book-card-title {
  font-size: var(--step-h4);
  line-height: 1.25;
  margin-top: 2px;
}

.book-card-title a { color: inherit; text-decoration: none; }
.book-card-title a:hover { color: var(--text-signal); text-decoration: none; }

.book-card-subtitle {
  color: var(--text-secondary);
  font-size: var(--step-small);
  line-height: 1.6;
}

.book-card-note {
  color: var(--text-muted);
  font-size: var(--step-mono);
  font-family: var(--font-mono);
  line-height: 1.55;
  margin-top: 2px;
}

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.progress {
  margin-top: var(--space-xs);
  display: grid;
  gap: 6px;
}

.progress-track {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-sunken);
  border: var(--border-width) solid var(--border-hairline);
  overflow: hidden;
  display: block;
}

.progress-fill {
  display: block;
  width: var(--pct, 0%);
  height: 100%;
  background: var(--signal);
}

.progress-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  color: var(--text-muted);
}

/* ── Single book ───────────────────────────────────────────────────────────── */
.book-detail {
  padding-block: var(--section-y);
  border-bottom: var(--border-width) solid var(--border-hairline);
  background: var(--bg-page-alt);
}

.book-detail-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}

.book-detail-cover-slot .media-slot,
.book-detail-cover {
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-hairline);
  width: 100%;
  height: auto;
}

.book-detail-copy { display: grid; gap: var(--space-md); align-content: start; }

.book-detail-title {
  font-size: var(--step-display);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
}

.book-detail-subtitle {
  font-size: 1.3125rem;
  line-height: 1.62;
  font-weight: var(--weight-light);
  color: var(--text-secondary);
  max-width: var(--measure-reading);
}

.book-detail-synopsis {
  color: var(--text-body);
  font-size: var(--step-body-lg);
  line-height: var(--lh-body);
  max-width: var(--measure-reading);
}

.book-detail-actions { margin-top: var(--space-sm); }

.section-title {
  font-size: var(--step-h2);
  margin-bottom: var(--space-lg);
}

.learn-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md) var(--space-xl);
  max-width: var(--container);
}

.learn-list li {
  padding-left: var(--space-lg);
  position: relative;
  color: var(--text-body);
  font-size: var(--step-body);
  line-height: var(--lh-snug);
  padding-block: var(--space-xs);
  border-top: var(--border-width) solid var(--border-hairline);
}

.learn-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: calc(var(--space-xs) + 0.62em);
  width: 10px;
  height: 2px;
  background: var(--signal);
}

/* ── Chapter outline ───────────────────────────────────────────────────────── */
.outline-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
}

.outline-row {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr) auto;
  gap: var(--space-md);
  align-items: baseline;
  padding: var(--space-md) 0;
  border-top: var(--border-width) solid var(--border-hairline);
}

.outline-row:last-child {
  border-bottom: var(--border-width) solid var(--border-hairline);
}

.outline-num {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-muted);
}

.outline-title {
  color: var(--text-primary);
  font-size: var(--step-body);
}
.outline-title-link {
  color: var(--text-primary);
  font-size: var(--step-body);
  text-decoration: none;
  transition: color var(--speed-fast) var(--ease-out);
}

.outline-title-link:hover,
.outline-title-link:focus-visible {
  color: var(--text-signal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The number turns too, so the row reads as one target. */
.outline-row:has(.outline-title-link:hover) .outline-num {
  color: var(--text-signal);
}


.outline-status {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.outline-row[data-status="drafted"] .outline-status { color: var(--text-signal); }

/* ── Mobile collapse ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .review-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-lg);
  }
  .review-header-title { max-width: 100%; }
  .verdict-split { grid-template-columns: 1fr; }
  .book-detail-grid { grid-template-columns: 1fr; }
  .book-detail-cover-slot { max-width: 200px; }
  .shelf-grid,
  .shelf-grid[data-cols="2"] { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .book-card { grid-template-columns: 72px 1fr; gap: var(--space-md); }
  .score-row { grid-template-columns: 100px 1fr; }
  .review-header-meta > div { padding-left: var(--space-md); }
}


/* ── Shelf toolbar ─────────────────────────────────────────────────────────
   Filter plus a live count, mirroring the kit's reviews index. The topic row
   under it reuses .tag-filter from the writing index. */
.shelf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.shelf-count {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-muted);
}

.shelf .tag-filter { margin-bottom: var(--space-lg); }

.review-header .breadcrumbs { margin-bottom: var(--space-xl); }

.review-header .share-row { margin-top: var(--space-lg); }

/* ── Outline, boxed ────────────────────────────────────────────────────────────
   The index shows the current title's outline as a single bordered object so it
   reads as one thing beside the sample code. The single book page keeps the
   open ruled list, which suits a full-width column better. */
.outline-list[data-boxed="true"] {
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.outline-list[data-boxed="true"] .outline-row {
  padding: var(--space-md) var(--space-lg);
  background: var(--surface-card);
  border-top: var(--border-width) solid var(--border-hairline);
}

.outline-list[data-boxed="true"] .outline-row:first-child {
  border-top: none;
}

.outline-list[data-boxed="true"] .outline-row:last-child {
  border-bottom: none;
}

.outline-note {
  margin-top: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-muted);
}

.outline-row[data-status="in-progress"] .outline-status {
  color: var(--text-flare);
}

/* ── Book band: outline beside the sample ──────────────────────────────────── */
.book-band-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2xl);
  align-items: start;
  margin-top: var(--space-2xl);
}

.book-band-aside {
  display: grid;
  gap: var(--space-lg);
  align-content: start;
}

@media (max-width: 860px) {
  .book-band-split {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }
}
