/* Media page (PW-023): the anime chapter (live AniList data), the film, book and game shelves, and
   the guided picker, in the site's light system. Loaded by media.html only. */

.anime-source { margin-top: 1.25rem; }

/* Jump links under the page title */
.media-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 1rem;
}

.media-jump a { color: var(--muted); text-decoration: none; padding-block: 0.35rem; }
.media-jump a:hover { color: var(--accent); }

/* Chapters: anime, film & tv, books, games. A kicker, a big title, then that medium's sections. */
.media-chapter { padding-top: clamp(48px, 6vw, 88px); }
.media-chapter > .anime-section:first-of-type { padding-top: clamp(24px, 3vw, 40px); }
section.media-chapter { padding-bottom: 0; }
#anime > .anime-section:last-child { padding-bottom: 0; }
.media-chapter:last-of-type { padding-bottom: var(--section); }

.chapter-head { margin-bottom: clamp(24px, 3vw, 40px); }
.chapter-kicker { color: var(--accent); margin-bottom: 0.5rem; }

.chapter-title {
  font-size: clamp(2.25rem, 1.4rem + 3.2vw, 4rem);
  line-height: 1;
  letter-spacing: -0.035em;
  margin-bottom: 0.75rem;
}

.chapter-head .section-subtitle a { color: inherit; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  cursor: pointer;
}
.anime-source a { color: var(--accent); }
.anime-source .is-error { color: var(--signal); }

.anime-section .section-head { margin-bottom: clamp(20px, 2.5vw, 32px); }

.anime-empty {
  font-family: var(--font-mono);
  font-size: var(--step-small);
  color: var(--muted);
  padding: 1.25rem;
  background: var(--surface);
}

/* Watching now */
.watch-list {
  list-style: none;
  display: grid;
  gap: 2px;
}

.watch-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  padding: 0.75rem 1rem 0.75rem 0.75rem;
}

.watch-item img,
.cover-fallback {
  width: 46px;
  height: 65px;
  object-fit: cover;
  background: var(--surface-2);
}

.watch-title {
  font-weight: 500;
  text-decoration: none;
  display: block;
  margin-bottom: 0.35rem;
}

.watch-title:hover { color: var(--accent); }

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.25rem;
}

.progress {
  height: 4px;
  background: var(--surface-2);
  margin: 0.5rem 0 0.4rem;
  max-width: 28rem;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Perfect scores: a contact sheet of covers */
.cover-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 1.25rem 0.9rem;
}

.cover-grid a {
  display: grid;
  gap: 0.45rem;
  text-decoration: none;
}

.cover-grid img,
.cover-grid .cover-fallback {
  width: 100%;
  height: auto;
  aspect-ratio: 23 / 33;
  object-fit: cover;
  background: var(--surface);
  outline: 2px solid transparent;
  outline-offset: 3px;
  transition: outline-color var(--fast) var(--ease);
}

.cover-grid a:hover img,
.cover-grid li.picked img { outline-color: var(--accent); }

.cover-grid .cover-title {
  font-size: var(--step-small);
  line-height: 1.3;
}

.cover-grid li.picked .cover-title { color: var(--accent); }

/* Top lists (loved anime, Film & TV): a mono "Top 10" label, rank numbers, and a Show all / Show fewer toggle */
.top-label { margin-bottom: 0.9rem; }

.top-shelf { counter-reset: rank; }
.top-shelf > li { counter-increment: rank; }

.top-shelf > li::before {
  content: counter(rank, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}

.cover-grid.top-shelf > li { display: grid; align-content: start; gap: 0.45rem; }

/* The loved top ten is a fixed 5 x 2 grid from tablet width up, kept compact on wide screens.
   Phones drop to 2 columns (5 rows): five covers across 390px would be about 60px each, too narrow
   for the titles. */
.cover-grid.top-shelf {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 56rem;
  gap: 1.5rem 1.25rem;
}
@media (max-width: 640px) {
  .cover-grid.top-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 24rem; }
}
.cover-grid .stub { display: grid; gap: 0.45rem; }

.more-bar { margin-block: 1.5rem; }
#perfectMore, #filmMore { margin-top: 1.25rem; }
#perfectMore[hidden], #filmMore[hidden] { display: none; }

/* Taste: By the numbers tiles beside the score columns */
.taste-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: clamp(40px, 5vw, 64px) clamp(32px, 4vw, 64px);
}

.chart h4 {
  font-size: var(--step-lead);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.chart .insight {
  color: var(--muted);
  margin-bottom: 1.1rem;
  max-width: 34rem;
}

/* By the numbers: four tiles, 2 x 2 at every width, so the block sits level with the score chart beside it */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}

.stat-grid > div {
  background: var(--surface);
  padding: 1rem 1.1rem 1.1rem;
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.stat-grid dt {
  order: 2;
  font-family: var(--font-mono);
  font-size: var(--step-small);
  color: var(--muted);
}

.stat-grid dd {
  order: 1;
  font-family: var(--font-mono);
  font-size: var(--step-head);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Vertical columns: score distribution */
.columns {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
}

.columns .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  height: 100%;
}

.columns .col span {
  display: block;
  background: var(--ink);
  opacity: 0.72;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}

.columns .col:hover span { opacity: 1; }
.columns .col.is-key span { background: var(--accent); opacity: 1; }

.columns .val {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.25rem;
}

.axis {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--step-small);
  color: var(--muted);
}

.axis.even span { flex: 1 1 0; text-align: center; }

/* Where I disagree with everyone */
.takes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 2rem clamp(32px, 4vw, 64px);
}

.takes h4 {
  font-size: var(--step-lead);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.take-list { list-style: none; }

.take-list li {
  display: grid;
  grid-template-columns: 1fr auto 3rem;
  gap: 1rem;
  align-items: baseline;
  padding-block: 0.6rem;
  border-top: 1px solid var(--rule);
}

.take-list a { text-decoration: none; }
.take-list a:hover { color: var(--accent); }

.take-list .gap {
  font-family: var(--font-mono);
  text-align: right;
}

.take-list .gap.up { color: var(--accent); }

/* Shelves: hand-picked films, books and games, as quiet cards */
.shelf {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  grid-auto-flow: dense;
  gap: 2px;
}

.shelf-item {
  background: var(--surface);
  padding: 1.25rem 1.25rem 1.4rem;
  display: grid;
  align-content: start;
  gap: 0.4rem;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color var(--fast) var(--ease);
}

.shelf-item { position: relative; }
.shelf-item h3 { font-size: var(--step-lead); font-weight: 500; line-height: 1.2; }

/* The title is the link; its ::before stretches over the whole card so the card is the click target.
   The arrow is a cue (with a spoken alternative), not text, so it never reaches the picker. */
.shelf-item h3 a { color: inherit; text-decoration: none; }
.shelf-item h3 a::before { content: ''; position: absolute; inset: 0; }
.shelf-item h3 a::after {
  content: '\2197' / ' (opens in a new tab)';
  font-family: var(--font-mono);
  font-size: 0.75em;
  margin-left: 0.35em;
  color: var(--muted);
  transition: color var(--fast) var(--ease);
}
.shelf-item:hover h3 a,
.shelf-item h3 a:hover { color: var(--accent); }
.shelf-item:hover h3 a::after,
.shelf-item h3 a:focus-visible::after { color: var(--accent); }
.shelf-item h3 a:focus-visible { outline: none; }
.shelf-item:has(h3 a:focus-visible) { outline-color: var(--accent); outline-width: 3px; }
.shelf-item p:last-child { color: var(--muted); }
.shelf-item.is-top { grid-column: span 2; }
.shelf-item.is-top h3 { font-size: var(--step-head); }
.shelf-item.picked { outline-color: var(--accent); }

/* Guided picker: a small button under the intro that opens the questions inline */
.media-pick { margin-top: 1.25rem; }

.pick-toggle::after {
  content: '+';
  margin-left: 0.6rem;
  font-family: var(--font-mono);
}

.pick-toggle[aria-expanded="true"]::after { content: '\2212'; }

.picker {
  background: var(--surface);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-top: 1rem;
  max-width: 60rem;
}

.picker-steps {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-bottom: 1.25rem;
}

.picker-steps li.is-current { color: var(--accent); }
.picker-steps li.is-done { color: var(--ink); }

.picker-q {
  font-size: var(--step-lead);
  font-weight: 500;
  margin-bottom: 1rem;
}

.picker-q:focus, .pick-title:focus { outline: none; }

.picker-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 2px;
}

.picker-option {
  display: grid;
  gap: 0.2rem;
  text-align: left;
  min-height: 56px;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.picker-option:hover { border-color: var(--accent); }
.picker-option .meta { font-size: 0.8rem; }
.picker-nav { margin-top: 1rem; }
.picker-wait { padding: 1rem 0; }

.pick-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

.pick-card:has(img) { grid-template-columns: minmax(96px, 150px) 1fr; }
.pick-card img { width: 100%; height: auto; aspect-ratio: 23 / 33; object-fit: cover; background: var(--surface-2); }
.pick-card > div { display: grid; gap: 0.5rem; max-width: 44rem; }
.pick-title { font-size: var(--step-head); }
.picker-why { color: var(--accent); }

.picker-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 0.5rem;
}

@media (max-width: 560px) {
  .shelf-item.is-top { grid-column: auto; }
  .pick-card:has(img) { grid-template-columns: 88px 1fr; }
  .columns { height: 128px; }
  .columns .val { display: none; }
  .cover-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
