/* Brand Identity & Color Adjustments */
:root {
  --brand-red: #ed2024;
  --brand-red-muted: rgba(237, 32, 36, 0.1);
  --primary: light-dark(#3f3f46, #fafafa); /* Subtler primary than pure black in light mode */
  color-scheme: light dark;
}
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html,
body {
  overflow-x: clip;
}
html[data-theme="light"] body { background: #fff; color: #18181b; }
html[data-theme="dark"] body { background: #09090b; color: #fafafa; }

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.theme-toggle svg { flex: 0 0 auto; }
html[data-theme="light"] .theme-toggle .icon-dark { display: none; }
html[data-theme="dark"] .theme-toggle .icon-light { display: none; }
html[data-theme="system"] .theme-toggle .icon-light { transform: translateX(3px); }
html[data-theme="system"] .theme-toggle .icon-dark {
  transform: translateX(-3px);
  opacity: .65;
}

[data-tooltip]::after {
  background: light-dark(#18181b, #f4f4f5);
  border: 1px solid light-dark(#27272a, #e4e4e7);
  box-shadow: 0 8px 24px light-dark(rgba(0, 0, 0, .16), rgba(0, 0, 0, .45));
  color: light-dark(#fff, #18181b);
}
[data-tooltip]::before {
  border-top-color: light-dark(#18181b, #f4f4f5);
}

/* HTMX page transitions */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
#main-content { animation: fadeIn 250ms ease-out; }
.htmx-swapping > #main-content, #main-content.htmx-swapping { opacity: 0; transition: opacity 150ms ease-in; }

/* HTMX indicator pattern */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; align-items: center; }

/* Thumbnail base — keeps a stable 16:9 box */
img[data-thumb] {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: transparent;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Card components: uniform height, contained zoom, and clean flex layouts */
article.video-card,
article.short-card { 
  padding: 0; 
  overflow: visible; 
  transition: border-color 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

article.video-card:hover,
article.short-card:hover {
  border-color: var(--brand-red);
}

article.video-card:hover img[data-thumb],
article.short-card:hover img[data-thumb] {
  transform: scale(1.04);
}

article.video-card > .card-link,
article.short-card > .card-link {
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
}

article.video-card .img-wrapper,
article.short-card .img-wrapper {
  overflow: hidden;
  position: relative;
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
}

article.video-card .img-wrapper {
  aspect-ratio: 16/9;
}

article.short-card .img-wrapper {
  aspect-ratio: 9/16;
}

article.video-card a img {
  border-radius: 0;
}

article.video-card header {
  padding: var(--space-4) var(--space-4) 0; 
  flex-grow: 1;
}

article.video-card header > h3 {
  font-size: var(--text-6); 
  margin: 0; 
  line-height: 1.4; 
  font-weight: var(--font-semibold);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

article.video-card footer,
article.short-card footer {
  margin: 0; 
  color: var(--muted-foreground); 
  font-size: var(--text-7); 
}

article.video-card footer {
  padding: var(--space-2) var(--space-4) var(--space-4); 
}

/* Hero card: bigger title, more cinematic */
article.video-hero header > h2 {
  font-size: var(--text-3); 
  margin: 0; 
  line-height: 1.2; 
  padding: var(--space-4) var(--space-4) 0; 
  font-weight: var(--font-bold);
}

.thumb-date-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 7px;
  background: rgba(0, 0, 0, .72);
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: var(--font-medium, 500);
  line-height: 1.35;
  pointer-events: none;
}

/* Site logo in the topnav */
.site-logo { 
  display: inline-flex; 
  align-items: center; 
  gap: .75rem; 
  font-weight: var(--font-bold); 
  text-decoration: none; 
  color: inherit; 
  transition: opacity 0.2s ease;
}
.site-logo:hover { color: inherit; opacity: .8; }

nav[data-topnav] { 
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
}

nav[data-topnav] > .site-logo { grid-column: 1; }
nav[data-topnav] > .nav-center { grid-column: 2; justify-self: center; width: 100%; max-width: 600px; }
nav[data-topnav] > .nav-right { grid-column: 3; display: flex; align-items: center; gap: var(--space-4); }

nav[data-topnav] a { font-weight: var(--font-medium); }

/* Responsive Nav */
@media (max-width: 768px) {
  nav[data-topnav] {
    grid-template-columns: 1fr auto;
    row-gap: var(--space-2);
  }
  nav[data-topnav] > .nav-center {
    grid-column: 1 / span 2;
    grid-row: 2;
    order: 3;
    max-width: none;
  }
  nav[data-topnav] > .nav-right {
    grid-column: 2;
    grid-row: 1;
    font-size: var(--text-7);
    gap: var(--space-2);
  }
}

/* Breadcrumb */
nav.breadcrumb ol { list-style: none; padding: 0; margin: 0 0 var(--space-6); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-7); color: var(--muted-foreground); }
nav.breadcrumb a { color: inherit; transition: color 0.2s ease; }
nav.breadcrumb a:hover { color: var(--foreground); }
nav.breadcrumb svg { display: inline-block; vertical-align: middle; opacity: 0.5; }

/* Prev/next nav under video detail */
nav.prevnext { display: flex; gap: var(--space-4); justify-content: space-between; margin-top: var(--space-8); padding: var(--space-6) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
nav.prevnext a { display: block; color: inherit; text-decoration: none; max-width: 48%; }
nav.prevnext a:hover { color: var(--brand-red); }
nav.prevnext a:last-child { text-align: end; margin-inline-start: auto; }
nav.prevnext small { color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em; font-weight: var(--font-bold); }
nav.prevnext strong { display: block; margin-top: var(--space-1); line-height: 1.3; }

/* Video detail: play overlay (dark translucent YouTube style) */
.video-detail-ambient {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  margin-top: calc(var(--space-4) * -1);
  padding: var(--space-4) max(var(--space-4), calc((100vw - 1180px) / 2)) var(--space-6);
  overflow: hidden;
  background-color: light-dark(#f5f5f7, #09090b);
  color: light-dark(#18181b, #fff);
}

.video-detail-ambient::before {
  content: "";
  position: absolute;
  inset: -18%;
  z-index: -2;
  opacity: .82;
  filter: blur(44px) saturate(1.35);
  background-image:
    radial-gradient(45% 55% at 16% 20%, var(--_c0-clr, rgba(237, 32, 36, .55)), transparent 72%),
    radial-gradient(48% 60% at 58% 12%, var(--_c1-clr, rgba(31, 111, 235, .55)), transparent 76%),
    radial-gradient(52% 62% at 88% 38%, var(--_c2-clr, rgba(255, 170, 64, .55)), transparent 76%),
    radial-gradient(50% 60% at 20% 82%, var(--_c3-clr, rgba(44, 190, 122, .55)), transparent 76%),
    radial-gradient(55% 65% at 70% 88%, var(--_c5-clr, rgba(130, 92, 255, .55)), transparent 78%);
}

.video-detail-ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(light-dark(rgba(255, 255, 255, 0.5), rgba(0, 0, 0, 0.33)), light-dark(rgba(255, 255, 255, 0.5), rgba(0, 0, 0, 0.33))),
    linear-gradient(
      to bottom,
      light-dark(#fff, #09090b) 0,
      light-dark(rgba(255, 255, 255, .08), rgba(9, 9, 11, .12)) 14%,
      rgba(0, 0, 0, .18) 34%,
      rgba(0, 0, 0, .48) 82%,
      light-dark(#fff, #09090b) 100%
    ),
    linear-gradient(to right, rgba(0, 0, 0, .30), rgba(0, 0, 0, .05) 35%, rgba(0, 0, 0, .32));
}

.video-detail-ambient-inner {
  width: min(1180px, calc(100vw - 2 * var(--space-4)));
  margin-inline: auto;
}

.video-detail-ambient h1 {
  max-width: none;
  color: #fff;
  margin: var(--space-5) 0 var(--space-3);
  font-size: clamp(1.5rem, 2.5vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-shadow: light-dark(0 2px 12px rgba(0, 0, 0, 0.72), 0 2px 22px rgba(0, 0, 0, 0.44));
}

.video-detail-ambient nav.breadcrumb {
  margin-bottom: var(--space-3);
}

.video-detail-ambient nav.breadcrumb,
.video-detail-ambient nav.breadcrumb a,
.video-detail-ambient nav.breadcrumb span {
  color: light-dark(rgba(24, 24, 27, .68), rgba(255, 255, 255, .78));
}

.video-detail-ambient nav.breadcrumb a:hover {
  color: light-dark(#18181b, #fff);
}

.video-detail-stage {
  position: relative;
  margin-top: var(--space-4);
}

.video-detail-stage > section {
  margin-bottom: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

.video-detail-stage > section > a,
.video-detail-stage > section img[data-thumb] {
  display: block;
  border-radius: 0;
}

.video-detail-stage > section img[data-thumb] {
  width: 100%;
}

.video-detail-ambient .badge.outline {
  border-color: light-dark(rgba(24, 24, 27, .18), rgba(255, 255, 255, .26));
  background: light-dark(rgba(255, 255, 255, .66), rgba(255, 255, 255, .13));
  color: light-dark(#18181b, #fff);
  backdrop-filter: blur(16px) saturate(1.15);
}

.video-detail-ambient .badge.outline b {
  color: light-dark(rgba(24, 24, 27, .62), rgba(255, 255, 255, .7));
}

.video-detail-ambient .badge.outline a,
.video-detail-ambient .badge.outline time {
  color: light-dark(#18181b, #fff);
}

.video-detail-description {
  margin-top: var(--space-5);
}

.video-detail-description,
.video-detail-page > nav.prevnext {
  width: min(1180px, calc(100vw - 2 * var(--space-4)));
  margin-inline: auto;
  box-sizing: border-box;
}

.video-detail-description > header h2 {
  font-size: var(--text-4);
}

.detail-quick-nav {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.detail-quick-nav__arrow {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 64px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 6px;
  background: rgba(20, 20, 24, .34);
  color: rgba(255, 255, 255, .92);
  text-decoration: none;
  overflow: hidden;
  z-index: 2;
  pointer-events: auto;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .26);
  backdrop-filter: blur(18px) saturate(1.25);
  transition: background .18s ease, transform .18s ease, opacity .18s ease;
}

.detail-quick-nav__arrow--left {
  left: -14px;
  transform: translateY(-50%);
}

.detail-quick-nav__arrow--right {
  right: -14px;
  transform: translateY(-50%);
}

.detail-quick-nav__arrow:hover {
  color: #fff;
  background: rgba(255, 255, 255, .24);
}

.detail-quick-nav__arrow--left:hover {
  transform: translateY(-50%) translateX(-2px);
}

.detail-quick-nav__arrow--right:hover {
  transform: translateY(-50%) translateX(2px);
}

.detail-quick-nav__arrow svg {
  display: block;
  width: 8.5px;
  height: 30.5px;
  fill: currentColor;
  flex: 0 0 auto;
}

.detail-quick-nav__arrow .video-nav-caret--right {
  transform: scaleX(-1);
}

@media (max-width: 760px) {
  .video-detail-ambient {
    padding-block: var(--space-4) var(--space-5);
  }
  .video-detail-ambient h1 {
    max-width: none;
    font-size: var(--text-3);
    margin-top: var(--space-4);
  }
  .video-detail-stage > section {
    border-radius: 10px;
  }
  .detail-quick-nav__arrow {
    width: 34px;
    height: 52px;
  }
  .detail-quick-nav__arrow--left { left: 8px; }
  .detail-quick-nav__arrow--right { right: 8px; }
  .detail-quick-nav__arrow svg {
    width: 7.5px;
    height: 27px;
  }
}

.play-overlay { 
  position: absolute; 
  bottom: 1.5rem; 
  left: 1.5rem; 
  background: rgba(0, 0, 0, 0.7); 
  color: #fff; 
  padding: 0.75rem 1.5rem; 
  border-radius: var(--radius-full); 
  font-weight: var(--font-bold); 
  text-decoration: none; 
  display: inline-flex; 
  align-items: center; 
  gap: 0.75rem; 
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, background 0.2s ease;
}
.play-overlay:hover { 
  background: rgba(0, 0, 0, 0.85); 
  color: #fff; 
  transform: scale(1.05); 
}

/* Badges on detail page */
.badge.outline { border-color: var(--border); font-weight: var(--font-medium); }
.badge.outline b { color: var(--muted-foreground); font-weight: var(--font-normal); margin-right: 0.25rem; }

/* Markdown content pages */
.prose { max-width: 70ch; margin: 0 auto; line-height: 1.7; }
.prose h1, .prose h2, .prose h3 { margin-top: 2em; }
.prose ul, .prose ol { padding-inline-start: 1.5em; margin-bottom: 1.5em; }
.prose li { margin-bottom: 0.5em; }

/* Utility classes */
.text-light { color: var(--muted-foreground); font-size: 0.9em; font-weight: var(--font-normal); }
.ml-2 { margin-inline-start: var(--space-2); }
.mr-2 { margin-inline-end: var(--space-2); }
.mt-8 { margin-top: var(--space-8); }
.no-underline { text-decoration: none; }
.no-underline:hover { text-decoration: underline; }
.block { display: block; }

/* Nav search input */
input.small { 
  width: 100%;
  padding-top: var(--space-1); 
  padding-bottom: var(--space-1); 
  font-size: var(--text-7);
  height: auto;
}

/* Shared button width: matches a single card column.
   Mobile (< 768px, .row collapses to 4 cols → col-4 is full-width)  →  100%
   Desktop (≥ 768px, .row is 12 cols → col-4 is 1/3)                 →  ~1/3 minus two gap widths
   inline-flex so any icon + label span align centred on the same axis
   instead of dropping to the text baseline. Used by the load-more
   button on /videos and the "More videos →" CTA on the homepage. */
.btn-col {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
}
@media (min-width: 768px) {
  .btn-col { width: calc((100% - 2 * var(--space-4)) / 3); }
}
#load-more-btn {
  transition: all 0.2s ease;
  border-width: 2px;
}
#load-more-btn:hover { border-color: var(--brand-red); color: var(--brand-red); background: var(--brand-red-muted); }

/* Search bar magnifier icon — absolutely positioned inside the form,
   text-indented input so the placeholder/value clears the icon. */
.search-form { position: relative; }
.search-form > .search-icon {
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.search-form > input[type="search"] {
  padding-left: calc(var(--space-2) * 2 + 16px);
}

/* ---------- Error pages (404 / 500 / 503 / …) ---------- */
.error-page {
  max-width: 40rem;
  margin: var(--space-6) auto;
}
.error-page h1 {
  font-size: var(--text-3);
  margin-bottom: var(--space-2);
}
.error-page > p { color: var(--muted-foreground); }

/* ---------- Location filter input (used on /map) ---------- */
.location-filter-wrap {
  position: relative;
}
.location-filter-wrap input[type="text"] {
  padding-right: 2.25rem;  /* room for the X button */
}
.location-filter-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: var(--text-7);
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: none;  /* shown when input has a value */
}
.location-filter-wrap.has-value .location-filter-clear { display: inline-flex; align-items: center; justify-content: center; }
.location-filter-clear:hover { background: var(--faint); color: var(--foreground); }

/* ---------- /map page (Leaflet) ---------- */
/* Container — shorter so the locations list under it is visible without
   immediate scrolling. */
.map-container {
  height: 55vh;
  min-height: 360px;
  border-radius: var(--radius-medium);
  border: 1px solid var(--border);
  overflow: hidden;
}
/* Hide markers instantly during zoom (no CSS transition — Leaflet's zoom
   animation is ~250ms and a 150ms opacity transition just kept the dots
   visible for most of the slide). */

/* Marker popup — compact for 1-2 videos, 3-column for larger cities. */
#map .leaflet-popup-pane {
  z-index: 900;
}
#map .leaflet-popup {
  z-index: 900;
}
#map .leaflet-popup-content {
  margin: 8px 10px;
}
.map-popup {
  width: 100%;
}
.map-popup--1 { width: 166px; }
.map-popup--2 { width: 232px; }
.map-popup--3 { width: 306px; }
.map-popup h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-6);
  padding-right: 20px;
}
.map-popup h4 a {
  color: var(--brand-red);
  text-decoration: none;
}
.map-popup h4 a:hover { text-decoration: underline; }
.map-popup-grid {
  display: grid;
  gap: 4px;
}
.map-popup--1 .map-popup-grid { grid-template-columns: 1fr; }
.map-popup--2 .map-popup-grid { grid-template-columns: repeat(2, 1fr); }
.map-popup--3 .map-popup-grid { grid-template-columns: repeat(3, 1fr); }
.map-popup-thumb {
  display: block;
  position: relative;
  line-height: 0;
}
.map-popup-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.map-popup-thumb:hover img { outline: 2px solid var(--brand-red); }
.map-popup-date {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border-radius: 3px;
  font-weight: var(--font-medium, 500);
}
.map-popup-more {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--text-7);
  color: var(--brand-red);
}

/* ---------- Archive ---------- */
.archive-years {
  display: grid;
  gap: var(--space-5);
}
.archive-year-card {
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0 var(--space-5);
}
.archive-year-card:last-child { border-bottom: 0; }
.archive-year-card header { margin-bottom: var(--space-3); }
.archive-year-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
}
.archive-year-heading a {
  color: inherit;
  text-decoration: none;
}
.archive-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.archive-strip-thumb {
  border-radius: var(--radius-medium);
  display: block;
  line-height: 0;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}
.archive-strip-thumb img {
  border-radius: 0;
  display: block;
  width: 100%;
}
.archive-strip-thumb:hover {
  border-color: var(--brand-red);
}
.archive-strip-thumb:hover img { transform: scale(1.03); }
@media (max-width: 760px) {
  .archive-strip {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: var(--space-2);
  }
}

/* Ranked city labels. JS places only a capped, non-overlapping subset
   after zoom/pan settles; the marker dot stays as the visual anchor. */
.popmap-label-overlay {
  position: absolute;
  inset: 0;
  z-index: 620;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 120ms ease;
}
.popmap-label-overlay.is-hidden {
  opacity: 0;
}
.popmap-label-overlay.is-hidden .popmap-label {
  pointer-events: none;
}
.popmap-label {
  position: absolute;
  transform: translate3d(-9999px, -9999px, 0);
  opacity: 0;
  pointer-events: none;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  border: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  white-space: nowrap;
  will-change: transform;
  transition: opacity 90ms ease;
}
.popmap-label.is-visible {
  opacity: 1;
  pointer-events: auto;
}
@media (pointer: coarse) {
  .popmap-label.is-visible { pointer-events: none; }
}
.popmap-label:hover {
  background: #fff;
  color: var(--brand-red);
  z-index: 2;
}

/* ---------- Shorts (portrait 9:16) ---------- */
/* Override the 16:9 thumbnail rule for shorts. The short-card .img-wrapper
   gets a 9:16 box; the <img> still fills the wrapper, just in a different
   aspect-ratio container. */
/* Unique portrait (9:16) short card properties */
/* The wrapper enforces 9:16 via aspect-ratio. The <a> intermediary is
   stretched over the box so the <img> has a sized parent to fill, and
   object-fit:cover center-crops YouTube's 16:9 thumbnail into the
   portrait frame. Don't fight YouTube on this. */
article.short-card .img-wrapper > a {
  position: absolute;
  inset: 0;
  display: block;
}
article.short-card img[data-thumb] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: auto;
}
article.short-card a { text-decoration: none; color: inherit; display: block; }
article.short-card header {
  padding: var(--space-2) var(--space-3);
  flex-grow: 1;
}
article.short-card header > h3,
article.short-card header > h4 {
  font-size: var(--text-7);
  font-weight: var(--font-semibold);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
article.short-card footer {
  padding: var(--space-1) var(--space-3) var(--space-2);
}

/* Hero: a single centred short, with a wide LQIP-coloured ambient backdrop
   spanning the full content width. The backdrop reuses the decoded LQIP
   gradient (via static/lqip.css) on the .shorts-hero-bg layer, blurred
   and desaturated so the centred frame still pops above it. */
.shorts-hero {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
  padding: var(--space-6) var(--space-4);
  border-radius: var(--radius-medium);
  overflow: hidden;
  isolation: isolate;
}
.shorts-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  /* Push the gradient out a bit so blurred edges don't reveal the cut. */
  margin: -10%;
  filter: blur(60px) saturate(1.3);
  opacity: 0.75;
  pointer-events: none;
}
.shorts-hero-frame {
  position: relative;
  z-index: 1;
  width: min(100%, 920px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 360px);
  gap: var(--space-5);
  align-items: center;
}
.shorts-hero-frame > .short-hero {
  width: 100%;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}
.shorts-hero .short-card header > h2 {
  font-size: var(--text-5);
  font-weight: var(--font-bold);
  margin: 0;
  line-height: 1.25;
}
.shorts-hero-description {
  grid-column: 1;
  grid-row: 1;
  padding: var(--space-5);
  border: 1px solid light-dark(rgba(24, 24, 27, .12), rgba(255, 255, 255, .18));
  border-radius: var(--radius-medium);
  background: light-dark(rgba(255, 255, 255, .74), rgba(9, 9, 11, .58));
  color: light-dark(#18181b, #fafafa);
  backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 18px 55px light-dark(rgba(24, 24, 27, .12), rgba(0, 0, 0, .28));
}
.shorts-hero-description-prose {
  font-size: var(--text-6);
  line-height: 1.55;
}
.shorts-hero-description-prose p,
.shorts-hero-description-prose br:first-child {
  margin-top: 0;
}
.shorts-hero-description-prose a {
  color: inherit;
}

@media (max-width: 760px) {
  .shorts-hero-frame {
    width: min(95vw, 360px);
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .shorts-hero-frame > .short-hero,
  .shorts-hero-description {
    grid-column: 1;
    grid-row: auto;
  }
  .shorts-hero-frame > .short-hero {
    order: 1;
  }
  .shorts-hero-description {
    order: 2;
  }
  .shorts-hero-description {
    padding: var(--space-4);
  }
}
/* A shorts playlist on /shorts is one card: the clickable header at the
   top, then the horizontal row of tiles. They live inside .shorts-playlist-card
   so the visual chrome is a single box. */
.shorts-playlist-card {
  padding: var(--space-3);
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.shorts-playlist-card .playlist-body { margin: 0; }

/* Clickable header link — thumb + meta side-by-side. No nested border
   anymore (the outer card carries it). */
.playlist-header {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-medium);
  transition: background-color 0.2s ease;
}
.playlist-header:hover { background: var(--faint); }
.playlist-header:hover .playlist-meta > h3 { color: var(--brand-red); }
/* The orphan card has no playlist destination — keep the visual chrome
   but skip the hover affordance so it doesn't suggest interactivity. */
.playlist-header.playlist-header-static { cursor: default; }
.playlist-header.playlist-header-static:hover { background: transparent; }
.playlist-header.playlist-header-static:hover .playlist-meta > h3 { color: inherit; }
.playlist-header .playlist-thumb {
  flex: 0 0 240px;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: var(--radius-medium);
  border: 1px solid var(--border);
}
.playlist-header .playlist-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: auto;
}
.playlist-header .playlist-meta { flex: 1; min-width: 0; }
.playlist-header .playlist-meta > h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-5);
  transition: color 0.2s ease;
}
.playlist-header .playlist-meta > p {
  margin: 0;
  color: var(--muted-foreground);
}
@media (max-width: 640px) {
  .playlist-header { flex-direction: column; }
  .playlist-header .playlist-thumb { flex: 0 0 auto; width: 100%; max-width: 360px; }
}

/* Shorts row — Swiffy Slider markup with our tile sizing.
   Swiffy's CSS already provides the swipe + snap behaviour; we override
   the list/item defaults so the cards keep their look. */
.shorts-row.swiffy-slider {
  /* Positioning context for the nav buttons (relative is Swiffy's default
     but we make it explicit since our card padding nests differently). */
  position: relative;
  display: block;
  width: 100%;
}
.shorts-row .slider-container {
  list-style: none;
  padding-left: 0;
  margin: 0;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  display: grid;
  align-items: stretch;
  grid-auto-flow: column;
  grid-auto-rows: 1fr;
  grid-template-rows: 1fr;
  grid-gap: var(--space-3);
}
.shorts-row .slider-container::-webkit-scrollbar { display: none; }
.shorts-row .slider-container > li.short-tile {
  list-style: none;
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  scroll-snap-align: start;
}
/* Tile width is responsive so the row shows "as many as fit":
     mobile (<640px)   →  ~1 tile + a peek of the next (signals scrollability)
     small (640–1023)  →  3 tiles per row
     desktop (≥1024)   →  5 tiles per row
   Swiffy's .slider-container is `display: grid; grid-auto-columns: 100%`,
   so we override grid-auto-columns directly — flex/basis rules wouldn't
   apply in a grid context. */
.shorts-row .slider-container {
  grid-auto-columns: 88%;
}
@media (min-width: 640px) {
  .shorts-row .slider-container {
    grid-auto-columns: calc((100% - 2 * var(--space-3)) / 3);
  }
}
@media (min-width: 1024px) {
  .shorts-row .slider-container {
    grid-auto-columns: calc((100% - 4 * var(--space-3)) / 5);
  }
}
/* Bring the prev/next buttons up to the tile vertical centre so they sit
   over the thumbnails, not the captions below them. */
.shorts-row .slider-nav {
  top: 0;
  bottom: auto;
  height: calc(100% - 3.5rem);  /* leave the caption area uncovered */
  z-index: 10;
  pointer-events: auto;
}

/* Short video detail page: 9:16 box that never overflows the viewport.
   Width is the MOST restrictive of three ceilings via min():
     * 95vw  – leaves a gutter so the box never touches the edges
     * calc(80vh * 9/16) – derived width when 80% of viewport height is the cap
     * 1080px – matches YouTube's native portrait width (=> height ≤ 1920px)
   Whichever caps the smallest wins, so even on a narrow-but-tall window
   (e.g. 600×1200) the box fits without page scroll.
   Applies to whatever direct child renders the player — the embedded
   YouTube <iframe> for shorts, or the click-through <a> fallback. */
/* Short detail page: the wrapper itself is sized to the player so an
   absolute-positioned caption inside is anchored to the video frame
   (not the page width). Width is the most restrictive of three ceilings:
     95vw  – leaves a gutter so the box never touches the edges
     calc(80vh * 9/16) – derived width from an 80vh height cap
     1080px – matches YouTube's native portrait width (=> height ≤ 1920px). */
.short-detail-thumb {
  position: relative;
  display: block;
  margin: 0 auto;
  width: min(95vw, calc(80vh * 9 / 16), 1080px);
  aspect-ratio: 9/16;
  border-radius: var(--radius-medium);
  overflow: hidden;
  background: var(--faint);
}
.short-detail-thumb > a,
.short-detail-thumb > iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  aspect-ratio: auto;  /* parent already enforces 9:16 */
}
.short-detail-thumb img[data-thumb] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: auto;
}

.short-detail-container {
  width: min(1180px, calc(100vw - 2 * var(--space-4)));
  margin-inline: auto;
  box-sizing: border-box;
}

.short-detail-stage {
  position: relative;
  width: min(95vw, calc(80vh * 9 / 16), 1080px);
}

.short-detail-layout {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.short-detail-layout .short-detail-stage {
  margin: 0;
}
.short-detail-layout-spacer {
  display: none;
}
.short-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.short-detail-description-desktop {
  display: none;
}
.short-description-dialog {
  width: min(92vw, 42rem);
  max-height: min(82vh, 44rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: light-dark(#fff, #18181b);
  color: var(--foreground);
}
.short-description-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.short-description-dialog-card {
  padding: var(--space-4);
  margin: 0;
  max-height: inherit;
  overflow: auto;
}
.short-description-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.short-description-dialog-header h2,
.short-detail-description-desktop h2 {
  margin: 0;
  font-size: var(--text-5);
}
.short-description-close {
  min-width: 2rem;
  padding-inline: 0.65rem;
}
.short-description-prose {
  max-width: none;
  margin: 0;
  font-size: var(--text-7);
  line-height: 1.55;
}
.short-description-prose p:last-child {
  margin-bottom: 0;
}

@media (min-width: 960px) {
  .short-detail-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: var(--space-6);
    width: 100%;
  }
  .short-detail-description-desktop {
    display: block;
    align-self: end;
    width: 100%;
    max-width: 320px;
    justify-self: start;
    max-height: 80vh;
    overflow: auto;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: light-dark(#fff, #18181b);
    color: var(--foreground);
  }
  .short-detail-description-desktop h2 {
    margin-bottom: var(--space-3);
  }
  .short-detail-layout-spacer {
    display: block;
    width: 100%;
    max-width: 320px;
    justify-self: end;
  }
  .short-description-dialog-button {
    display: none;
  }
}

/* 'More Shorts' grid: auto-fill so the row count grows with the
   viewport width without bespoke breakpoints. Used for the catch-all
   list of shorts that aren't (yet) in any user playlist. */
.shorts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .shorts-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 1280px) {
  .shorts-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
