/* =========================================================================
   iPhone 17 Pro Max — Deep Blue Portrait
   Source PNG: 1080 × 2204, screen cutout pre-rendered as alpha hole.
   Screen cutout bounds (measured from PNG alpha channel):
     left   = 55  / 1080 =  5.0926%
     top    = 49  / 2204 =  2.2232%
     width  = 970 / 1080 = 89.8148%
     height = 2106/ 2204 = 95.5535%
   Dynamic Island, side buttons and chassis are baked into the PNG.
   No CSS filters, no pseudo-shadows — chassis renders as-is.
   ========================================================================= */

.iphone-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 48px);
  width: 100%;
}

/* ----------------------------------------------------------------------------
   Carousel arrows — round, neutral, sit on the side of the iPhone.
   Disabled state for endpoints. Keyboard + swipe also work (see carousel.js).
   ---------------------------------------------------------------------------- */
.carousel-arrow {
  flex: 0 0 auto;
  width: clamp(40px, 4.4vh, 56px);
  height: clamp(40px, 4.4vh, 56px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease,
              transform 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.carousel-arrow svg {
  width: 50%;
  height: 50%;
  display: block;
}
.carousel-arrow:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.20);
  color: #fff;
}
.carousel-arrow:active {
  transform: scale(0.96);
}
.carousel-arrow[disabled] {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}
.carousel-arrow:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

.iphone {
  position: relative;
  /* PNG is 1080 × 2204 → aspect 1080/2204 ≈ 1:2.041.
     Sized to fill the available stage height: viewport minus
     chrome (page padding 48 + header 88 + stage padding 16
     + footer 38 + safety ≈ 200). Width follows aspect-ratio.
     Cap at 880 to avoid being absurdly tall on huge displays. */
  /* Max 1100px = roughly pixel-perfect with the 2204-tall source PNG at
     Retina DPR 2, so the chassis lands sharp on the user's display. */
  height: clamp(420px, calc(100dvh - 32px), 1500px);
  aspect-ratio: 1080 / 2204;
  flex: 0 0 auto;
  container-type: size;
}

/* Chassis PNG overlays the screen content */
.iphone-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 2;
  /* high-quality lets Chromium use Lanczos for downscaling instead of
     bilinear. No translateZ/backface tricks — those force a composited
     layer and degrade sampling. */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: high-quality;
  /* Recolor the dark titanium chassis to a bright chrome/cool-metal look:
     desaturate + brighten + slight contrast lift; subtle hue shift towards cool. */
  filter: saturate(0) brightness(4.2) contrast(0.85);
}

/* Screen area — sits BEHIND the chassis frame.
   Position derived from PNG alpha-cutout bounds (see header). */
.iphone-screen {
  position: absolute;
  left: 5.0926%;
  top: 2.2232%;
  width: 89.8148%;
  height: 95.5535%;
  background: #000;
  overflow: hidden;
  isolation: isolate;
  z-index: 1;
  /* Slight inner radius — chassis PNG masks the actual corners; this just
     prevents the black bg from showing past the cutout edge. */
  border-radius: 11cqw;
}

/* Status bar inside the screen (sits below the Dynamic Island).
   Heights/spacing in cqh; widths/fonts in cqw so everything scales with
   the screen container. */
.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7cqh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2.5cqh 5cqw 0 6cqw;
  z-index: 5;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  pointer-events: none;
}

.status-time {
  font-size: 3.8cqw;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
  color: #fff;
  line-height: 1;
}

.status-icons svg {
  display: block;
  height: 2.5cqw;
  width: auto;
}

/* App content (Phase 2+) — see app.css for the live definition.
   Phase 4: background made transparent so the atlas canvas (z-index 0)
   shows through. */
.app-frame {
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 2;
}

/* ----------------------------------------------------------------------------
   Screenshot carousel — fills the screen cutout. Crossfade between slides.
   The screenshot includes its own status bar + UI; HTML overlays are off.
   ---------------------------------------------------------------------------- */
.shots {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
  touch-action: pan-y pinch-zoom; /* allow vertical page scroll + h-swipe */
  user-select: none;
  -webkit-user-select: none;
}
.shots > picture {
  display: contents;
}
.shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
  display: block;
  -webkit-user-drag: none;
}
.shot.is-active {
  opacity: 1;
}

/* ----------------------------------------------------------------------------
   Hotspots — tappable transparent overlays positioned over the pills and the
   AI input on slide 1. Hidden on all other slides. Hover reveals a soft green
   ring; a one-time pulse animation runs on first view.
   ---------------------------------------------------------------------------- */
.hotspots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1.5px solid transparent;
  color: transparent; /* text is for screen readers only, label is in screenshot */
  font: inherit;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: border-color 180ms ease, box-shadow 240ms ease,
              background-color 200ms ease, transform 180ms ease,
              opacity 200ms ease;
  outline: none;
}
.hotspot.is-active {
  opacity: 1;
  pointer-events: auto;
}
.hotspot-pill {
  border-radius: 999px;
}
.hotspot-input {
  border-radius: 22px;
}
.hotspot-row {
  border-radius: 14px;
}
.hotspot-plus {
  border-radius: 999px;
}
.hotspot:hover,
.hotspot:focus-visible {
  border-color: rgba(80, 220, 120, 0.85);
  background-color: rgba(80, 220, 120, 0.08);
  box-shadow: 0 0 0 1px rgba(80, 220, 120, 0.45),
              0 0 18px 2px rgba(80, 220, 120, 0.35);
  transform: scale(1.015);
}
.hotspot:active {
  transform: scale(0.985);
  background-color: rgba(80, 220, 120, 0.16);
}

/* One-time pulse animation. Run sequentially via inline animation-delay set
   from JS. Each hotspot pulses once then settles back to invisible. */
@keyframes hotspot-pulse {
  0%   { border-color: rgba(80, 220, 120, 0);
         box-shadow: 0 0 0 0 rgba(80, 220, 120, 0); }
  25%  { border-color: rgba(80, 220, 120, 0.9);
         box-shadow: 0 0 0 2px rgba(80, 220, 120, 0.5),
                     0 0 22px 4px rgba(80, 220, 120, 0.45); }
  100% { border-color: rgba(80, 220, 120, 0);
         box-shadow: 0 0 0 0 rgba(80, 220, 120, 0); }
}
.hotspot.is-pulsing {
  animation: hotspot-pulse 1100ms ease-out 1 both;
}

/* Calm constant pulse — runs while the hotspot is active. Used on the + icon
   on the AI chat slide to draw a gentle, continuous hint without being noisy. */
@keyframes hotspot-pulse-calm {
  0%, 100% {
    border-color: rgba(80, 220, 120, 0.30);
    box-shadow: 0 0 0 0 rgba(80, 220, 120, 0);
  }
  50% {
    border-color: rgba(80, 220, 120, 1);
    box-shadow: 0 0 8px 0 rgba(80, 220, 120, 0.45);
  }
}
.hotspot.pulse-calm.is-active {
  animation: hotspot-pulse-calm 2400ms ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   Back hotspot — covers the upper (atlas) portion of the iPhone screen on
   slides 2–7. Invisible by default; on hover a small green hint pill fades in
   near the top of the screen. Click returns to slide 1.
   Height 45% chosen to clear the +Frames panel on slide 2 (panel starts ~47%)
   and other detail-panel slides.
   ---------------------------------------------------------------------------- */
.back-hotspot {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 45%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  outline: none;
}
.back-hotspot.is-on {
  opacity: 1;
  pointer-events: auto;
}
.back-hint {
  position: absolute;
  top: 10.5%;
  left: 50%;
  transform: translate(-50%, -6px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(18, 24, 20, 0.78);
  border: 1px solid rgba(80, 220, 120, 0.7);
  color: rgba(190, 245, 210, 0.96);
  font: 500 10.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI",
         system-ui, sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 180ms ease, transform 220ms ease;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45),
              0 0 14px rgba(80, 220, 120, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.back-hotspot:hover .back-hint,
.back-hotspot:focus-visible .back-hint {
  opacity: 1;
  transform: translate(-50%, 0);
}
.back-hotspot:active .back-hint {
  background: rgba(28, 40, 32, 0.85);
}

/* =========================================================================
   Responsive — mobile: fit between header + footer, never overflow width
   ========================================================================= */
@media (max-width: 640px) {
  .iphone {
    /* Height-based: leave ~150px for header (~60) + footer (~70) + gaps.
       Width follows aspect-ratio; capped at 90vw so very tall narrow
       phones don't blow out horizontally. */
    height: calc(100dvh - 160px);
    width: auto;
    max-width: 90vw;
    max-height: none;
  }
}

/* Very narrow phones (<360w): tighten further. */
@media (max-width: 360px) {
  .iphone {
    height: calc(100dvh - 140px);
  }
}
