/*
 * The live demo v3 rooftop engine (demov3.alrashid-properties.sa, v37), restyled for demov1.
 * Only the mechanics come from Demo 3: the hero film, the flight into the rooftop television
 * and the villa walk. Everything a visitor reads follows demov4:
 *   - the hero keeps demov4's own heading, lede and finder (HomeHero.vue) over a full-screen film;
 *   - the walk's caption uses the site type (.display .t-2, the lede size) over the film;
 *   - its footer bar and stops menu are bands in the logo teal (.tide), as in main.css;
 *   - phones held upright show the whole film in a 16:9 strip under the header, as Demo 3, with
 *     the hero copy and then the walk's caption band filling the screen below it.
 * The engine adds the site classes itself (rooftop.js): this file only lays them out.
 */

/* Before the engine mounts (the short Nuxt hydration step): the opening frame, no copy yet. */
#home-hero:not([data-rooftop]) .hero__frame { background: var(--color-lagoon-950) url('/rooftop-media/hero-r38-opening.webp') center / cover no-repeat; }
#home-hero:not([data-rooftop]) :is(.hero__media,.hero__title,.hero__lede,.hero__foot) { visibility: hidden; }

#home-hero[data-rooftop] {
  /* Lines up with the page's .wrap content. */
  --rx-edge: max(var(--gutter), calc((100% - var(--ui-container)) / 2 + var(--gutter)));
  --rx-ui: 1;
  --rx-rise: 0px;
  --rx-dock: 112%;
  --rx-safe: max(1.25rem, env(safe-area-inset-bottom, 0px));
  position: relative; height: var(--rx-height, 1600svh) !important;
  min-height: 0; margin: 0 !important; padding: 0; background: var(--color-lagoon-950); z-index: 1;
}
#home-hero[data-rooftop] .hero__stage {
  height: 100svh !important; width: 100%; top: 0; position: sticky !important;
  overflow: hidden; isolation: isolate; visibility: visible !important; pointer-events: auto !important;
  background: var(--color-lagoon-950); transform: none !important;
}

/* ---------- Hero copy: demov4's own heading, lede and finder ---------- */
/* The frame now only carries the copy and its shade; the engine's film plays beneath it.
   It fades and rises away as the camera heads for the television. */
#home-hero[data-rooftop] .hero__frame {
  z-index: 4; background: transparent !important; clip-path: none !important;
  mask: none !important; -webkit-mask: none !important; transform: none !important;
  pointer-events: none !important; overflow: visible;
  opacity: var(--rx-ui);
}
#home-hero[data-rooftop] .hero__media { display: none !important; }
#home-hero[data-rooftop] .hero__content {
  /* Room under the lede and finder for the film's play and scroll controls. */
  padding-bottom: calc(var(--rx-safe) + 4.25rem);
  transform: translateY(var(--rx-rise)) !important;
}
#home-hero[data-rooftop] .hero__title { --hero-chrome: 30rem; }
@media (min-width: 48rem) { #home-hero[data-rooftop] .hero__title { --hero-chrome: 27rem; } }
@media (min-width: 64rem) { #home-hero[data-rooftop] .hero__title { --hero-chrome: 24.5rem; } }
#home-hero[data-rooftop] .finder { pointer-events: auto; }
#home-hero[data-rooftop][data-away] .hero__content { visibility: hidden; }
#home-hero[data-rooftop] + #home-journey { display: none !important; }

/* ---------- Film ---------- */
.rx-screen { position: absolute; z-index: 1; inset: 0; color: #fff; direction: inherit; }
.rx-film { position: absolute; inset: 0; overflow: hidden; background: var(--color-lagoon-950); }
.rx-film > video, .rx-film > img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%;
  display: block; margin: 0; border: 0; pointer-events: none; opacity: 0;
}
.rx-film > [data-front] { opacity: 1; }
.rx-film > [data-early] { z-index: 1; transition: opacity .28s ease; }
/* The tour's shade (as the v1 tour): it comes in as the hero copy and its own shade leave. */
.rx-screen::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgb(15 39 46 / 0.82) 0%, rgb(15 39 46 / 0.28) 38%, transparent 62%);
  opacity: calc(1 - var(--rx-ui, 1));
}
/* Once the camera leaves the hero the film plays clear, as Demo 3: only a faint lift at its foot.
   The walk's caption carries its own soft shadow instead of a full-screen gradient. */
#home-hero[data-rooftop][data-phase] .rx-screen::after {
  background: linear-gradient(to top, rgb(15 39 46 / 0.17), transparent 21%);
}

/* ---------- Overlay ---------- */
.rx-overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; color: #fff; }
.rx-overlay button, .rx-overlay a { font: inherit; color: inherit; touch-action: manipulation; pointer-events: auto; cursor: pointer; }
.rx-overlay :focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.rx-overlay svg { width: 1.125rem; height: 1.125rem; display: block; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.rx-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Demo 3's own headlines give way to demov4's heading. */
.rx-head { display: none !important; }

/* Play / pause and "scroll into the television", under the hero copy. */
.rx-tools {
  position: absolute; inset-inline-start: var(--rx-edge); bottom: var(--rx-safe);
  display: flex; gap: 1rem; align-items: center;
  opacity: var(--rx-ui); transform: translateY(var(--rx-rise));
}
.rx-action, .rx-cue, .rx-step, .rx-skip, .rx-watch { border: 0; background: transparent; }
.rx-action { display: inline-grid; place-items: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0; }
.rx-action + .rx-cue { border-inline-start: 1px solid rgb(255 255 255 / 0.35); padding-inline-start: 1rem; }
.rx-cue { display: inline-flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; padding: 0; white-space: nowrap; font-size: 0.875rem; font-weight: 500; }
.rx-cue .rx-disc { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 1px solid rgb(255 255 255 / 0.55); border-radius: 50%; }
.rx-cue:hover .rx-disc, .rx-cue:focus-visible .rx-disc { background: rgb(255 255 255 / 0.14); }
.rx-cue[data-ready] .rx-disc { border-color: #fff; box-shadow: 0 0 0 0 rgb(255 255 255 / 0.3); animation: rx-pulse 1.9s ease-out 2; }
@keyframes rx-pulse { to { box-shadow: 0 0 0 0.5rem rgb(255 255 255 / 0); } }
#home-hero[data-away] .rx-tools { visibility: hidden; }
.rx-note { margin: 0; }

/* ---------- Footer bar: a band in the logo teal, with the caption laid over the film above it ---------- */
.rx-dock {
  position: absolute; inset: auto 0 0;
  transform: translateY(var(--rx-dock)); opacity: calc(1 - var(--rx-ui, 1));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: clamp(0.75rem, 2vw, 1.5rem);
  padding: 0.75rem var(--rx-edge) max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--ui-border);
}
.rx-place {
  --ui-text-highlighted: #fff;
  position: absolute; bottom: 100%; inset-inline: var(--rx-edge);
  display: grid; gap: 0.6rem; max-width: 34rem;
  padding-bottom: clamp(1.25rem, 3vw, 2rem);
  color: #fff;
}
/* A shade only behind the caption: from the teal band up to a little above the stop's name,
   across the screen, so the rest of the film stays clear. */
.rx-place::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  top: -4.5rem; bottom: 0; inset-inline-start: calc(-1 * var(--rx-edge)); inset-inline-end: -100vw;
  background: linear-gradient(to top, rgb(15 39 46 / 0.74), rgb(15 39 46 / 0.42) 50%, transparent);
}
.rx-place .display { margin: 0; color: #fff; }
.rx-place :is(.display, .rx-note, .rx-index-open) { text-shadow: 0 0.05em 0.5em rgb(15 39 46 / 0.6), 0 0 0.15em rgb(15 39 46 / 0.35); }
.rx-index-open {
  appearance: none; display: inline-flex; align-items: center; gap: 0.6em; justify-self: start;
  min-height: 1.75rem; max-width: 100%; padding: 0; border: 0; background: transparent;
  color: var(--color-lagoon-300); text-align: start; cursor: pointer;
}
.rx-index-open small { font: inherit; font-size: 0.875rem; font-weight: 500; }
.rx-index-open i { width: 6px; height: 6px; margin-block-end: 3px; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg); }
.rx-note { font-size: clamp(1rem, 1.2vw, 1.1875rem); line-height: 1.7; color: rgb(255 255 255 / 0.86); }
html[lang="en"] .rx-note { line-height: 1.6; }

.rx-track { position: relative; height: 4px; border-radius: 2px; background: color-mix(in oklab, var(--color-lagoon-950) 22%, transparent); }
.rx-track::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--rx-progress, 0%); border-radius: inherit; background: var(--color-lagoon-950); }
.rx-track::after { content: ''; position: absolute; inset-inline-start: var(--rx-progress, 0%); top: 50%; width: 0.875rem; height: 0.875rem; margin-inline-start: -0.4375rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--color-lagoon-950); transform: translateY(-50%); }

.rx-nav { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; color: var(--color-lagoon-950); }
/* Pills and rounds as the v1 tour's skip button, drawn for the teal band. */
.rx-skip, .rx-watch {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; flex: none;
  min-height: 2.75rem; padding-inline: 1.125rem; white-space: nowrap;
  border: 1px solid var(--ui-border-accented) !important; border-radius: 999px;
  font-size: 0.875rem !important; font-weight: 500;
  transition: background 0.3s ease, color 0.3s ease;
}
.rx-watch[hidden] { display: none !important; }
.rx-watch svg { width: 0.875rem; height: 0.875rem; }
.rx-step { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--ui-border-accented) !important; border-radius: 50%; transition: background 0.3s ease, color 0.3s ease; }
.rx-skip:hover, .rx-watch:hover, .rx-step:hover:not(:disabled) { background: var(--color-lagoon-950); color: #fff; }
.rx-step:disabled { opacity: .32; cursor: default; }
.rx-nav .rx-step svg { width: 1rem; height: 1rem; }
html[dir=rtl] .rx-nav .rx-step svg { transform: scaleX(-1); }

/* Narrow screens: the progress takes its own line, skip at the start and the arrows at the end. */
@media (max-width: 40rem) {
  .rx-dock { grid-template-columns: minmax(0, 1fr); row-gap: 0.625rem; padding-top: 0.875rem; }
  .rx-nav { gap: 0.4rem; }
  .rx-skip { margin-inline-end: auto; }
  .rx-skip, .rx-watch { padding-inline: 0.875rem; font-size: 0.8125rem !important; }
}
/* Phones on their side: a short caption. */
@media (max-height: 32rem) and (orientation: landscape) {
  .rx-place .display { font-size: 1.5rem; }
  .rx-note { display: none; }
}

/* The stops row is for phones held upright only (see below). */
.rx-strip { display: none; }

/* ---------- Walk ---------- */
.rx-walk { position: absolute; inset: 0; pointer-events: none; visibility: hidden; overflow: hidden; }
.rx-walk[data-open] { visibility: visible; }
.rx-walk-clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; }
.rx-walk-clip[data-visible] { opacity: 1; }

/* Picture quality, top corner during the walk. */
.rx-quality {
  display: none; position: absolute; z-index: 6;
  inset-inline-end: var(--rx-edge); top: calc(var(--ui-header-height, 4.5rem) + 0.75rem);
  padding: 0.35rem 0.6rem; border: 1px solid rgb(15 39 46 / 0.38);
  background: var(--color-logo); color: var(--color-lagoon-950);
  border-start-start-radius: var(--radius-petal-sm); border-end-end-radius: var(--radius-petal-sm);
  font: inherit; font-size: 0.8125rem; font-weight: 500; line-height: 1.3; cursor: pointer;
}
#home-hero:is([data-phase="tour"],[data-phase="villa"]) .rx-quality { display: block; }
.rx-quality option { background: var(--color-logo); color: var(--color-lagoon-950); }

/* ---------- Stops menu: a teal band ---------- */
.rx-index {
  width: min(42rem, calc(100vw - 2rem)); max-height: min(80svh, 44rem); margin: auto;
  padding: clamp(1rem, 3vw, 1.75rem); overflow: auto; overscroll-behavior: contain;
  border: 0; border-start-start-radius: var(--radius-petal-sm); border-end-end-radius: var(--radius-petal-sm);
  box-shadow: 0 1.5rem 5rem rgb(15 39 46 / 0.42); font-family: var(--font-sans);
}
.rx-index::backdrop { background: rgb(15 39 46 / 0.68); }
.rx-index-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-block-end: 1rem; }
.rx-index h2 { margin: 0; }
.rx-index-close {
  appearance: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border: 1px solid var(--ui-border-accented); border-radius: 50%; background: transparent; color: inherit;
  font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.rx-index-close:hover { background: var(--color-lagoon-950); color: #fff; }
.rx-index-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.625rem; }
.rx-index-grid button {
  display: grid; align-content: start; appearance: none; margin: 0; padding: 0; overflow: hidden;
  border: 1px solid var(--ui-border); background: var(--band-panel); color: inherit;
  text-align: start; font: inherit; cursor: pointer;
}
.rx-index-grid button img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.rx-index-grid button span { padding: 0.5rem 0.625rem; font-size: 0.875rem; font-weight: 500; line-height: 1.4; }
.rx-index-grid button:hover, .rx-index-grid button[aria-current] { border-color: var(--color-lagoon-950); background: var(--band-panel-strong); }
.rx-index-grid button[data-stop=map] { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.5rem; }
.rx-index-grid button[data-stop=map] img { width: clamp(5.5rem, 18%, 7.5rem); aspect-ratio: 2.3; }
.rx-index-open:focus-visible, .rx-index button:focus-visible { outline: 2px solid var(--color-lagoon-950); outline-offset: 3px; }
.rx-index-open:focus-visible { outline-color: #fff; }
@media (max-width: 34rem) {
  .rx-index-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .rx-index-grid button span { font-size: 0.8125rem; }
}

/* ---------- Phones held upright (as Demo 3) ---------- */
/* The whole film, full width, in a 16:9 strip under the header (the engine also measures
   --rx-picture-top and --rx-picture-height), closing on a petal corner. The screen below it is
   never left empty: the hero's heading, lede and finder fill it on the lagoon, and as the camera
   heads in, the walk's teal band takes their place with the stop's title and note, the progress
   and the controls. */
@media (max-aspect-ratio: 4/5) {
  #home-hero[data-rooftop] {
    --rx-picture-top: var(--ui-header-height);
    --rx-picture-height: 56.25vw;
    --rx-below: calc(var(--rx-picture-top) + var(--rx-picture-height));
  }
  #home-hero:not([data-rooftop]) .hero__frame {
    background: var(--color-lagoon-950) url('/rooftop-media/hero-r38-opening.webp') center var(--ui-header-height) / 100% auto no-repeat;
  }
  .rx-film { inset: var(--rx-picture-top) 0 auto; height: var(--rx-picture-height); border-end-end-radius: var(--radius-petal); }
  .rx-screen::after { display: none; }
  #home-hero[data-rooftop] .hero__shade { display: none; }
  #home-hero[data-rooftop] .hero__content {
    position: absolute; inset: var(--rx-below) 0 0; height: auto;
    justify-content: space-between; padding-top: clamp(1.25rem, 5vw, 2rem);
  }
  #home-hero[data-rooftop] .hero__title {
    /* Two lines that always fit what is left under the film, with the lede and finder. */
    font-size: clamp(2.5rem, (100svh - var(--rx-below) - 21rem) / var(--hero-lines), 3.4rem);
    text-shadow: none;
  }
  #home-hero[data-rooftop] .hero__content { gap: 1rem; padding-bottom: calc(var(--rx-safe) + 3.5rem); }
  #home-hero[data-rooftop] .hero__foot { gap: 1rem; }
  /* City and community side by side, Explore across the foot: a shorter finder. */
  #home-hero[data-rooftop] .finder { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
  #home-hero[data-rooftop] .finder > button { grid-column: 1 / -1; margin-block-start: 0.35rem; }
  #home-hero[data-rooftop] .finder__field + .finder__field { padding-inline-start: 1rem; border-inline-start: 1px solid var(--ui-border); }
  #home-hero[data-rooftop] .finder__field > button { min-width: 0; } /* long community names truncate */

  .rx-dock {
    inset: var(--rx-below) 0 0;
    display: flex; flex-direction: column; align-items: stretch; gap: 0.875rem;
    padding: clamp(1.25rem, 5vw, 2rem) var(--rx-edge) max(1.25rem, env(safe-area-inset-bottom));
    border-top: 0;
    transform: translateY(var(--rx-dock-mobile, 25px)); opacity: var(--rx-dock-alpha, 0);
    isolation: isolate;
  }
  /* The room between the caption and the controls carries the brand rosette lattice, rising
     faintly from the controls, so the band reads as one designed panel rather than a gap. */
  .rx-dock::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-color: var(--color-lagoon-950); opacity: 0.09;
    -webkit-mask: url('/images/brand-rosette-pattern.svg') 0 0 / 8rem 8rem, linear-gradient(transparent 25%, #000 75%);
    -webkit-mask-composite: source-in;
    mask: url('/images/brand-rosette-pattern.svg') 0 0 / 8rem 8rem, linear-gradient(transparent 25%, #000 75%);
    mask-composite: intersect;
  }
  /* The walk's stops as a row of thumbnails above the progress (rooftop.js builds it): swipe
     along it, tap one to go there; the current stop is lit and kept in the middle. */
  .rx-strip {
    display: flex; gap: 0.5rem; pointer-events: auto;
    margin-inline: calc(var(--rx-edge) * -1); padding-inline: var(--rx-edge);
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    scroll-snap-type: x proximity; scroll-padding-inline: var(--rx-edge);
  }
  .rx-strip::-webkit-scrollbar { display: none; }
  .rx-strip button {
    flex: none; width: clamp(6.5rem, 34vw, 9rem); padding: 0; border: 0; background: none;
    overflow: hidden; scroll-snap-align: center; cursor: pointer;
    border-start-start-radius: var(--radius-petal-sm); border-end-end-radius: var(--radius-petal-sm);
    outline: 2px solid transparent; outline-offset: -2px; opacity: 0.6;
    transition: opacity 0.25s ease, outline-color 0.25s ease;
  }
  .rx-strip button[aria-current] { opacity: 1; outline-color: var(--color-lagoon-950); }
  .rx-strip img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
  .rx-place .display { font-size: clamp(1.85rem, 8.5vw, 2.6rem); }
  .rx-note { font-size: 1.0625rem; }
  .rx-place {
    --ui-text-highlighted: inherit;
    position: static; max-width: none; margin-block-end: auto; padding-bottom: 0; color: inherit;
  }
  .rx-place .display { color: var(--ui-text-highlighted); }
  .rx-place::before { display: none; }
  .rx-place :is(.display, .rx-note, .rx-index-open) { text-shadow: none; }
  .rx-index-open { color: var(--ui-text-highlighted); }
  .rx-note { color: var(--ui-text-toned); }
}

@media (prefers-reduced-motion: reduce) {
  #home-hero[data-rooftop] *, #home-hero[data-rooftop] *::before { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
