/* ============================================================================
   Chassidish Choir — pages.css
   Everything the inner pages need that base.css does not already give:
     · media bar + section filter chips        (videos.html)
     · mixed-orientation grid + masonry wall   (videos.html / gallery.html)
     · the booking CTA band                    (videos.html / gallery.html)
     · contact layout, details rail, form      (contact.html)
     · the 404 panel                           (404.html)

   Rules followed here:
     - No new colors. Every value below resolves to a token in tokens.css.
     - Nothing that base.css already defines is redeclared. Where a base.css
       rule is deliberately overridden, the reason is in a comment right above
       the override — see .gallery-masonry (display) and .grid-videos
       (.card--portrait's frame ratio).
     - .loadmore and .card__frame--noimg are media.js class names that home.css
       also styles; home.css is not loaded on these pages, so they are repeated
       here on purpose and kept identical.
   ========================================================================== */

/* ============================================================================
   1. MEDIA BAR — the row above a grid: filter chips on the left, count right
   ========================================================================== */

.media-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--rule-soft);
}

/* Before media.js runs, the chips are empty and the count is blank — an empty
   bar is just a stray hairline, so it stays out of the way until it has
   something to say. (Browsers without :has simply show the empty bar.) */
.media-bar:not(:has(.filters > *)):has([data-media-count]:empty) { display: none; }

.media-count {
  margin: 0;
  max-width: none;
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--fg-faint);
}
.media-count [data-media-count] { color: var(--gold-300); }

/* ---- Section filter chips -------------------------------------------------
   media.js owns the markup inside [data-media-filters]; we do not know whether
   it emits <button> or <a>, so every plausible child is styled the same and the
   active state is matched on all three conventions it might use. */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  min-width: 0;
}
.filters:empty { display: none; }

.filters > button,
.filters > a,
.filters .chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.35em 1.15em;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-ui);
  font-size: var(--t-small);
  font-weight: 400;
  letter-spacing: var(--track-nav);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out);
}

.filters > button:hover,
.filters > a:hover,
.filters .chip:hover {
  color: var(--gold-100);
  border-color: var(--rule);
}

.filters > button[aria-pressed="true"],
.filters > a[aria-current],
.filters .chip.is-active,
.filters .is-active,
.filters [data-active] {
  color: var(--plum-950);
  background: var(--gold-300);
  border-color: var(--gold-300);
  font-weight: 500;
}

/* ============================================================================
   2. GRID PLUMBING shared by both media pages
   ========================================================================== */

/* The <button> UA reset that used to live here (padding / text-align / font) has
   moved onto `.card` itself in base.css. Scoping it to these two grids is what
   left every card on the HOME page with Chrome's 1px 6px button padding showing
   as a band between the border and the picture. Don't re-scope it. */

/* media.js sets .is-empty and drops a single .state box in. In a multi-column
   layout that box would sit in column one; flatten the container while empty. */
.grid-videos.is-empty,
.gallery-masonry.is-empty { display: block; }

/* .loadmore and .card__frame--noimg are media.js's own class names. home.css
   already styles them for index.html, but home.css is not loaded here — these
   are the same rules so the two pages match. */
.loadmore { margin: var(--sp-6) auto 0; display: flex; }

.card__frame--noimg {
  background:
    radial-gradient(circle at 50% 45%, rgba(184, 137, 47, 0.22), transparent 62%),
    var(--plum-800);
}
.card__frame--noimg::after {
  content: "";
  position: absolute;
  inset: 22%;
  background: url("../img/seal.webp") center / contain no-repeat;
  opacity: 0.28;
  filter: grayscale(1) brightness(1.5);
}

/* ============================================================================
   3. VIDEOS GRID — mixed orientation without a hole in the row
   ========================================================================== */

/* The vertical clip is real — one of the six is 1080x1920 — and a 9/16 card
   dropped into a row of 16/9 cards leaves a crater under its neighbours.
   Fix without reordering anything (the client's rule is newest-first, so a
   masonry column flow that reads top-to-bottom is not available here):

     · the portrait card spans TWO grid rows, so it is genuinely tall;
     · every card is a flex column whose frame grows to fill its row, so the
       row always closes flush instead of leaving a hole;
     · grid-auto-flow: dense backfills the cell the tall card would strand.

   The 9/16 frame from base.css is dropped for a fill-the-span frame; the
   lightbox still opens the clip at its true ratio. */
.grid-videos {
  grid-auto-flow: dense;
  align-items: stretch;
}

.grid-videos > .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.grid-videos > .card .card__frame { flex: 1 1 auto; }

.grid-videos > .card--portrait {
  grid-row: span 2;
}
/* 3/4 is the FLOOR, not the shape: flex-grow above lets the frame fill the two
   rows it spans. Without a floor the card collapses to just its caption bar the
   moment the grid drops to one column and no sibling is left to size the rows. */
.grid-videos > .card--portrait .card__frame {
  aspect-ratio: 3 / 4;
  min-height: 0;
}
/* One column: there is nothing to span, and spanning is what collapsed it. */
@media (max-width: 700px) {
  .grid-videos > .card--portrait { grid-row: auto; }
}

/* Videos are 16/9 or vertical in practice (PLAN §7); a "square" clip is treated
   as landscape so it does not set an odd height for its whole row. */
.grid-videos > .card--square .card__frame { aspect-ratio: 16 / 9; }

/* ============================================================================
   4. GALLERY — a masonry wall, not the dead-black grid
   ========================================================================== */

.gallery-masonry {
  /* OVERRIDE of base.css .grid-media { display: grid }.
     A photo set of mixed orientation in an equal-row grid is exactly the
     uneven dead-space look on yedidimchoir.com (reference/yed-2.png). CSS
     columns let every photo keep its own height and close the gaps. Aspect
     ratios stay declared below so nothing shifts while images load. */
  --gal-gap: clamp(1rem, 1.6vw, 1.75rem);
  display: block;
  /* Explicit counts rather than a column-width, so the phone gets 2-up instead
     of one full-width photo per screen and a 5,000px scroll. */
  columns: 2;
  column-gap: var(--gal-gap);
}
/* Capped at 3. Four columns balance badly — break-inside:avoid leaves the last
   column ending several hundred px short — and 3 keeps the faces big enough to
   be worth looking at, which is the whole point of the wall. */
@media (min-width: 620px) { .gallery-masonry { columns: 3; } }

.gallery-masonry > * {
  break-inside: avoid;
  margin-bottom: var(--gal-gap);
}

.gallery-masonry .card { width: 100%; }

/* Three declared shapes so the wall staggers on purpose instead of by accident,
   and so a portrait photo is a portrait photo. */
.gallery-masonry .card__frame { aspect-ratio: 3 / 2; }
.gallery-masonry .card--portrait .card__frame { aspect-ratio: 3 / 4; }
.gallery-masonry .card--square .card__frame { aspect-ratio: 1 / 1; }

/* If a batch happens to be all-landscape, this keeps the column tops from
   lining up into a grid again. */
.gallery-masonry .card:nth-child(4n + 1):not(.card--portrait):not(.card--square) .card__frame {
  aspect-ratio: 5 / 4;
}

/* No caption bar on the wall. media.js takes a photo's title from its filename,
   and the client's photos are camera dumps — LASH0851, DSC00602, YST_4471. A
   row of serial numbers under the pictures is the watermark problem all over
   again. The card keeps its aria-label, and the lightbox still names the file. */
.gallery-masonry .card__meta { display: none; }

/* Anything media.js drops in that is NOT a card — empty state, an error note, a
   stray button — spans the full wall instead of hiding in column one.
   (:not(.card) matters: the cards themselves are <button> elements.) */
.gallery-masonry > .state,
.gallery-masonry > p,
.gallery-masonry > button:not(.card) { column-span: all; }
.gallery-masonry > button:not(.card) { display: block; margin-inline: auto; }

/* ============================================================================
   5. BOOKING CTA BAND — slim, closes Videos and Gallery
   ========================================================================== */

.cta-band {
  position: relative;
  padding-block: clamp(2.75rem, 2rem + 3.4vw, 5rem);
  background: var(--plum-900);
  border-top: 1px solid var(--rule);
  overflow: hidden;
}
.cta-band::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -70%;
  width: min(880px, 130vw);
  aspect-ratio: 1;
  translate: -50% 0;
  background: radial-gradient(circle, rgba(184, 137, 47, 0.14), transparent 62%);
  pointer-events: none;
}

.cta-band__inner {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5) var(--sp-7);
}
.cta-band__copy { min-width: 0; }
.cta-band__copy .label { margin-bottom: var(--sp-3); }
.cta-band__copy .lead { margin-top: var(--sp-3); }
.cta-band .btn { flex: 0 0 auto; }

@media (max-width: 640px) {
  .cta-band__inner { flex-direction: column; align-items: flex-start; }
  .cta-band .btn { width: 100%; }
}

/* ============================================================================
   6. CONTACT — two columns: the form, and the details rail
   ========================================================================== */

.contact__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(2.25rem, 4vw, 4.5rem);
  align-items: start;
}
@media (max-width: 940px) {
  .contact__grid { grid-template-columns: minmax(0, 1fr); }
}

.contact__h { margin-bottom: var(--sp-4); }
.contact__intro { color: var(--fg-dim); }

/* ---- Details rail --------------------------------------------------------- */

.contact__rail {
  position: relative;
  padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--plum-900);
  overflow: hidden;
}
.rail__seal {
  position: absolute;
  right: -20%;
  top: -14%;
  width: min(260px, 60%);
  opacity: 0.06;
  filter: grayscale(1) brightness(1.6);
  pointer-events: none;
}
.contact__rail > *:not(.rail__seal) { position: relative; z-index: var(--z-content); }

.rail__list {
  list-style: none;
  margin: var(--sp-6) 0 0;
  padding: 0;
  display: grid;
  gap: var(--sp-5);
}
.rail__item {
  display: grid;
  gap: var(--sp-2);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--rule-soft);
}
.rail__item:last-child { padding-bottom: 0; border-bottom: 0; }

.rail__k {
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--gold-400);
}
.rail__v {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.1rem + 0.85vw, 1.9rem);
  line-height: 1.15;
  color: var(--cream);
  overflow-wrap: anywhere;
}
a.rail__v { transition: color var(--dur) var(--ease-out); }
a.rail__v:hover { color: var(--gold-200); }

/* Deliberately does NOT look like a real value — nothing here is invented. */
.rail__v.is-pending {
  justify-self: start;
  padding: 0.35em 1em;
  border: 1px dashed var(--rule);
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: var(--t-small);
  font-weight: 400;
  letter-spacing: var(--track-nav);
  color: var(--fg-faint);
}

.rail__rule { margin-top: var(--sp-6); }
.rail__note {
  margin-top: var(--sp-5);
  font-size: var(--t-small);
  color: var(--fg-dim);
}

/* ============================================================================
   7. FORM CONTROLS on the dark plum surface
   ========================================================================== */

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-6);
}
@media (max-width: 560px) {
  .form { grid-template-columns: minmax(0, 1fr); }
}

.field { display: grid; gap: var(--sp-2); min-width: 0; }
.field--full { grid-column: 1 / -1; }

.field > label {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--gold-300);
}
.req { color: var(--blush-400); }

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px; /* thumb target */
  padding: 0.7rem 1rem;
  font-family: var(--font-ui);
  font-size: 1rem; /* 16px — anything smaller makes iOS zoom on focus */
  font-weight: 300;
  line-height: 1.5;
  color: var(--cream);
  background: var(--plum-800);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--fg-faint); }

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--rule); }

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--plum-700);
  border-color: var(--gold-500);
  outline: none; /* replaced by the ring below, which is more visible on plum */
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--gold-300);
  outline-offset: 2px;
}

.field textarea {
  min-height: 148px;
  line-height: 1.6;
  resize: vertical;
}

.field [aria-invalid="true"] { border-color: var(--blush-500); }

/* ---- Select: the OS arrow is replaced with our own ------------------------ */

.select-wrap { position: relative; display: block; }
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.9rem;
  cursor: pointer;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 1.15rem;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--gold-300);
  border-bottom: 1.5px solid var(--gold-300);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
/* The dropdown list itself is OS-drawn; this is as far as it can be pushed. */
.select-wrap select option {
  background: var(--plum-900);
  color: var(--cream);
}

/* ---- Date: the native picker glyph is black-on-plum by default ------------ */

.field input[type="date"] { cursor: text; }
.field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.68);
  cursor: pointer;
}
.field input[type="date"]::-webkit-calendar-picker-indicator:hover { filter: invert(1) opacity(1); }

/* ---- Honeypot -------------------------------------------------------------
   Off-screen, NOT display:none — bots skip hidden-by-display fields. Paired
   with tabindex="-1" in the markup so it is unreachable by keyboard. */
.hp {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- Errors, actions, status --------------------------------------------- */

.field__err {
  margin: 0;
  max-width: none;
  font-size: var(--t-small);
  line-height: 1.4;
  color: var(--blush-400);
}
.field__err[hidden] { display: none; }

.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4) var(--sp-5);
  margin-top: var(--sp-2);
}
.form__note {
  margin: 0;
  max-width: 34ch;
  font-size: var(--t-small);
  color: var(--fg-faint);
}
.form__actions .btn[disabled] { opacity: 0.6; cursor: progress; }

.form__status {
  grid-column: 1 / -1;
  margin: 0;
  max-width: none;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule-soft);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--plum-800);
  font-size: var(--t-small);
  line-height: 1.55;
}
.form__status:empty { display: none; }
.form__status.is-ok { border-color: var(--gold-500); color: var(--gold-100); }
.form__status.is-err { border-color: var(--blush-500); color: var(--blush-200); }

/* Turnstile renders nothing until a site key is pasted in — no empty gap. */
.cf-turnstile:empty { display: none; }

/* ============================================================================
   8. 404
   ========================================================================== */

.page-404 {
  position: relative;
  min-height: 76vh;
  display: grid;
  place-items: center;
  padding-block: calc(var(--header-h) + var(--sp-8)) var(--sp-9);
  overflow: hidden;
}
.page-404::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(820px, 130vw);
  aspect-ratio: 1;
  translate: -50% -50%;
  background: radial-gradient(circle, rgba(184, 137, 47, 0.15), transparent 62%);
  pointer-events: none;
}
.page-404__inner { position: relative; z-index: var(--z-content); }
.page-404__seal {
  width: clamp(88px, 12vw, 138px);
  margin: 0 auto var(--sp-6);
  border-radius: 50%;
}
.page-404__lead { margin-top: var(--sp-4); }
.page-404__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-4);
  margin-top: var(--sp-7);
}
@media (max-width: 420px) {
  .page-404__actions .btn { width: 100%; }
}
