/*
 * Palette lifted from the Alarmco app's own theme tokens
 * (apps/mobile/src/theme/tokens.ts), same 60/30/10 split:
 *   60% bg              — neutral canvas
 *   30% brand (violet)   — structure, chrome, primary action
 *   10% pop (peach)      — reserved for what should catch the eye
 */
:root {
  --bg: #f8f8fb;
  --ink: #1d1726;
  --ink-soft: #6b6280;
  --line: #e4e2ea;
  --brand: #7c3aed;
  --brand-soft: #eee5fc;
  /* Exact gradient stops sampled from the app icon (apps/mobile/assets/icon.png) —
     fixed brand asset colors, not theme-adaptive like the tokens above. */
  --brand-light: #a168fc;
  --brand-deep: #5f23d9;
  --pop: #d46535;
  --pop-deep: #b45309;
  --plane: #8b8398;
  --shadow-color: rgba(42, 31, 61, 0.22);
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12101a;
    --ink: #f4f1f8;
    --ink-soft: #a79fb8;
    --line: #332c44;
    --brand: #a78bfa;
    --brand-soft: #2a2140;
    --pop: #ffa985;
    --pop-deep: #ffb27a;
    --plane: #9b93ab;
    --shadow-color: rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vw, 28px) clamp(20px, 5vw, 48px);
}

.nav__logo {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(1rem, 2vw, 1.15rem);
}

.nav__cta {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5em 1.1em;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.nav__cta:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* ---------- scene ---------- */

.scene {
  position: relative;
  height: 360vh;
}

.scene__pin {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Two clocks arranged diagonally so both stay legible on a phone-width
   screen — owner up-left, friend down-right, sized to share the space
   rather than each claiming a full hero-sized slot. */
.duo-stage {
  position: relative;
  width: clamp(280px, 62vw, 620px);
  aspect-ratio: 4 / 3;
}

.clock-slot {
  position: absolute;
  width: clamp(150px, 34vw, 300px);
  aspect-ratio: 1 / 1;
  transition: opacity 0.5s ease;
}

.clock-slot--owner {
  top: 0;
  left: 0;
}

.clock-slot--friend {
  bottom: 0;
  right: 0;
}

.clock-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--brand-light) 22%, transparent) 0%,
    color-mix(in srgb, var(--brand-deep) 12%, transparent) 45%,
    transparent 70%
  );
  pointer-events: none;
}

.clock-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 14px 20px var(--shadow-color));
  transform-origin: 50% 85%;
}

/* Monoline brand style, lifted from the app's own icon (apps/mobile/assets/icon.png):
   uniform thick stroke, round caps/joins, no fills on the clock body itself. */
.clock-svg .face__ring {
  fill: none;
  stroke: var(--ink);
  stroke-width: 8;
}

.clock-svg .face__check {
  fill: none;
  stroke: var(--ink);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clock-svg .bell path {
  fill: var(--ink);
}

.clock-svg .feet line {
  stroke: var(--ink);
  stroke-width: 8;
  stroke-linecap: round;
}

.clock-svg .wave {
  fill: none;
  stroke: var(--pop);
  stroke-width: 3;
  stroke-linecap: round;
}

.clock-svg .spark {
  fill: none;
  stroke: var(--pop);
  stroke-width: 4;
  opacity: 0;
  transform-origin: 100px 68px;
}

.clock-svg .burst {
  transform-origin: 100px 68px;
  opacity: 0;
}

.clock-svg .burst line {
  stroke: var(--pop);
  stroke-width: 3.5;
  stroke-linecap: round;
}

/* Smoldering wisps + ember glow, faded in by JS once a clock has been
   struck — the wisps themselves loop continuously via CSS so they're
   already mid-cycle (staggered, organic) whenever the parent fades in. */
.clock-svg .smoke {
  opacity: 0;
  pointer-events: none;
}

.clock-svg .smoke__wisp {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0;
  transform-origin: 100px 60px;
}

.clock-svg .smoke__wisp--1 {
  animation: smoke-rise-a 3.2s ease-in infinite;
}
.clock-svg .smoke__wisp--2 {
  animation: smoke-rise-b 3.8s ease-in infinite;
  animation-delay: 0.9s;
}
.clock-svg .smoke__wisp--3 {
  animation: smoke-rise-c 2.9s ease-in infinite;
  animation-delay: 1.6s;
}

.clock-svg .ember {
  fill: var(--pop);
  opacity: 0.45;
  filter: blur(2.5px);
  animation: ember-flicker 1.6s ease-in-out infinite;
}

@keyframes smoke-rise-a {
  0% { transform: translate(0, 0) scale(0.85); opacity: 0; }
  20% { opacity: 0.7; }
  100% { transform: translate(-10px, -50px) scale(1.35); opacity: 0; }
}
@keyframes smoke-rise-b {
  0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
  25% { opacity: 0.6; }
  100% { transform: translate(8px, -58px) scale(1.4); opacity: 0; }
}
@keyframes smoke-rise-c {
  0% { transform: translate(0, 0) scale(0.9); opacity: 0; }
  22% { opacity: 0.6; }
  100% { transform: translate(12px, -42px) scale(1.25); opacity: 0; }
}
@keyframes ember-flicker {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.plane-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.plane-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 8px 12px var(--shadow-color));
}

.plane-part {
  fill: var(--plane);
  stroke: var(--ink);
  stroke-width: 6;
  stroke-linejoin: round;
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(28px, 6vh, 56px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.5em;
  transition: opacity 0.3s ease;
}

.scroll-hint__arrow {
  display: inline-block;
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.sound-toggle {
  position: absolute;
  right: clamp(16px, 4vw, 32px);
  bottom: clamp(16px, 4vw, 32px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.sound-toggle svg { fill: currentColor; }
.sound-toggle .sound-toggle__wave {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.35;
}

.sound-toggle[aria-pressed="true"] {
  color: var(--pop);
  border-color: var(--pop);
}
.sound-toggle[aria-pressed="true"] .sound-toggle__wave {
  opacity: 1;
}

/* ---------- shared section rhythm ---------- */

.backup,
.download {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10vh 6vw;
}

.reveal {
  max-width: 34rem;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.backup h2,
.download h2 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.4em;
  font-weight: 700;
}

.backup p,
.download p {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--ink-soft);
  margin: 0;
}

.download p {
  margin-bottom: 2.2em;
}

/* ---------- download badges ---------- */

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
}

.badge {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.65em 1.2em;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.badge:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.badge__icon {
  width: 22px;
  height: 22px;
  fill: var(--bg);
  flex-shrink: 0;
}

.badge__text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
  font-weight: 600;
  font-size: 0.95rem;
}

.badge__text em {
  font-style: normal;
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

/* ---------- footer ---------- */

.footer {
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .duo-stage {
    width: clamp(240px, 82vw, 380px);
  }
  .clock-slot {
    width: clamp(130px, 44vw, 190px);
  }
  .scene {
    height: 320vh;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .scroll-hint__arrow {
    animation: none;
  }
  .reveal {
    transition: opacity 0.3s ease;
    transform: none;
  }
  .smoke__wisp,
  .ember {
    animation: none;
    opacity: 0.4;
  }
}
