/* ── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* scroll-snap removed — JS handles section transitions */
  overflow-x: hidden;
}

/* ── External SVG icons via CSS mask (color via currentColor) ── */
.icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  background-color: currentColor;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  flex-shrink: 0;
}
.icon-close       { -webkit-mask-image: url(../icons/close.svg);       mask-image: url(../icons/close.svg); }
.icon-menu        { -webkit-mask-image: url(../icons/menu.svg);        mask-image: url(../icons/menu.svg); }
.icon-mute        { -webkit-mask-image: url(../icons/mute.svg);        mask-image: url(../icons/mute.svg); }
.icon-unmute      { -webkit-mask-image: url(../icons/unmute.svg);      mask-image: url(../icons/unmute.svg); }
.icon-share       { -webkit-mask-image: url(../icons/share.svg);       mask-image: url(../icons/share.svg); }
.icon-copied      { -webkit-mask-image: url(../icons/copied.svg);      mask-image: url(../icons/copied.svg); }
.icon-fullscreen  { -webkit-mask-image: url(../icons/fullscreen.svg);  mask-image: url(../icons/fullscreen.svg); }
.icon-chevron-up  { -webkit-mask-image: url(../icons/chevron-up.svg);  mask-image: url(../icons/chevron-up.svg); }
.icon-instagram   { -webkit-mask-image: url(../icons/instagram.svg);   mask-image: url(../icons/instagram.svg); }
.icon-x           { -webkit-mask-image: url(../icons/x.svg);           mask-image: url(../icons/x.svg); }
.icon-youtube     { -webkit-mask-image: url(../icons/youtube.svg);     mask-image: url(../icons/youtube.svg); }
.icon-bluesky     { -webkit-mask-image: url(../icons/bluesky.svg);     mask-image: url(../icons/bluesky.svg); }
.icon-arrow-up    { -webkit-mask-image: url(../icons/arrow-up.svg);    mask-image: url(../icons/arrow-up.svg); }
.icon-arrow-down  { -webkit-mask-image: url(../icons/arrow-down.svg);  mask-image: url(../icons/arrow-down.svg); }

/* Sort toggle: two arrows side by side, dim inactive */
#sort-toggle { display: flex; align-items: center; justify-content: center; padding: 0; }
#sort-toggle .icon { opacity: 0.25; transition: opacity 0.15s; width: 22px; height: 22px; }
#sort-toggle .icon.arrow-down { margin-left: -10px; }
#sort-toggle .icon.active { opacity: 1; }

html.panel-open,
html.panel-open body {
  overflow: hidden !important;
  height: 100%;
}


body {
  font-family: 'Montserrat', sans-serif;
  background-color: #000;
  color: #f0f0f0;
  overflow-x: hidden;
  width: 100%;
}

/* ── Video section ─────────────────────────────────────────────── */
.video-section {
  width: 100%;
  height: 100vh;
  height: 100dvh; /* iOS Safari: shrink with tab bar visible */
  position: relative;
  background: #000;
  overflow: hidden;
  /* Isolate compositing so overlays inside don't trigger video color profile
     changes when their visibility/backdrop-filter toggles. */
  isolation: isolate;
}

.video-section video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: none;
  /* Always GPU-composited so toggling overlays with backdrop-filter
     (permalink CTA pill) doesn't trigger a layer promotion mid-playback
     that shifts color rendering. */
  transform: translateZ(0);
  will-change: transform;
}


/* ── Overlay controls ──────────────────────────────────────────── */
.video-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.video-overlay .btn-icon {
  pointer-events: auto;
}


.video-section.show-overlay .video-overlay {
  opacity: 1;
}

.video-section.hide-cursor {
  cursor: none;
}

/* Auto-hide controls after inactivity */
.video-section .menu-btn,
.video-section .player-controls {
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.video-section.show-overlay .menu-btn,
.video-section.show-overlay .player-controls {
  opacity: 1;
  pointer-events: auto;
}

/* Dim logo & caption to 50% when controls hidden (burn-in prevention) */
.video-section .video-info-text {
  opacity: 0.5;
  transition: opacity 0.3s;
}

.video-section.show-overlay .video-info-text {
  opacity: 1;
}

.video-section:fullscreen .site-logo.visible,
html.pseudo-fullscreen .video-section .site-logo.visible {
  opacity: 0.5;
  pointer-events: auto;
}

.video-section:fullscreen.show-overlay .site-logo.visible,
html.pseudo-fullscreen .video-section.show-overlay .site-logo.visible {
  opacity: 1;
}

/* Pseudo-fullscreen (iOS fallback): make video section fill the viewport
   without using the native iOS video fullscreen player (which breaks
   dual-buffer video swapping). */
html.pseudo-fullscreen,
html.pseudo-fullscreen body {
  overflow: hidden !important;
  height: 100%;
}
html.pseudo-fullscreen .video-section {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
}
html.pseudo-fullscreen .timeline-section,
html.pseudo-fullscreen .timeline-controls {
  display: none !important;
}

.player-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.player-controls .btn-icon {
  padding: 10px;
}

.player-controls .btn-icon svg,
.player-controls .btn-icon .icon {
  width: 28px;
  height: 28px;
  fill: #fff;
  color: #fff;
}

#share-btn svg {
  width: 25px;
  height: 25px;
}

.video-info-text {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 1.5rem;
  font-weight: 500;
  color: #fff;
  text-align: right;
  line-height: 1.5;
  z-index: 11;
  pointer-events: auto;
}

.info-stacked {
  display: none;
}

.info-inline {
  white-space: nowrap;
}

/* Switch to stacked layout when inline would overlap controls */
@media (max-width: 768px) {
  .player-controls {
    bottom: 16px;
    left: 16px;
  }
  .player-controls .btn-icon svg {
    width: 36px;
    height: 36px;
  }
  .video-info-text {
    font-size: 1rem;
    bottom: 16px;
    right: 16px;
  }
  .info-inline { display: none; }
  .info-stacked { display: inline; }
}

/* Landscape phones — width can exceed 768px but vertical space is tight */
@media (orientation: landscape) and (max-height: 500px) {
  .video-info-text {
    font-size: 0.85rem;
    bottom: 12px;
    right: 14px;
  }
  .info-inline { display: none; }
  .info-stacked { display: inline; }
  .player-controls {
    bottom: 10px;
    left: 12px;
  }
  .player-controls .btn-icon svg,
  .player-controls .btn-icon .icon {
    width: 26px;
    height: 26px;
  }
}

/* Hide tagline on narrow viewports so it doesn't crowd the filter icon.
   Keep the logo mark at its default 72px — alignment with the filter
   icon already works at that size. */
@media (max-width: 600px) {
  .site-tagline { display: none; }
  .timeline-footer-title { font-size: 1.5rem; }
}

.info-link {
  cursor: pointer;
  transition: opacity 0.15s;
}
.info-link:hover {
  opacity: 0.7;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.overlay-info {
  font-size: 1.5rem;
  font-weight: 400;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Site logo ─────────────────────────────────────────────────── */
.site-logo {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 1em;
  text-decoration: none;
}

.site-logo.visible {
  opacity: 0.5;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.video-section.show-overlay .site-logo.visible {
  opacity: 1;
}

.site-tagline {
  font-size: 2.25rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ── Hamburger menu button ──────────────────────────────────────── */

.menu-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 11;
  pointer-events: auto;
}

.menu-btn.btn-icon svg,
.menu-btn.btn-icon .icon {
  width: 56px;
  height: 56px;
  fill: #fff;
  color: #fff;
}

/* ── Filter panel ──────────────────────────────────────────────── */
.filter-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 680px;
  max-width: 90vw;
  background: rgba(0, 0, 0, 0.85);
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.filter-panel.open {
  transform: translateX(0);
}

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-panel-header .btn-icon {
  padding: 12px;
}

.filter-panel-header .btn-icon svg,
.filter-panel-header .btn-icon .icon {
  width: 56px;
  height: 56px;
  color: #fff;
}

.filter-panel-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.05em;
}

.playback-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.playback-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.playback-mode {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s, background 0.2s;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.mode-btn.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.mode-btn:hover {
  opacity: 0.8;
}

.latest-btn {
  background: rgba(72, 199, 142, 0.2);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  white-space: nowrap;
  margin-left: 4px;
}

.latest-btn:hover {
  background: rgba(72, 199, 142, 0.35);
}

.mode-direction-btn {
  display: none;
  font-size: 1.1rem;
  padding: 10px 12px;
}

.mode-direction-btn.visible {
  display: block;
  opacity: 0.6;
}

.mode-direction-btn.visible:hover {
  opacity: 1;
}

.filter-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    "year  month day"
    "tag   tag   tag"
    "cam   cam   cam"
    "city  city  city"
    "spot  spot  spot";
  gap: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 0;
}
.filter-column:nth-child(1) { grid-area: year; }
.filter-column:nth-child(2) { grid-area: month; }
.filter-column:nth-child(3) { grid-area: day; }
.filter-column:nth-child(4) { grid-area: tag; }
.filter-column:nth-child(5) { grid-area: cam; }
.filter-column:nth-child(6) { grid-area: city; }
.filter-column:nth-child(7) { grid-area: spot; }

.filter-column {
  padding: 0 16px 16px;
  min-width: 0;
}

.filter-column h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.filter-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.filter-column li {
  font-size: 0.8rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.7);
  padding: 5px 0;
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.filter-column li:hover {
  color: #fff;
}

.filter-column li.active {
  color: #fff;
  font-weight: 600;
}

.filter-column li.active::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.filter-clear-btn {
  margin: 12px auto 16px;
  padding: 8px 20px;
  width: auto;
  display: block;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.filter-clear-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.permalink-cta {
  position: absolute;
  bottom: 14vh;
  left: 50%;
  /* translate3d (not translateX) so this element is composited up front and
     fading it in doesn't trigger a layer change that recolors the video. */
  transform: translate3d(-50%, 0, 0);
  z-index: 11;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  text-align: center;
  width: max-content;
  max-width: 90vw;
  will-change: opacity;
}

.permalink-cta-desc {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.permalink-cta.visible {
  opacity: 1;
  pointer-events: auto;
}

.permalink-cta a {
  display: inline-block;
  padding: 11px 26px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.03em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.permalink-cta a:hover {
  background: rgba(255, 255, 255, 0.25);
}

.filter-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 16px 0 8px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  fill: rgba(255, 255, 255, 0.5);
  transition: color 0.2s, fill 0.2s;
}

.filter-links a:hover {
  color: #fff;
  fill: #fff;
}

.filter-links a svg {
  fill: inherit;
}

.filter-about {
  margin: 8px 0 16px;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  letter-spacing: 0.02em;
}

/* Narrow screens: stack vertically */
@media (max-width: 480px) {
  .player-controls {
    bottom: 12px;
    left: 12px;
  }

  .video-info-text {
    font-size: 0.85rem;
    bottom: 12px;
    right: 12px;
  }

  .overlay-info {
    font-size: 0.7rem;
  }

  .filter-panel {
    width: 100%;
    max-width: 100vw;
  }

  /* Playback row: wrap onto multiple lines */
  .playback-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .playback-label {
    flex-basis: 100%;
  }
  .mode-btn {
    font-size: 0.9rem;
    padding: 8px 12px;
  }
  .latest-btn {
    margin-left: auto;
  }

  /* Year/Month side-by-side, everything else full-width with wrapping pills */
  .filter-columns {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "year   month"
      "day    day"
      "tag    tag"
      "cam    cam"
      "city   city"
      "spot   spot";
    overflow-y: auto;
    column-gap: 8px;
    align-content: start;
  }
  .filter-column { padding: 0 12px 12px; min-width: 0; }

}

/* Day/Month as compact pill grids to save vertical space (all viewports) */
#filter-day,
#filter-month {
  display: grid;
  gap: 3px;
}
#filter-day { grid-template-columns: repeat(7, 1fr); }
#filter-month { grid-template-columns: repeat(6, 1fr); }
#filter-day li,
#filter-month li {
  text-align: center;
  padding: 5px 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  font-size: 0.72rem;
  line-height: 1.2;
}
#filter-day li.active,
#filter-month li.active {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}
#filter-day li.active::before,
#filter-month li.active::before {
  display: none;
}
#filter-day li .count,
#filter-month li .count {
  display: none;
}

/* Tag / Camera / City / Spot as horizontal-wrap pill clouds */
#filter-tag,
#filter-camera,
#filter-city,
#filter-spot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#filter-tag li,
#filter-camera li,
#filter-city li,
#filter-spot li {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}
#filter-tag li.active,
#filter-camera li.active,
#filter-city li.active,
#filter-spot li.active {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 500;
}
#filter-tag li.active::before,
#filter-camera li.active::before,
#filter-city li.active::before,
#filter-spot li.active::before {
  display: none;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background-color 0.2s ease;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.btn-icon svg,
.btn-icon .icon {
  width: 22px;
  height: 22px;
  fill: #fff;
  color: #fff;
}

/* ── Timeline section ──────────────────────────────────────────── */
.timeline-section {
  min-height: 100vh;
  min-height: 100dvh;
  background: #000;
  position: relative;
  margin: 0;
  padding: 0;
}

.timeline-controls {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.timeline-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

.timeline-controls .btn-icon {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
  min-width: 48px;
  min-height: 48px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.timeline-controls .btn-icon:hover {
  background: #fff;
}

.timeline-controls .btn-icon svg,
.timeline-controls .btn-icon .icon {
  fill: #333;
  color: #333;
}

.timeline-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 16px 24px;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
}

.timeline-item {
  position: relative;
  width: 100%;
  padding: 0;
  /* Skip render/layout for offscreen items — critical for 50k+ timelines.
     intrinsic-size is an estimate so scroll geometry stays stable before
     the real item lays out. 16:9 @ ~860px + info line ≈ 500px. */
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* Virtual-scroll top spacer: grows as older items get pruned from DOM
   so scroll position is preserved. */
.timeline-spacer {
  width: 100%;
  height: 0;
  flex-shrink: 0;
}

.timeline-item + .timeline-item {
  margin-top: 32px;
}

.timeline-item-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.timeline-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.timeline-footer {
  display: flex;
  justify-content: center;
  padding: 60px 0 120px;
}

.timeline-footer a {
  display: flex;
  align-items: center;
  gap: 1em;
  text-decoration: none;
}

.timeline-footer img {
  display: block;
}

.timeline-footer-title {
  font-size: 2.25rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.timeline-item-info {
  position: relative;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.6;
  padding: 6px 0 0;
  pointer-events: auto;
}

.tl-info-link {
  cursor: pointer;
  transition: color 0.15s;
}
.tl-info-link:hover {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 2px;
}


/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .video-section {
    height: 50vh;
  }

  .timeline-section {
    /* scroll-snap-align: start; */
  }
}
