/* =============================================
   Home page only (index.html), loaded after style.css.
   Effects plan: docs/home-ui-plan.md. JS: js/home.js.
   Everything here is still under prefers-reduced-motion (see the end).
   ============================================= */

:root {
  --header-height: 80px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --reveal-duration: 0.8s;
  --curtain-radius: 32px;
  --glow-green: rgba(76, 105, 82, 0.28);
  --glow-light-green: rgba(143, 185, 150, 0.3);
  --glow-gold: rgba(233, 216, 166, 0.5);
  --glow-dark-green: rgba(111, 207, 151, 0.18);
  --glow-dark-gold: rgba(233, 216, 166, 0.14);
  --glow-dark-light-green: rgba(143, 185, 150, 0.16);
  --glow-card: rgba(76, 105, 82, 0.16);
}

/* same-page links (smooth, from style.css) stop below the fixed header */
html {
  scroll-padding-top: var(--header-height);
}

/* =============================================
   Header: fixed over the hero, frosted once you scroll (js adds .header--scrolled)
   ============================================= */

.header_section {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

/* without JS the header never turns frosted, so give it its background from the start */
html:not(.js) .header_section {
  background: rgba(13, 43, 13, 0.82);
}

.header_section.header--scrolled .container {
  padding-top: 12px;
  padding-bottom: 12px;
}

/* =============================================
   Hero: full screen, cross-fading photos, curtain on scroll
   ============================================= */

.hero_area {
  min-height: 100vh;
  min-height: 100svh;
  background: #0d2b0d;
}

/* The hero stays put and the next sections slide over it like a sheet.
   Only on screens tall enough to show the whole hero. */
@media (min-height: 640px) {
  .hero_area {
    position: sticky;
    top: 0;
  }
}

.hero_area ~ section,
.hero_area ~ footer {
  position: relative;
  z-index: 1;
}

/* the first section is the sheet: rounded top and a shadow on the hero */
.hero_area + .about_section {
  border-radius: var(--curtain-radius) var(--curtain-radius) 0 0;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.35);
}

.slider_section {
  padding: calc(var(--header-height) + 40px) 0 100px;
}

/* photos stacked; js/home.js moves .is-active every few seconds.
   Ken Burns only runs on the photo you see, and not while the sections cover the hero. */
.hero_area .bg-box img {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
}

.hero_area .bg-box img.is-active {
  opacity: 1;
}

.hero_area .bg-box img:not(.is-active),
.hero_area.is-covered .bg-box img {
  animation-play-state: paused;
}

/* stronger shade on the text side so it reads on every photo */
.hero_area .bg-overlay {
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.25) 55%, transparent 85%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.2) 35%, rgba(0, 0, 0, 0.25) 60%, rgba(13, 43, 13, 0.8) 100%);
}

/* darkens the photo as the sheet covers it (see the curtain below) */
.hero_area .bg-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000000;
  opacity: 0;
  pointer-events: none;
}

.hero-title,
.hero-subtitle {
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}

/* Curtain: as you scroll the first screen, the photo shrinks, rounds and darkens,
   and the hero text fades and lifts. Browsers without scroll animations just scroll. */
@supports (animation-timeline: scroll()) {
  @media (min-height: 640px) {
    .hero_area .bg-box {
      animation: heroShrink linear both;
    }

    .hero_area .bg-box::after {
      animation: heroDim linear both;
    }

    .slider_section > .container {
      animation: heroTextAway linear both;
    }

    /* the cue keeps its fade-in (time) and also leaves with the text (scroll) */
    .hero-scroll-cue {
      animation: fadeUp 0.7s 1.1s ease both, heroTextAway linear both;
    }

    /* timelines after the shorthands, which reset them */
    .hero_area .bg-box,
    .hero_area .bg-box::after,
    .slider_section > .container {
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }

    .slider_section > .container {
      animation-range: 0 70vh;
    }

    .hero-scroll-cue {
      animation-timeline: auto, scroll(root);
      animation-range: normal, 0 70vh;
    }
  }
}

@keyframes heroShrink {
  to {
    transform: scale(0.9);
    border-radius: var(--curtain-radius);
  }
}

@keyframes heroDim {
  to {
    opacity: 0.55;
  }
}

@keyframes heroTextAway {
  to {
    opacity: 0;
    transform: translateY(-80px);
  }
}

/* ---------- Blur-in title (js wraps each word in .hero-word) ---------- */
.hero-title.is-split {
  animation: none;
}

.hero-word {
  display: inline-block;
  animation: blurIn 0.9s var(--ease-out) both;
  animation-delay: calc(var(--i) * 90ms + 150ms);
}

@keyframes blurIn {
  from {
    opacity: 0;
    filter: blur(12px);
    transform: translateY(18px);
  }
}

/* the rest of the hero comes in after the title */
.hero-subtitle {
  animation-delay: 0.75s;
}

.hero-actions {
  animation-delay: 0.9s;
}

.hero-scroll-cue {
  animation-delay: 1.1s;
}

/* =============================================
   Scroll reveal (js adds .reveal, then .is-visible with a small stagger)
   ============================================= */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity var(--reveal-duration) var(--ease-out),
    transform var(--reveal-duration) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* =============================================
   Aurora: slow green and gold glow behind two section headers
   ============================================= */

.essentials-header,
.tophubs-header {
  position: relative;
  isolation: isolate;
}

.essentials-header::before,
.essentials-header::after,
.tophubs-header::before,
.tophubs-header::after {
  content: "";
  position: absolute;
  inset: -60px -15%;
  z-index: -1;
  pointer-events: none;
  animation: auroraDrift 18s ease-in-out infinite alternate;
}

.essentials-header::before {
  background:
    radial-gradient(40% 45% at 25% 45%, var(--glow-green), transparent 70%),
    radial-gradient(35% 45% at 75% 55%, var(--glow-gold), transparent 70%);
}

.essentials-header::after {
  background: radial-gradient(30% 40% at 50% 60%, var(--glow-light-green), transparent 70%);
  animation-duration: 24s;
  animation-direction: alternate-reverse;
}

.tophubs-header::before {
  background:
    radial-gradient(40% 45% at 25% 45%, var(--glow-dark-green), transparent 70%),
    radial-gradient(35% 45% at 75% 55%, var(--glow-dark-gold), transparent 70%);
}

.tophubs-header::after {
  background: radial-gradient(30% 40% at 50% 60%, var(--glow-dark-light-green), transparent 70%);
  animation-duration: 24s;
  animation-direction: alternate-reverse;
}

@keyframes auroraDrift {
  to {
    transform: translate(8%, 6%) scale(1.15);
  }
}

/* =============================================
   Destinations: filter, cards
   ============================================= */

/* the filter needs JS; without it all places show and the buttons stay hidden */
html:not(.js) .places_section .filters_menu {
  display: none;
}

.places_section .filters_menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 36px 0 40px;
}

.filters_menu .filter-btn {
  padding: 7px 22px;
  border-radius: 50px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #4b5563;
  border: 1.5px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.filters_menu .filter-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filters_menu .filter-btn[aria-pressed="true"] {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.filters_menu .filter-btn:focus-visible {
  outline: 2px solid var(--highlight-color);
  outline-offset: 2px;
}

/* cards slide to their new place when the filter changes (View Transitions) */
::view-transition-group(*) {
  animation-duration: 0.45s;
  animation-timing-function: var(--ease-out);
}

/* placeholder colour while a photo loads; the photo then fades in */
.places_section .place-card .card-img {
  background: #2d4a33;
}

.places_section .place-card .card-img img {
  transition: transform 0.5s ease, opacity 0.6s ease;
}

.places_section .place-card .card-img img.is-loading {
  opacity: 0;
}

/* region label as wide as its text, not the whole card */
.places_section .place-card .card-region {
  align-self: flex-start;
}

.places_section .place-card .card-explore::after {
  transition: transform 0.25s ease;
}

.places_section .place-card:hover .card-explore::after {
  transform: translateX(4px);
}

/* =============================================
   Mouse only: card tilt + shine, Essentials glow (js sets --mx/--my/--rx/--ry)
   ============================================= */

@media (hover: hover) and (pointer: fine) {
  .places_section .place-card {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 0.2s ease-out, box-shadow 0.3s ease;
  }

  .places_section .place-card:hover {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
  }

  .places_section .place-card .card-img::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.22), transparent 55%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .places_section .place-card:hover .card-img::after {
    opacity: 1;
  }

  .essential-card {
    isolation: isolate;
  }

  .essential-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), var(--glow-card), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .essential-card:hover::before {
    opacity: 1;
  }
}

/* =============================================
   Top Destinations: score rings fill up when they come into view
   ============================================= */

@property --score-pct {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.reveal .ring {
  animation: ringFill 1.4s var(--ease-out) both paused;
}

.reveal.is-visible .ring {
  animation-play-state: running;
  animation-delay: calc(var(--reveal-delay, 0ms) + 300ms);
}

@keyframes ringFill {
  from {
    --score-pct: 0%;
  }
}

/* =============================================
   Phones
   ============================================= */

@media (max-width: 767px) {
  :root {
    --header-height: 72px;
    --curtain-radius: 24px;
  }

  .slider_section {
    padding: calc(var(--header-height) + 24px) 0 80px;
  }

  /* text is centred on phones, so shade the whole photo evenly */
  .hero_area .bg-overlay {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.4) 40%, rgba(0, 0, 0, 0.45) 70%, rgba(13, 43, 13, 0.85) 100%);
  }
}

/* =============================================
   Reduced motion: no movement at all, everything visible
   ============================================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
