/* =====================================================================
   MATTTCHES — Immersion layer
   Adds: atmosphere colour worlds, bento "How It Works", pinned app
   showcase, interactive match demo, global card tilt.
   Loaded after the base styles in index.html.
   ===================================================================== */

/* ============================ 0. HERO FIT ============================
   Safe viewport units account for mobile browser chrome. The cinematic
   pinned scene is retained only when the viewport has enough space;
   constrained and landscape screens use a naturally sized, scrollable
   hero so no content or control can ever be clipped. */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  padding-top: max(8rem, env(safe-area-inset-top));
  padding-bottom: max(8.5rem, calc(env(safe-area-inset-bottom) + 7rem));
}
.js .hero-pin .hero {
  height: 100vh;
  height: 100svh;
}
.hero-btns {
  position: relative;
  z-index: 3;
  max-width: 100%;
}
.hero-btns a {
  pointer-events: auto;
  touch-action: manipulation;
}

/* Laptop-height screens can keep the cinematic treatment with tighter scale. */
@media (min-height: 821px) and (min-width: 641px) {
  .js .hero-pin .hero { padding-top: 7rem; }
}

/*
   Fail-safe layout: phones, landscape devices, split-screen windows and
   short laptop browser areas. Disable pinning and reveal the complete
   hero immediately; its natural height can extend below the viewport and
   remains normally scrollable instead of being hidden inside 100vh.
*/
@media (max-height: 820px), (max-width: 640px) {
  .js .hero-pin {
    height: auto !important;
    min-height: 0;
  }
  .js .hero-pin .hero {
    position: relative !important;
    top: auto;
    height: auto !important;
    min-height: 100vh;
    min-height: 100svh;
    overflow: visible;
    justify-content: flex-start;
    padding: max(6rem, calc(env(safe-area-inset-top) + 5rem)) 1.25rem
             max(3rem, calc(env(safe-area-inset-bottom) + 2rem));
  }
  .hero-inner {
    width: min(100%, 880px);
    margin: auto;
    transform: none !important;
    opacity: 1 !important;
  }
  .hero-kicker {
    margin-bottom: 1.25rem;
    font-size: clamp(0.52rem, 1.5vw, 0.62rem);
  }
  .hero-h1 {
    font-size: clamp(2rem, min(8vw, 8vh), 4rem);
    line-height: 1.02;
  }
  .js .hero-pin .hero-h1 .hw {
    opacity: 1 !important;
    text-shadow: var(--glow-lg) !important;
  }
  .js .hero-pin .hero-sub,
  .js .hero-pin .hero-btns {
    opacity: 1 !important;
    transform: none !important;
  }
  .hero-sub {
    margin: 1.25rem auto 1.75rem;
    font-size: clamp(0.9rem, 2.5vw, 1.02rem);
    line-height: 1.65;
  }
  .scroll-cue { display: none !important; }
}

/* Narrow phones: controls become large, full-width touch targets. */
@media (max-width: 440px) {
  .js .hero-pin .hero {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .hero-kicker { gap: 0.55rem; letter-spacing: 0.18em; }
  .hero-kicker span { width: 1rem; }
  .hero-h1 { font-size: clamp(1.85rem, 9.2vw, 2.8rem); }
  .hero-btns {
    width: 100%;
    flex-direction: column;
    gap: 1rem;
  }
  .hero-btns .btn-solid {
    width: 100%;
    min-height: 48px;
    padding: 0.9rem 1rem;
    font-size: 0.68rem;
    white-space: normal;
  }
  .hero-btns .btn-ghost {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
  }
}

/* ============================ 1. ATMOSPHERE ============================
   A fixed stack of gradient "worlds". experience.js cross-fades their
   opacity against scroll position so the page breathes from a cold,
   isolated dark into a warm blaze and back. */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.atmo-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.1s ease;
  will-change: opacity;
}
/* cold + constricted — the problem */
.atmo-cold {
  background:
    radial-gradient(ellipse 70% 55% at 50% 30%, rgba(38, 58, 96, 0.20) 0%, transparent 70%),
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(12, 16, 30, 0.55) 0%, transparent 72%);
}
/* first warmth — how it works */
.atmo-warm {
  background:
    radial-gradient(ellipse 65% 50% at 30% 40%, rgba(232, 98, 42, 0.10) 0%, transparent 68%),
    radial-gradient(ellipse 60% 45% at 78% 65%, rgba(196, 110, 60, 0.08) 0%, transparent 70%);
}
/* the blaze — the moment / app */
.atmo-blaze {
  background:
    radial-gradient(ellipse 60% 45% at 50% 45%, rgba(232, 98, 42, 0.20) 0%, transparent 66%),
    radial-gradient(ellipse 85% 60% at 50% 92%, rgba(255, 148, 74, 0.10) 0%, transparent 70%);
}
/* calm + trustworthy — privacy */
.atmo-calm {
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(46, 84, 78, 0.16) 0%, transparent 70%),
    radial-gradient(ellipse 90% 55% at 50% 100%, rgba(14, 22, 26, 0.45) 0%, transparent 74%);
}
/* full warmth — founder + finale */
.atmo-ember {
  background:
    radial-gradient(ellipse 70% 55% at 50% 55%, rgba(232, 98, 42, 0.16) 0%, transparent 70%),
    radial-gradient(ellipse 100% 60% at 50% 0%, rgba(138, 56, 16, 0.16) 0%, transparent 68%);
}
/* every real section paints above the atmosphere.
   NOTE: headers are position:fixed controls — they must NOT
   be reset to relative (that dropped the nav to z-index 1 and let the
   sticky hero slide over it and swallow all nav clicks). */
body > .hero-pin,
body > section,
body > .divider,
body > footer { position: relative; z-index: 1; }
/* Fixed controls stay fixed and clickable above page content. The ember
   canvas above them is pointer-events:none so clicks pass straight
   through while the sparkle still draws on top. */
body > .site-header { position: fixed; z-index: 600; }

/* Rasterize the large finale text/glow once while the section moves. */
.finale.motion-active .finale-inner { will-change: transform; }
.finale.motion-active .finale-glow { will-change: opacity; }
.finale .btn-solid { transition: transform .2s ease; }
.finale .btn-solid:hover { box-shadow: var(--glow-md); }

/* ============================ 2. BENTO "HOW IT WORKS" ============================
   Replaces the pinned crossfade scene with an asymmetric grid: stage 01
   is the hero tile, 02 and 03 stack beside it. */
@media (min-width: 960px) {
  .stages-bento .stages {
    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    grid-template-rows: auto auto;
    gap: 1.1rem;
    align-items: stretch;
  }
  .stages-bento .stage:nth-child(1) { grid-row: 1 / span 2; }
}
.stages-bento .stage {
  display: block;
  border: 1px solid var(--w12);
  border-top: 1px solid var(--w12);
  border-radius: 22px;
  padding: 2.25rem 2.1rem;
  background:
    linear-gradient(165deg, rgba(240, 237, 232, 0.035), rgba(240, 237, 232, 0.012));
  position: relative;
  overflow: hidden;
  transition: border-color 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
}
.stages-bento .stage:last-child { border-bottom: 1px solid var(--w12); }
.stages-bento .stage::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 22px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(232, 98, 42, 0.09), transparent 72%);
}
.stages-bento .stage:hover::after { opacity: 1; }
.stages-bento .stage:hover {
  border-color: rgba(232, 98, 42, 0.30);
  box-shadow: 0 0 50px rgba(232, 98, 42, 0.07), 0 24px 60px rgba(0, 0, 0, 0.32);
}
/* the stage number becomes a lit chip in the tile corner */
.stages-bento .stage-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin-bottom: 1.4rem;
  border: 1px solid var(--w12);
  border-radius: 50%;
  background: rgba(12, 13, 17, 0.6);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  transition: color 0.45s ease, border-color 0.45s ease, box-shadow 0.45s ease;
}
.stages-bento .stage.in .stage-n {
  color: var(--orange);
  border-color: rgba(232, 98, 42, 0.45);
  box-shadow: 0 0 22px rgba(232, 98, 42, 0.28);
}
/* stage 01 gets the larger typographic treatment */
@media (min-width: 960px) {
  .stages-bento .stage:nth-child(1) .stage-title { font-size: clamp(2.2rem, 3.4vw, 3.4rem); }
  .stages-bento .stage:nth-child(1) { padding: 2.75rem 2.5rem; }
}
/* tiles rise in on reveal */
.js .stages-bento .stage {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.85s ease var(--sd, 0s), transform 0.85s ease var(--sd, 0s),
              border-color 0.4s ease, box-shadow 0.4s ease;
}
.js .stages-bento .stage.in { opacity: 1; transform: translateY(0); }

/* ============================ 3. PINNED APP SHOWCASE ============================ */
.app-pin { position: relative; }
.app-scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-grid {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 0 4rem;
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 4rem;
  align-items: center;
}
.app-copy .section-h2 { margin-bottom: 1.5rem; }
.app-steps { margin-top: 2.25rem; display: flex; flex-direction: column; gap: 0.15rem; }
.app-step {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--w06);
  opacity: 0.32;
  transition: opacity 0.5s ease;
}
.app-step:last-child { border-bottom: 1px solid var(--w06); }
.app-step.active { opacity: 1; }
.app-step-n {
  font-family: var(--syne); font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.18em; color: var(--w35);
  transition: color 0.5s ease, text-shadow 0.5s ease;
}
.app-step.active .app-step-n { color: var(--orange); text-shadow: 0 0 16px rgba(232, 98, 42, 0.5); }
.app-step-t {
  font-family: var(--syne); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--w90);
  margin-bottom: 0.3rem;
}
.app-step-d { font-size: 0.86rem; font-weight: 300; color: var(--w60); line-height: 1.65; }

/* the device */
.app-phone {
  position: relative;
  width: min(390px, 100%);
  aspect-ratio: 600 / 941;
  margin: 0 auto;
  filter: drop-shadow(0 0 35px rgba(232, 98, 42, 0.10)) drop-shadow(0 30px 45px rgba(0, 0, 0, 0.55));
  will-change: transform;
  transition: filter 0.5s ease;
}
.app-screen.app-phone-image {
  padding: 0;
  display: block;
  width: 100%; height: 100%;
  object-fit: contain;
  visibility: hidden;
}
.app-phone-image.on { visibility: visible; }
.app-generated-shell {
  position: absolute;
  top: 0; left: 50%;
  width: 76.923%; height: 99.67%;
  transform: translateX(-50%);
  border-radius: 44px;
  padding: 12px;
  background: linear-gradient(165deg, #23262f, #101219);
  border: 1px solid rgba(240, 237, 232, 0.14);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.08);
  opacity: 1;
  transition: opacity 0.45s ease;
}
.app-phone.photo-stage .app-generated-shell { opacity: 0; visibility: hidden; }
.app-generated-shell::before {
  content: '';
  position: absolute;
  top: 26px; left: 50%;
  width: 82px; height: 5px;
  margin-left: -41px;
  border-radius: 100px;
  background: rgba(240, 237, 232, 0.16);
  z-index: 3;
}
.app-viewport {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 34px;
  overflow: hidden;
  background: #0a0b0f;
}
.app-screen {
  position: absolute;
  inset: 0;
  padding: 3.4rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.55s ease, transform 0.55s ease;
  pointer-events: none;
}
.app-screen.on { opacity: 1; transform: none; }
.app-screen-lbl {
  font-family: var(--syne); font-size: 0.54rem; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--w35);
  margin-bottom: 1rem;
}
.app-screen-h {
  font-family: var(--serif); font-size: 1.5rem; line-height: 1.15;
  color: var(--white); margin-bottom: 0.9rem;
}
.app-screen-p { font-size: 0.8rem; font-weight: 300; color: var(--w60); line-height: 1.7; }
.app-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.2rem; }
.app-chip {
  font-family: var(--syne); font-size: 0.56rem; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--w60); border: 1px solid var(--w12);
  padding: 0.34rem 0.7rem; border-radius: 100px;
}
.app-chip.lit-chip {
  color: var(--white);
  border-color: rgba(232, 98, 42, 0.5);
  box-shadow: 0 0 18px rgba(232, 98, 42, 0.18);
}
.app-prompt {
  margin-top: auto;
  background: rgba(240, 237, 232, 0.045);
  border: 1px solid var(--w12);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}
.app-prompt-q {
  font-family: var(--serif); font-style: italic; font-size: 0.9rem;
  color: var(--white); line-height: 1.5;
}
/* match reveal screen */
.app-match { margin-top: 1.4rem; display: flex; align-items: center; gap: 0.7rem; }
.app-ava {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-style: italic; font-size: 1rem;
  color: var(--white);
  background: rgba(240, 237, 232, 0.09);
  border: 1px solid rgba(232, 98, 42, 0.35);
  box-shadow: 0 0 20px rgba(232, 98, 42, 0.22);
}
.app-thread {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 98, 42, 0.9), transparent);
  box-shadow: 0 0 10px rgba(232, 98, 42, 0.45);
}
/* courage tap screen */
.app-tap-ring {
  margin: auto auto 1.2rem;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 1px solid rgba(232, 98, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--syne); font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--white);
  text-align: center;
  box-shadow: 0 0 40px rgba(232, 98, 42, 0.22), inset 0 0 30px rgba(232, 98, 42, 0.12);
  animation: tapRing 2.8s ease-in-out infinite;
}
@keyframes tapRing {
  0%, 100% { box-shadow: 0 0 34px rgba(232, 98, 42, 0.18), inset 0 0 24px rgba(232, 98, 42, 0.10); }
  50%      { box-shadow: 0 0 60px rgba(232, 98, 42, 0.34), inset 0 0 34px rgba(232, 98, 42, 0.18); }
}
/* progress rail under the device */
.app-rail {
  display: flex; gap: 0.35rem; justify-content: center;
  margin-top: 1.5rem;
}
.app-rail-seg {
  width: 34px; height: 2px; border-radius: 100px;
  background: var(--w12);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}
.app-rail-seg.on {
  background: var(--orange);
  box-shadow: 0 0 12px rgba(232, 98, 42, 0.6);
}

@media (min-width: 960px) {
  .js .app-pin { height: 340vh; }
  .js .app-pin .app-scene { position: sticky; top: 0; height: 100vh; }
}
@media (max-width: 959px) {
  .app-grid { grid-template-columns: 1fr; gap: 2.75rem; padding: 0 1.75rem; }
  .app-phone { width: min(350px, 100%); }
  .app-scene { min-height: 0; padding: 5rem 0; }
}

/* ============================ 6. GLOBAL CARD TILT ============================ */
.tilt-card { transform-style: preserve-3d; }
@media (hover: hover) and (pointer: fine) {
  .tilt-card { transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
}

/* ============================ REDUCED MOTION ============================ */
@media (prefers-reduced-motion: reduce) {
  .atmo-layer { transition: none; }
  .js .stages-bento .stage { opacity: 1 !important; transform: none !important; transition: none !important; }
  .js .app-pin { height: auto !important; }
  .js .app-pin .app-scene { position: relative; height: auto; }
  .app-screen, .app-generated-shell { transition: none !important; }
  .app-phone { aspect-ratio: auto; }
  .app-screen.app-phone-image {
    position: relative; height: auto; margin-bottom: 1.5rem;
    opacity: 1 !important; visibility: visible; transform: none !important;
  }
  .app-tap-ring { animation: none !important; }
  .app-step { opacity: 1; }
  .tilt-card { transition: none !important; transform: none !important; }
}

/* Keep the illustrative walkthrough readable when scripts are unavailable. */
html:not(.js) .app-phone { aspect-ratio: auto; }
html:not(.js) .app-screen.app-phone-image {
  position: relative; height: auto; margin-bottom: 1.5rem;
  opacity: 1; visibility: visible; transform: none;
}
html:not(.js) .app-generated-shell { display: none; }
html:not(.js) .app-step { opacity: 1; }
