/* =============================================
   MEDIA PAGE (media.php)
   Loaded only on that template, after style.css, so it reuses the
   :root tokens, .page-hero, .btn and .cta-banner. Everything new sits
   under md-* classes.

   The hero leads with one client video (muted loop, tap for sound).
   Client stories are a copy column beside three 9:16 videos. Bill's
   guides are one filterable row of 3:4 covers that open a player
   dialog; below 900px they become cover-and-text rows. On phones story
   videos stack one per row, never a swipe row.
   ============================================= */

/* ---- Hero: light like the other pages, one client video leads.
   Position and title style come from the PAGE HEADERS block in style.css. ---- */
.md-hero {
  padding: var(--ph-top) 0 96px;
  background: linear-gradient(180deg, var(--color-white) 0%, var(--color-bg-light) 100%);
}
.md-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}
.md-hero__title span { display: block; color: var(--color-cta); }
.md-hero__lede {
  max-width: 500px;
  margin: 0 0 34px;
  font-family: var(--font-accent);
  font-size: 17px;
  font-weight: var(--fw-regular);
  line-height: 1.75;
  color: #444;
}
.md-hero__btns { display: flex; flex-wrap: wrap; gap: 14px; }

/* The three client stories, as faces that link down to them */
.md-hero__people {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 500px;
  margin-top: 52px;
  padding-top: 28px;
  border-top: 1px solid rgba(0,0,0,0.1);
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.45;
}
.md-hero__faces { display: flex; flex: 0 0 auto; }
.md-hero__faces img {
  width: 52px;
  height: 52px;
  border: 3px solid var(--color-white);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.md-hero__faces img + img { margin-left: -14px; }
.md-hero__people-text strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 16px;
  color: var(--color-dark);
}
.md-hero__people-arrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--color-dark);
  transition: transform 0.2s ease;
}
.md-hero__people:hover .md-hero__people-arrow { transform: translateY(3px); }
.md-hero__people:hover .md-hero__people-text strong { color: var(--color-cta); }

/* Featured video: centred in its column, sized to sit above the fold */
.md-hero__watch { display: flex; justify-content: center; }
.md-feature {
  width: min(360px, (100vh - var(--ph-top) - 48px) * 9 / 16);
  min-width: 280px;
  margin: 0;
}
.md-feature__media {
  position: relative;
  cursor: pointer;   /* tap anywhere: sound first, then play/pause (main.js) */
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: var(--r-card);
  background: #11151a;
  box-shadow: 0 30px 60px -24px rgba(0,0,0,0.4);
}
.md-feature__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Stories ---- */
.md-story {
  padding: var(--sp-sec) 0;
  background: var(--color-white);
}
.md-story--flip { background: var(--color-bg-light); }

.md-story__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 700px);
  gap: 64px;
  align-items: start;
}
.md-story--flip .md-story__inner { grid-template-columns: minmax(0, 700px) minmax(0, 1fr); }
.md-story--flip .md-story__copy { order: 2; }

/* Three videos: a narrower copy column so the videos keep the same container edges */
.md-story--wide .md-story__inner { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 56px; }
.md-story--wide .md-reels { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Copy rides alongside the tall videos instead of floating mid-height. */
.md-story__copy {
  position: sticky;
  top: 120px;
  padding-top: 24px;
}

.md-story__title {
  font-size: clamp(30px, 3.2vw, 44px);
  line-height: 1.1;
  margin-bottom: 18px;
  text-wrap: balance;
}

.md-story__copy p {
  max-width: 44ch;
  font-size: 17px;
  font-weight: var(--fw-regular);
  line-height: 1.7;
  color: #333;
}

/* ---- Video cards ---- */
.md-reels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.md-reel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--color-white);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.md-story--flip .md-reel { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06); }

.md-reel__media {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #11151a;
}

.md-reel__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* With JS the whole frame is one play/pause button. */
.md-reel__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.md-reel__play[hidden] { display: none; }
.md-reel__play:focus-visible { outline: 3px solid var(--color-cta); outline-offset: -3px; }

.md-reel__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--color-heading);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.md-reel__icon svg { width: 26px; height: 26px; margin-left: 3px; }
.md-reel__play:hover .md-reel__icon { transform: scale(1.08); }

/* While playing, the frame stays a tap target but the icon gets out of the way. */
.is-playing .md-reel__icon { opacity: 0; }

.md-reel__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  pointer-events: none;
}
.md-reel__bar {
  display: block;
  width: 0;
  height: 100%;
  background: var(--color-white);
}

.md-reel__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px 20px;
}

.md-reel__title {
  font-size: 18px;
  line-height: 1.3;
}

.md-reel__quote { font-style: italic; }
.md-reel__note {
  font-size: 15px;
  font-weight: var(--fw-regular);
  line-height: 1.6;
  color: #333;
}

.md-reel__handle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: auto;
  padding-top: 6px;
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--color-accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.md-reel__handle:hover,
.md-reel__handle:focus-visible { border-bottom-color: currentColor; }

.md-reel .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Loading spinner (media.js trackLoading) ---- */
.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: var(--color-white);
  border-radius: 50%;
  background: rgba(20, 28, 38, 0.55);
  box-shadow: 0 0 0 8px rgba(20, 28, 38, 0.55);
  animation: md-spin 0.8s linear infinite;
  pointer-events: none;
}
.is-loading .md-reel__icon,
.is-loading .md-player__icon,
.is-loading .tap-video__icon { opacity: 0 !important; }
@keyframes md-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .is-loading::after { animation-duration: 2.4s; }
}

/* ---- Ask Bill: filterable guide cards ---- */
.md-guides {
  padding: var(--sp-sec) 0;
  background: var(--color-bg-light);
}
.md-guides__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  margin-bottom: 44px;
}
.md-guides__intro p {
  max-width: 52ch;
  font-size: 17px;
  font-weight: var(--fw-regular);
  line-height: 1.7;
  color: #333;
}
.md-guides__intro .md-story__title { margin-bottom: 14px; }

.md-guides__filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.md-guides__filters button {
  padding: 10px 18px;
  border: 1.5px solid rgba(0,0,0,0.14);
  border-radius: var(--r-pill);
  background: var(--color-white);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--color-dark);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.md-guides__filters button:hover { border-color: var(--color-dark); }
.md-guides__filters button.is-active {
  background: var(--color-dark);
  border-color: var(--color-dark);
  color: var(--color-white);
}

.md-guides__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 28px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.md-guide { display: flex; flex-direction: column; }
.md-guide__body { display: flex; flex-direction: column; }
.md-guide[hidden] { display: none; }

.md-guide__thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  margin-bottom: 16px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #11151a;
  cursor: pointer;
}
.md-guide__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.md-guide__thumb:hover img { transform: scale(1.04); }
.md-guide__thumb:focus-visible { outline: 3px solid var(--color-cta); outline-offset: 3px; }

.md-guide__play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.94);
  color: var(--color-heading);
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
  transition: transform 0.2s ease;
}
.md-guide__play svg { width: 20px; height: 20px; margin-left: 2px; }
.md-guide__thumb:hover .md-guide__play { transform: scale(1.08); }

.md-guide__length {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(20, 28, 38, 0.72);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-white);
}

.md-guide__cat {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.md-guide__title {
  margin-bottom: 6px;
  font-size: 17px;
  line-height: 1.3;
}
.md-guide__note {
  font-size: 15px;
  font-weight: var(--fw-regular);
  line-height: 1.55;
  color: #444;
}

.md-guides__more {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 15px;
  color: #444;
}
.md-guides__more a {
  font-weight: var(--fw-semibold);
  color: var(--color-dark);
  border-bottom: 1px solid currentColor;
}
.md-guides__more a:hover { color: var(--color-cta); }
.md-guides__more span { margin-left: 6px; color: var(--color-muted); }

/* ---- Player dialog ---- */
html.md-lock { overflow: hidden; }
.md-player {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.md-player::backdrop { background: rgba(10, 13, 17, 0.86); }
.md-player[open] { display: grid; place-items: center; }
.md-player__box {
  display: grid;
  grid-template-columns: 56px auto 56px;
  grid-template-areas: "prev frame next" ". cap .";
  gap: 16px 20px;
  align-items: center;
}
.md-player__frame {
  grid-area: frame;
  position: relative;
  height: min(78vh, 760px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 16px;
  background: #000;
  cursor: pointer;
}
.md-player__video { display: block; width: 100%; height: 100%; object-fit: cover; }
.md-player__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  background: rgba(255,255,255,0.94);
  color: var(--color-heading);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.md-player__icon svg { width: 26px; height: 26px; margin-left: 3px; }
.md-player__frame.is-paused .md-player__icon { opacity: 1; }

.md-player__step,
.md-player__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: var(--color-white);
  cursor: pointer;
  transition: background 0.2s ease;
}
.md-player__step:hover,
.md-player__close:hover { background: rgba(255,255,255,0.24); }
.md-player__step:disabled { visibility: hidden; }
.md-player__step--prev { grid-area: prev; }
.md-player__step--next { grid-area: next; }
.md-player__close { position: fixed; top: 20px; right: 20px; z-index: 2; }

.md-player__cap {
  grid-area: cap;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  color: var(--color-white);
}
.md-player__cat {
  width: 100%;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #aabbc5;
}
.md-player__title { font-family: var(--font-heading); font-size: 18px; }
.md-player__ig {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--color-white);
}
.md-player__ig:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 1180px) {
  .md-guides__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 24px; }
  .md-guides__head { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 24px; }
  .md-guides__filters { justify-content: flex-start; }
}

@media (max-width: 1080px) {
  .md-hero__inner { grid-template-columns: minmax(0, 1fr) auto; gap: 48px; }
  .md-feature { width: 300px; min-width: 0; }
  .md-story__inner { grid-template-columns: minmax(0, 1fr) minmax(0, 540px); gap: 40px; }
  .md-story--flip .md-story__inner { grid-template-columns: minmax(0, 540px) minmax(0, 1fr); }
  .md-story--wide .md-story__inner { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .md-story--wide .md-story__copy { position: static; padding-top: 0; }
  .md-reels { gap: 20px; }
}

@media (max-width: 900px) {
  /* Stacked: copy on top, videos keep the container edges */
  .md-story__inner,
  .md-story--flip .md-story__inner { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .md-story--flip .md-story__copy { order: 0; }
  .md-story__copy { position: static; padding-top: 0; }
  .md-hero { padding-bottom: 64px; }
  .md-hero__inner { grid-template-columns: minmax(0, 1fr); gap: 44px; }
  .md-feature { width: 100%; max-width: 360px; }

  /* Guides become rows: cover on the left, words on the right */
  .md-guides__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .md-guide {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 10px;
    border-radius: 16px;
    background: var(--color-white);
    box-shadow: 0 6px 18px rgba(0,0,0,0.05);
  }
  .md-guide[hidden] { display: none; }
  .md-guide__thumb { margin-bottom: 0; border-radius: 10px; }
  .md-guide__play { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
  .md-guide__play svg { width: 16px; height: 16px; }
  .md-guide__length { right: 6px; bottom: 6px; padding: 3px 6px; font-size: 11px; }
  .md-guide__body { padding-right: 6px; }
  .md-guide__cat { margin-bottom: 4px; font-size: 10.5px; }
  .md-guide__title { margin-bottom: 4px; font-size: 16px; }
  .md-guide__note { font-size: 14px; line-height: 1.5; }

  /* Player: video fills the screen width, arrows sit under it */
  .md-player__box {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "frame frame" "cap cap" "prev next";
    gap: 14px;
    width: min(100vw - 32px, 440px);
  }
  .md-player__frame { justify-self: center; height: min(70vh, (100vw - 32px) * 16 / 9); }
  .md-player__step--next { justify-self: end; }
  .md-player__close { top: 12px; right: 12px; }
}

@media (max-width: 600px) {
  .md-story__copy p,
  .md-guides__intro p { font-size: 16px; }

  .md-hero { padding-bottom: 52px; }
  .md-hero__lede { font-size: 15.5px; }
  .md-hero__btns .btn { width: 100%; }
  .md-hero__people { gap: 14px; margin-top: 36px; }
  .md-hero__faces img { width: 44px; height: 44px; border-width: 2px; }
  .md-hero__faces img + img { margin-left: -12px; }
  .md-hero__people-text strong { font-size: 15px; }
  .md-hero__people-arrow { display: none; }

  /* One video per row, full width: side by side at ~170px they were too small to watch. */
  .md-reels,
  .md-story--wide .md-reels {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .md-guides__head { margin-bottom: 28px; }
  .md-guides__filters button { padding: 9px 15px; font-size: 13.5px; }
  .md-guides__grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .md-guide { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
  .md-guides__more { margin-top: 36px; }
  .md-guides__more span { display: block; margin: 4px 0 0; }
}
