/* ---------------------------------------------------------------------------
   Comparative Analysis — one global stylesheet.
   Palette and card treatment follow the house style used across these
   projects: cream ground, navy text, white cards at 16px radius with a soft
   shadow. One accent is added: a muted brass for excerpt numerals and section
   rules, which reads as "recital programme" next to the navy and cream.
--------------------------------------------------------------------------- */

:root {
  --cream: #f4f2ec;
  --navy: #22223b;
  --muted: #6b7280;
  --line: #e2ded4;
  --brass: #9a7b4f;
  --white: #fff;
  --warn: #b91c1c;

  --radius: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --measure: 68ch;
  --page: 1080px;
  /* An analysis reads straight down a single column, so the column is sized
     for the video: wide enough for a 16:9 player to carry detail, narrow
     enough that the commentary beneath it keeps a readable measure. */
  --article: 880px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule is a plain `display: none`, which any
   author `display` declaration beats. Several things here are flex or grid
   AND start hidden until JavaScript enables them (the filter bar, the compare
   bar, its buttons), so without this they would sit there visible and dead
   for a reader with JavaScript off. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--cream);
  color: var(--navy);
  line-height: 1.55;
}

img { max-width: 100%; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy);
  color: var(--cream);
  padding: 0.7rem 1.1rem;
  z-index: 20;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* --- site bar ------------------------------------------------------------ */

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 242, 236, 0.92);
  backdrop-filter: saturate(1.4) blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-bar__title {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-bar__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.95rem;
}
.site-bar__nav a { text-decoration: none; color: var(--muted); }
.site-bar__nav a:hover { color: var(--navy); }

/* --- buttons ------------------------------------------------------------- */

.button {
  display: inline-block;
  background: var(--navy);
  color: var(--cream);
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.3rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: #2f2f52; }
.button--small { padding: 0.45rem 0.9rem; font-size: 0.9rem; border-radius: 8px; }
.button--quiet {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.button--quiet:hover { background: var(--white); color: var(--navy); }

/* --- shared page furniture ----------------------------------------------- */

main { padding: 0 clamp(1rem, 4vw, 2rem) 4rem; }

.analysis { max-width: var(--article); margin: 0 auto; }
.gallery { max-width: var(--page); margin: 0 auto; }

.section { margin: 3rem 0; }

.section__heading {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass);
  margin: 0 0 1.1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.prose {
  max-width: var(--measure);
  font-size: 1.05rem;
  line-height: 1.7;
}
.prose p { margin: 0 0 1.1em; }
.prose p:last-child { margin-bottom: 0; }

/* --- analysis hero ------------------------------------------------------- */

.hero {
  padding: clamp(2rem, 6vw, 3.5rem) 0 1.5rem;
  max-width: var(--measure);
}

.hero__eyebrow {
  margin: 0 0 0.8rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero__title {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.hero__byline {
  margin: 0.9rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.hero__work {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 1.1rem 0 0; padding: 0; }
.chip {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
}

/* --- score figure -------------------------------------------------------- */

.score {
  margin: 2rem 0 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.score img { display: block; border-radius: 8px; width: 100%; }
.score figcaption { margin-top: 0.7rem; font-size: 0.9rem; color: var(--muted); }

/* --- excerpts ------------------------------------------------------------
   Each excerpt is one card: who is playing, the recording, then the student's
   commentary on it. They stack, so the page reads intro / video / commentary /
   video / commentary / synthesis straight down.
-------------------------------------------------------------------------- */

.excerpt {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem clamp(1.1rem, 3vw, 1.75rem) 1.5rem;
  margin-bottom: 1.75rem;
}
.excerpt:last-child { margin-bottom: 0; }

.excerpt__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.excerpt__id { flex: 1 1 12rem; min-width: 0; }

.excerpt__performer {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.excerpt__source {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.excerpt__cue {
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

/* The commentary keeps its own reading measure even though the player above
   it runs the full width of the card. */
.excerpt__commentary { margin-top: 1.25rem; }

/* --- comparison mode -----------------------------------------------------
   Pick two or three excerpts and they reflow into columns: a smaller player
   with that performer's commentary underneath, so the recordings sit next to
   each other without separating any of them from its argument.
-------------------------------------------------------------------------- */

.compare-hint { margin: -0.4rem 0 1rem; font-size: 0.9rem; color: var(--muted); }

.compare-toggle {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  background: var(--white);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  min-height: 36px;
}
.compare-toggle:hover:not(:disabled) { border-color: var(--brass); color: var(--navy); }
.compare-toggle[aria-pressed="true"] {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--white);
  font-weight: 600;
}
.compare-toggle[aria-pressed="true"]::before { content: "✓ "; }
.compare-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

.comparebar {
  position: sticky;
  bottom: 1rem;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding: 0.8rem 1.1rem;
  background: var(--navy);
  color: var(--cream);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}
.comparebar__status { margin: 0; font-size: 0.92rem; }
.comparebar__actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.comparebar .button { background: var(--cream); color: var(--navy); }
.comparebar .button:hover { background: var(--white); }
.comparebar .button:disabled { opacity: 0.45; cursor: not-allowed; }
.comparebar .button--quiet {
  background: transparent;
  color: var(--cream);
  border: 1px solid rgba(244, 242, 236, 0.4);
}
.comparebar .button--quiet:hover { background: rgba(244, 242, 236, 0.12); color: var(--cream); }

/* Widened only while comparing. Prose blocks elsewhere on the page carry their
   own max-width, so nothing else stretches with it. */
body.is-comparing .analysis { max-width: 1280px; }

.excerpts[data-comparing] {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}
.excerpts[data-comparing="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.excerpts[data-comparing="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.excerpts[data-comparing] .excerpt { margin-bottom: 0; padding: 1rem; }
.excerpts[data-comparing] .excerpt__performer { font-size: 1rem; }
.excerpts[data-comparing] .excerpt__commentary { margin-top: 1rem; font-size: 0.97rem; }
.excerpts[data-comparing] .compare-toggle { font-size: 0.8rem; padding: 0.25rem 0.7rem; min-height: 32px; }

.numeral {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--brass);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --- players ------------------------------------------------------------- */

.player { display: flex; flex-direction: column; gap: 0.55rem; }

.player__stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  /* Shows through whenever a thumbnail is missing or fails to load, so an
     absent image still looks deliberate rather than broken. */
  background: linear-gradient(135deg, #2b2b47, #14142a);
}

.player__frame, .facade { width: 100%; height: 100%; border: 0; display: block; }

.player__frame--audio { aspect-ratio: auto; height: 152px; }
.player__stage:has(.player__frame--audio) { aspect-ratio: auto; height: 152px; background: none; }

.facade {
  position: relative;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

.facade__thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* hqdefault is 4:3 with letterbox bars; cover crops them away. */
  object-fit: cover;
}

.facade__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.05));
  transition: opacity 0.15s ease;
}
.facade:hover .facade__scrim { opacity: 0.6; }

.facade__play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.facade__play::after {
  content: "";
  position: absolute;
  left: 54%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent var(--navy);
}
.facade:hover .facade__play { transform: translate(-50%, -50%) scale(1.08); }

.facade__cue {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.player__open {
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
}
.player__open:hover { color: var(--navy); text-decoration: underline; }

.player__note { margin: 0; font-size: 0.85rem; color: var(--muted); }
.player__note--warn { color: var(--warn); }

.linkcard {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  height: 100%;
  padding: 1.2rem;
  color: #fff;
  text-decoration: none;
  text-align: center;
}
.linkcard__label { font-weight: 600; }
.linkcard__cue { font-variant-numeric: tabular-nums; opacity: 0.85; }
.linkcard__hint { font-size: 0.8rem; opacity: 0.65; }

/* --- synthesis and sources ----------------------------------------------- */

.synthesis {
  background: var(--white);
  border-left: 4px solid var(--brass);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  padding: 1.5rem clamp(1.2rem, 3vw, 2rem);
  font-size: 1.1rem;
}

.sources { font-size: 0.95rem; color: var(--muted); }
.sources a { overflow-wrap: anywhere; }

.analysis__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.analysis__permalink { color: var(--muted); overflow-wrap: anywhere; }
.page-analysis .analysis__permalink { display: none; }

/* --- gallery ------------------------------------------------------------- */

.gallery__hero { padding: clamp(2rem, 6vw, 3.5rem) 0 1.5rem; max-width: var(--measure); }
.gallery__hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.015em; }
.gallery__blurb { margin: 0.8rem 0 0; font-size: 1.1rem; color: var(--muted); }
.gallery__counts {
  margin: 1rem 0 1.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brass);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem;
  padding: 1rem;
  margin-bottom: 1.6rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter { display: flex; flex-direction: column; gap: 0.3rem; }
.filter--search { flex: 1 1 16rem; }
.filter__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.filter select, .filter input {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: inherit;
  min-height: 44px;
}
.filter select:focus, .filter input:focus { outline: none; border-color: var(--brass); }

.gallery__actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 0; }
.gallery__empty { color: var(--muted); }

.cards {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
.card[hidden] { display: none; }

.card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.card__banner {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2b2b47, #14142a);
  overflow: hidden;
}
.card__banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.card__count {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.card__body { padding: 1rem 1.1rem 0.6rem; flex: 1 1 auto; }
.card__title { margin: 0; font-size: 1.12rem; line-height: 1.3; overflow-wrap: anywhere; }
.card__work { margin: 0.3rem 0 0.6rem; font-size: 0.88rem; color: var(--brass); }
.card__summary {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.card__author { font-weight: 600; color: var(--navy); }

/* --- footer -------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer p { margin: 0; }

/* --- small screens ------------------------------------------------------- */

@media (max-width: 720px) {
  .excerpt { padding: 1.1rem 1rem 1.25rem; margin-bottom: 1.25rem; }
  .excerpt__performer { font-size: 1.05rem; }
  .site-bar { position: static; }

  /* Three columns on a phone would be three unwatchable videos. Comparison
     still filters the page down to the chosen excerpts, which is most of the
     value; they just stay stacked. */
  .excerpts[data-comparing="2"], .excerpts[data-comparing="3"] {
    grid-template-columns: 1fr;
  }
  .excerpts[data-comparing] .excerpt { margin-bottom: 0; }
  .comparebar { flex-direction: column; align-items: stretch; text-align: center; }
  .comparebar__actions { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
  .facade:hover .facade__play { transform: translate(-50%, -50%); }
}

/* --- print ---------------------------------------------------------------
   A printed analysis has to survive without players, so every player is
   replaced by its URL and cue. attr(href) is what keeps the evidence in a
   document whose whole subject is linked media.
-------------------------------------------------------------------------- */

@media print {
  :root { --cream: #fff; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-bar, .site-footer, .toolbar, .skip, .compare-toggle, .comparebar, .compare-hint,
  .player__stage, .facade, .player__note, .analysis__foot a { display: none !important; }

  /* Printing while comparing prints the comparison, which is the point. */
  .excerpts[data-comparing] { display: block; }

  .excerpt, .synthesis, .score, .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  .excerpt__commentary { margin-top: 0.6rem; }
  .prose, .hero { max-width: none; }
  .section__heading { color: #000; }

  .player__open { display: block; font-size: 9pt; color: #000; }
  .player__open::after { content: " — " attr(href); word-break: break-all; }

  .page-analysis .analysis__permalink { display: block; }
  p { orphans: 3; widows: 3; }
  a { text-decoration: none; }
}
