/* ==========================================================================
   Sohbah Retreats — motion layer
   One easing curve, transform/opacity only, every effect plays once.
   Everything here is gated behind html.mx, which is only set when the visitor
   has not asked for reduced motion. Without JS, all content stays visible.
   ========================================================================== */

:root {
  --mx-ease: cubic-bezier(.22, 1, .36, 1);
  --mx-ease-soft: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Reading progress: a sandstone thread along the top ---------- */
.mx-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1000;
  background: var(--r-accent, #9c4a31);
  transform: scaleX(0); transform-origin: 0 50%;
  pointer-events: none;
  will-change: transform;
}
@supports (animation-timeline: scroll()) {
  .mx-progress { animation: mx-progress linear both; animation-timeline: scroll(root); }
  @keyframes mx-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}
@media (prefers-reduced-motion: reduce) { .mx-progress { display: none; } }

/* ---------- Opening choreography (homepage hero) ---------- */
@keyframes mx-rise { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }
@keyframes mx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mx-title {
  from { opacity: 0; transform: translate3d(0, 36px, 0); filter: blur(14px); }
  60%  { filter: blur(0); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes mx-film { from { opacity: 0; transform: scale(1.12); } to { opacity: 1; transform: none; } }
@keyframes mx-star { from { transform: rotate(-180deg) scale(0); } to { transform: none; } }

.mx body.sohba-editorial .hero .hero-visual { animation: mx-film 2400ms var(--mx-ease-soft) both; transform-origin: 60% 50%; }
.mx body.sohba-editorial .header { animation: mx-fade 900ms var(--mx-ease) 700ms both; }
.mx body.sohba-editorial .hero .eyebrow { animation: mx-rise 900ms var(--mx-ease) 450ms both; }
.mx body.sohba-editorial .hero .eyebrow::before { animation: mx-star 1200ms var(--mx-ease) 500ms both; }
/* Headline: every letter rises from behind its own mask, tilting upright as it lands,
   then a fine sand line draws itself beneath "sohbah". Split by motion-plus.js. */
.mx body.sohba-editorial .hero h1:not(.mx-split) { animation: mx-fade 700ms var(--mx-ease) 2200ms both; } /* fallback if the script never runs */
.mx body.sohba-editorial .hero h1.mx-split { animation: none; }
.mx .hero h1 .mx-hw {
  display: inline-block;
  position: relative;
  overflow: hidden;
  vertical-align: top;
  padding: .12em .04em .2em;
  margin: -.12em -.04em -.2em;
}
.mx .hero h1 .mx-hc {
  display: inline-block;
  transform-origin: 0% 100%;
  animation: mx-char 1400ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(450ms + var(--c, 0) * 34ms);
  will-change: transform;
}
@keyframes mx-char {
  0%   { transform: translate3d(0, 118%, 0) rotate(9deg); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: none; opacity: 1; }
}
/* The sand line draws itself beneath the "sohbah" wordmark once it has landed */
.mx .hero h1 .mx-hc-img::before {
  content: '';
  position: absolute;
  left: .02em; right: .02em; top: calc(100% + .09em);
  height: max(1.5px, .03em);
  background: #e9c9a0;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: 0 50%;
  animation: mx-underline 1100ms cubic-bezier(.65, 0, .35, 1) 1500ms both;
}
@keyframes mx-underline { to { transform: scaleX(1); } }

/* The wordmark rises as one piece, then gold light passes across it once */
.mx .hero h1 .mx-hc-img { position: relative; }
.mx .hero h1 .mx-hc-img .hero-wordmark { display: block; }
.mx .hero h1 .mx-hc-img::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 0%, transparent 38%,
    rgba(214, 160, 80, 0) 40%,
    rgba(214, 160, 80, 1) 47%,
    rgba(240, 200, 130, 1) 50%,
    rgba(214, 160, 80, 1) 53%,
    rgba(214, 160, 80, 0) 60%,
    transparent 62%, transparent 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-mask: url('/assets/sohbah-wordmark-word.png') center / 100% 100% no-repeat;
          mask: url('/assets/sohbah-wordmark-word.png') center / 100% 100% no-repeat;
  animation: mx-word-sheen 1100ms cubic-bezier(.45, 0, .2, 1) 1650ms both;
}
@keyframes mx-word-sheen {
  0%   { background-position: 100% 0; opacity: 1; }
  85%  { opacity: 1; }
  100% { background-position: 0% 0; opacity: 0; }
}
.mx body.sohba-editorial .hero .hero-sub { animation: mx-rise 1000ms var(--mx-ease) 1250ms both; }
.mx body.sohba-editorial .hero .hero-actions { animation: mx-rise 1000ms var(--mx-ease) 1400ms both; }
.mx body.sohba-editorial .hero .hero-cycle-toggle { animation: mx-fade 900ms var(--mx-ease) 1500ms both; }

/* As you scroll on, the hero recedes: the headline lifts away, the film deepens */
@supports (animation-timeline: scroll()) {
  .mx body.sohba-editorial .hero .hero-heading {
    animation: mx-hero-out linear both;
    animation-timeline: scroll(root);
    animation-range: 0 85vh;
  }
  .mx body.sohba-editorial .hero .hero-video {
    animation: mx-hero-deepen linear both;
    animation-timeline: scroll(root);
    animation-range: 0 100vh;
  }
  @keyframes mx-hero-out { to { opacity: 0; transform: translate3d(0, -10vh, 0); } }
  @keyframes mx-hero-deepen { to { transform: scale(1.1); } }
}

/* ---------- Scroll reveals (armed by motion-plus.js) ---------- */

/* Headings rise word by word from behind a mask */
.mx .mx-w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: .12em; margin-bottom: -.12em;   /* keeps descenders (g, j, y) unclipped */
}
.mx .mx-wi { display: inline-block; will-change: transform; }
.mx [data-mx="words"].mx-armed:not(.mx-in) .mx-wi { transform: translate3d(0, 110%, 0); }
.mx [data-mx="words"].mx-in .mx-wi {
  transition: transform 1000ms var(--mx-ease) calc(min(var(--i, 0), 14) * 55ms);
}

/* Section labels: text settles, the tile star turns into place */
.mx [data-mx="label"].mx-armed:not(.mx-in) { opacity: 0; transform: translate3d(0, 8px, 0); }
.mx [data-mx="label"].mx-armed:not(.mx-in)::before { transform: rotate(-180deg) scale(0); }
.mx [data-mx="label"].mx-in { transition: opacity 700ms var(--mx-ease), transform 700ms var(--mx-ease); }
.mx [data-mx="label"].mx-in::before { transition: transform 1100ms var(--mx-ease) 120ms; }

/* Photographs open upwards from a mask while settling from a slight zoom */
.mx [data-mx="img"].mx-armed:not(.mx-in) { clip-path: inset(100% 0 0 0 round 16px); }
.mx [data-mx="img"].mx-armed:not(.mx-in) img,
.mx img[data-mx="img"].mx-armed:not(.mx-in) { transform: scale(1.14); }
.mx [data-mx="img"].mx-in {
  clip-path: inset(0 0 0 0 round 16px);
  transition: clip-path 1300ms var(--mx-ease-soft) var(--mx-delay, 0ms), transform 1600ms var(--mx-ease-soft) var(--mx-delay, 0ms);
}
.mx [data-mx="img"].mx-in img { transition: transform 1600ms var(--mx-ease-soft) var(--mx-delay, 0ms); }

/* Generic soft rise for blocks the page script doesn't already reveal */
.mx [data-mx="rise"].mx-armed:not(.mx-in) { opacity: 0; transform: translate3d(0, 24px, 0); }
.mx [data-mx="rise"].mx-in { transition: opacity 900ms var(--mx-ease) var(--mx-delay, 0ms), transform 900ms var(--mx-ease) var(--mx-delay, 0ms); }

/* FAQ rows arrive as a gentle cascade */
.mx [data-mx="list"].mx-armed:not(.mx-in) > * { opacity: 0; transform: translate3d(0, 14px, 0); }
.mx [data-mx="list"].mx-in > * {
  transition: opacity 700ms var(--mx-ease), transform 700ms var(--mx-ease);
  transition-delay: calc(min(var(--i, 0), 10) * 50ms);
}

/* ---------- Destination switcher: crossfade instead of a hard swap ---------- */
.mx .atlas-scene #atlas-image,
.mx .atlas-scene #atlas-name,
.mx .atlas-scene #atlas-teaser {
  transition: opacity 600ms var(--mx-ease), transform 900ms var(--mx-ease);
}
.mx .atlas-scene.mx-swap #atlas-image { opacity: 0; transform: scale(1.04); transition: none; }
.mx .atlas-scene.mx-swap #atlas-name,
.mx .atlas-scene.mx-swap #atlas-teaser { opacity: 0; transform: translate3d(0, 10px, 0); transition: none; }
.mx .atlas-scene #atlas-teaser { transition-delay: 80ms; }

/* ---------- Accordions open smoothly where the browser supports it ---------- */
@supports (interpolate-size: allow-keywords) {
  .mx main details { interpolate-size: allow-keywords; }
  .mx main details::details-content {
    height: 0; overflow: clip; opacity: 0;
    transition: height 420ms var(--mx-ease), opacity 320ms var(--mx-ease), content-visibility 420ms allow-discrete;
  }
  .mx main details[open]::details-content { height: auto; opacity: 1; }
}

/* ---------- Gentle crossfade between pages (supporting browsers) ---------- */
@view-transition { navigation: auto; }
html body .header .logo { view-transition-name: sohbah-logo; }
::view-transition-old(root) { animation: 260ms var(--mx-ease) both mx-vt-out; }
::view-transition-new(root) { animation: 520ms var(--mx-ease) 80ms both mx-vt-in; }
@keyframes mx-vt-out { to { opacity: 0; } }
@keyframes mx-vt-in { from { opacity: 0; transform: translate3d(0, 12px, 0); } }

/* ---------- Respect reduced motion completely ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  html.mx *, html.mx *::before, html.mx *::after { animation: none !important; }
}
