/* ============================================================================
   Palm Valley Church - Sermon Archive

   The palette is the church's own brand cyan, sampled from the logo lockup:
   #00AFE5. That colour is only 2.47:1 against white, so it can never be text -
   it is used for fills alone (spine bars, badges, the mark, focus). Interactive
   text uses a deepened version of the same hue that clears WCAG AA.

   Light only, by request. Every text colour below is measured against --paper:
     --ink 15.42:1   --muted 5.73:1   --brand-deep 5.55:1   --brand-strong 7.00:1
   The cyan hairline recurs as the only divider in the page.
   ========================================================================= */

:root {
  /* Fills only - never text. 2.47:1 on paper. */
  --brand:        #00AFE5;  /* the logo cyan, exact          */
  /* Text-safe members of the same hue. */
  --brand-deep:   #0A6E96;  /* links, hover        5.55:1    */
  --brand-strong: #065E80;  /* active, focus       7.00:1    */

  --paper:  #FBFCFD;  /* cool white page                     */
  --shade:  #EDF3F7;  /* pale blue-grey: cards, input        */
  --ink:    #0E2530;  /* blue-slate near-black    15.42:1    */
  --muted:  #4F6875;  /* dates, speakers, labels   5.73:1    */
  --hatch:  #7C93A0;  /* audio-only hatching, graphic only   */

  --rule: color-mix(in srgb, var(--brand) 30%, transparent);

  --display: "Bricolage Grotesque", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --title:   "Newsreader", "Iowan Old Style", Georgia, serif;

  --step--1: clamp(0.76rem, 0.74rem + 0.1vw, 0.82rem);
  --step-0:  clamp(0.94rem, 0.9rem + 0.2vw, 1rem);
  --step-1:  clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
  --step-2:  clamp(1.4rem, 1.2rem + 1vw, 2rem);
  --step-3:  clamp(1.9rem, 1.4rem + 2.4vw, 3.2rem);

  --gap: clamp(1rem, 0.6rem + 1.6vw, 1.75rem);
  --pad: clamp(1rem, 0.5rem + 3vw, 3.5rem);
  --radius: 3px; /* nearly square: the mark is drawn, not rounded */
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

:where(a) { color: inherit; }

/* One focus treatment everywhere, in the accent so it is unmistakable. */
:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 60;
  padding: 0.7em 1.1em;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--step--1);
  text-decoration: none;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* --------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0.85rem var(--pad);
  max-width: 1600px;
  margin-inline: auto;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  flex: 0 0 auto;
}

.wordmark__mark { width: 2.5rem; height: 2.5rem; color: var(--brand); flex: 0 0 auto; }

.wordmark__text { display: flex; flex-direction: column; line-height: 1.15; }

.wordmark__name {
  font-weight: 800;
  font-size: var(--step-0);
  letter-spacing: -0.02em;
}

.wordmark__sub {
  font-size: var(--step--1);
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Search is the primary control on the page, so it gets the room. */
.find {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  max-width: 32rem;
  margin-left: auto;
}

.find__label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.find__icon {
  position: absolute;
  left: 0.85rem;
  width: 1.05rem; height: 1.05rem;
  color: var(--muted);
  pointer-events: none;
}

.find input {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 0.6rem 0.9rem 0.6rem 2.5rem;
  background: var(--shade);
  border: 1px solid transparent;
  border-radius: var(--radius);
  appearance: none;
}
.find input::-webkit-search-cancel-button { display: none; }
.find input::placeholder { color: var(--muted); }
.find input:focus { border-color: var(--brand-deep); background: var(--paper); }

.find__clear {
  position: absolute;
  right: 0.35rem;
  font: inherit;
  font-size: var(--step--1);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0.4em 0.6em;
  cursor: pointer;
}
.find__clear:hover { color: var(--brand-strong); }

/* At narrow widths the wordmark and search stop competing: search gets its own row. */
@media (max-width: 42rem) {
  .masthead__inner { flex-wrap: wrap; gap: 0.75rem; }
  .find { flex-basis: 100%; max-width: none; margin-left: 0; }
}

/* ------------------------------------------------------------------ spine */

.spine {
  max-width: 1600px;
  margin: clamp(1.5rem, 3vw, 3rem) auto 0;
  padding-inline: var(--pad);
}

.spine__h {
  margin: 0 0 0.9rem;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.spine__rows { display: flex; flex-direction: column; }

.year {
  display: grid;
  grid-template-columns: 3.2rem 1fr 2.6rem;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  margin-inline: -0.5rem;
  background: none;
  border: 0;
  border-top: 1px solid var(--rule);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.year:last-child { border-bottom: 1px solid var(--rule); }

.year__label { font-variant-numeric: tabular-nums; font-weight: 600; }

.year__bar { display: flex; height: 0.55rem; gap: 2px; }

/* Solid = video, hatched = audio only. The shape of the archive over time. */
.year__seg--video { background: var(--brand); }
.year__seg--audio {
  background: repeating-linear-gradient(
    -45deg,
    var(--hatch) 0 2px,
    transparent 2px 4px
  );
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hatch) 55%, transparent);
}

.year__n {
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
}

/* Legend for the spine's solid/hatched segments. */
.spine__key {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0.9rem 0 0;
  font-size: var(--step--1);
  color: var(--muted);
}

.key { display: inline-flex; align-items: center; gap: 0.5rem; }

.key__swatch {
  display: inline-block;
  width: 1.6rem;
  height: 0.55rem;
  flex: 0 0 auto;
}
.key__swatch--video { background: var(--brand); }
.key__swatch--audio {
  background: repeating-linear-gradient(-45deg, var(--hatch) 0 2px, transparent 2px 4px);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hatch) 55%, transparent);
}

.year:hover .year__label { color: var(--brand-deep); }

/* The selected year is marked on the row itself. The bars keep their
   video/audio encoding so they never stop matching the legend. */
.year[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.year[aria-pressed="true"] .year__label {
  color: var(--brand-strong);
  font-weight: 800;
}
.year[aria-pressed="true"] .year__n { color: var(--brand-strong); }

/* ----------------------------------------------------------------- status */

.status {
  max-width: 1600px;
  margin: clamp(1.75rem, 4vw, 3rem) auto 1rem;
  padding-inline: var(--pad);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: var(--gap);
  max-width: 1600px;
  margin-inline: auto;
  padding: 0 var(--pad);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.card__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--shade);
  border-radius: var(--radius);
  overflow: hidden;
}

.card__img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.card__img[data-loaded] { opacity: 1; }

/* Audio-only sermons have no frame to show, so they get the mark instead. */
.card__stand-in {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--brand) 35%, transparent);
}
.card__stand-in svg { width: 40%; height: 40%; }

.card__badge {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.2em 0.5em;
  border-radius: 2px;
  /* Ink on brand cyan is 6.23:1. The one place the fill carries text.
     The hairline edge keeps it legible over arbitrary artwork - some series
     images are themselves blue, and the badge must not melt into them. */
  background: var(--brand);
  color: var(--ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 30%, transparent);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card__dur {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0.2em 0.45em;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  color: var(--paper);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.card__series {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.card__title {
  margin: 0;
  font-family: var(--title);
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.card__meta {
  margin: 0;
  font-size: var(--step--1);
  color: var(--muted);
}

.card:hover .card__title { color: var(--brand-deep); }
.card:hover .card__frame { box-shadow: 0 0 0 2px var(--brand); }

/* ------------------------------------------------------------------ empty */

.empty {
  max-width: 44rem;
  margin: clamp(3rem, 8vw, 6rem) auto;
  padding-inline: var(--pad);
  font-family: var(--title);
  font-size: var(--step-2);
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.sentinel { height: 1px; }

/* ----------------------------------------------------------------- viewer */

.viewer { position: fixed; inset: 0; z-index: 50; }

.viewer__scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  animation: fade 0.2s ease;
}

.viewer__panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (min-width: 60rem) {
  .viewer__panel {
    inset: 3vh 50% auto auto;
    transform: translateX(50%);
    width: min(64rem, 94vw);
    max-height: 94vh;
    border-radius: var(--radius);
    box-shadow: 0 2rem 5rem color-mix(in srgb, var(--ink) 40%, transparent);
  }
}

.viewer__close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.4rem; height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: #fff;
  cursor: pointer;
}
.viewer__close svg { width: 1.1rem; height: 1.1rem; }
.viewer__close:hover { background: var(--brand-strong); }

.stage {
  aspect-ratio: 16 / 9;
  background: #000;
}
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }

.viewer__body { padding: clamp(1.2rem, 3vw, 2.4rem); }

.viewer__series {
  margin: 0 0 0.5rem;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.viewer__series button {
  font: inherit;
  color: var(--brand-deep);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-underline-offset: 3px;
}
.viewer__series button:hover { text-decoration: underline; color: var(--brand-strong); }

.viewer__title {
  margin: 0 0 0.5rem;
  font-family: var(--title);
  font-size: var(--step-3);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.viewer__meta { margin: 0; color: var(--muted); }

.getit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: clamp(1.2rem, 3vw, 2rem);
  padding-top: clamp(1.2rem, 3vw, 2rem);
  border-top: 1px solid var(--rule);
}

.getit a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
}
.getit a:hover { border-color: var(--brand-deep); color: var(--brand-deep); }
.getit svg { width: 0.95rem; height: 0.95rem; }

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

.footer {
  max-width: 1600px;
  margin: clamp(4rem, 10vw, 8rem) auto 0;
  padding: clamp(1.5rem, 4vw, 3rem) var(--pad) clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--muted);
}
.footer p { margin: 0 0 0.4rem; max-width: 42rem; }
.footer__meta { font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- motion */

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(1.5rem); } }

@media (min-width: 60rem) {
  @keyframes rise {
    from { opacity: 0; transform: translateX(50%) translateY(1.5rem); }
    to   { opacity: 1; transform: translateX(50%); }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card__img { opacity: 1; }
}
