/* =========================================================
   iHome Global — Apple-Style Dark Landing Page
   ========================================================= */

/* ── Reset & Base ─────────────────────────────────────── */
#landing-page *,
#landing-page *::before,
#landing-page *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#landing-page {
  --font: -apple-system, 'SF Pro Display', 'SF Pro Text', BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #000000;
  --bg-alt: #0a0a0a;
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --accent: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Scene glow vars — controlled by JS */
  --glow-color: 255, 154, 60;
  --glow-opacity: 0;
  --glow-x: 50%;
  --glow-y: 50%;

  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Ambient Background Glow ─────────────────────────── */
.landing-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    ellipse 70% 60% at var(--glow-x) var(--glow-y),
    rgba(var(--glow-color), var(--glow-opacity)) 0%,
    transparent 70%
  );
  transition: background 1.2s var(--ease), opacity 0.8s var(--ease);
}

/* Gate animation overlay */
.landing-gate {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: flex;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.landing-gate.active {
  opacity: 1;
}

.gate-panel-left,
.gate-panel-right {
  width: 50%;
  height: 100%;
  background: rgba(0, 200, 83, 0.04);
  border: 1px solid rgba(0, 200, 83, 0.12);
  transform: translateX(0);
  transition: transform 1.2s var(--ease);
}

.landing-gate.active .gate-panel-left {
  transform: translateX(-100%);
}

.landing-gate.active .gate-panel-right {
  transform: translateX(100%);
}

/* Equalizer bars for music */
.landing-equalizer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 0 20%;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.landing-equalizer.active {
  opacity: 1;
}

.eq-bar {
  flex: 1;
  background: linear-gradient(to top, rgba(175, 82, 222, 0.6), rgba(175, 82, 222, 0.1));
  border-radius: 3px 3px 0 0;
  animation: eqBounce 0.8s ease-in-out infinite alternate;
  transform-origin: bottom;
}

.eq-bar:nth-child(1)  { animation-delay: 0.00s; }
.eq-bar:nth-child(2)  { animation-delay: 0.07s; }
.eq-bar:nth-child(3)  { animation-delay: 0.14s; }
.eq-bar:nth-child(4)  { animation-delay: 0.21s; }
.eq-bar:nth-child(5)  { animation-delay: 0.28s; }
.eq-bar:nth-child(6)  { animation-delay: 0.14s; }
.eq-bar:nth-child(7)  { animation-delay: 0.07s; }
.eq-bar:nth-child(8)  { animation-delay: 0.00s; }
.eq-bar:nth-child(9)  { animation-delay: 0.10s; }
.eq-bar:nth-child(10) { animation-delay: 0.20s; }

/* Stars overlay for night mode */
.landing-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 1s var(--ease);
}

.landing-stars.active {
  opacity: 1;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  animation: starTwinkle var(--duration, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

/* ── Typography ──────────────────────────────────────── */
.landing-eyebrow {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.landing-headline {
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 24px;
}

.landing-headline span {
  background: linear-gradient(135deg, #ffffff 30%, #a1a1a6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subhead {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 40px;
}

.section-headline {
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.1;
}

.section-subhead {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 540px;
  margin: 0 auto 60px;
}

/* ── Layout Utilities ────────────────────────────────── */
.landing-section {
  position: relative;
  z-index: 2;
  width: 100%;
  overflow: hidden;
}

.landing-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 40px;
}

.landing-center {
  text-align: center;
}

/* ── Scroll Reveal ───────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

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

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ── iPhone Mockup ───────────────────────────────────── */
.iphone-wrapper {
  position: relative;
  display: inline-block;
  perspective: 1200px;
  z-index: 2;
}

.iphone-frame {
  position: relative;
  width: 280px;
  height: 568px;
  border-radius: 48px;
  background: linear-gradient(160deg, #d0d0d2 0%, #b8b8ba 50%, #c8c8ca 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.6),
    0 0 0 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 60px 160px rgba(0, 0, 0, 0.5);
  transform-style: preserve-3d;
  transition: transform 0.1s linear;
}

/* Side buttons */
.iphone-frame::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 110px;
  width: 3px;
  height: 34px;
  background: linear-gradient(to right, #a0a0a2, #b8b8ba);
  border-radius: 2px 0 0 2px;
  box-shadow: 0 44px 0 rgba(160,160,162,0.8);
}

.iphone-frame::after {
  content: '';
  position: absolute;
  right: -3px;
  top: 145px;
  width: 3px;
  height: 70px;
  background: linear-gradient(to left, #a0a0a2, #b8b8ba);
  border-radius: 0 2px 2px 0;
}

.iphone-screen {
  position: absolute;
  inset: 8px;
  border-radius: 42px;
  background: #000000;
  overflow: hidden;
}

.iphone-dynamic-island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 36px;
  background: #000;
  border-radius: 20px;
  z-index: 10;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04);
}

/* ── HomeKit Screen UI ───────────────────────────────── */
.homekit-screen {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    #6fa8d0 0%,
    #8fb5c8 18%,
    #c4a96a 42%,
    #d09840 62%,
    #b07828 100%
  );
  display: flex;
  flex-direction: column;
  padding: 0;
  font-size: 11px;
  font-family: var(--font);
  color: #1c1c1e;
  overflow: hidden;
}

.homekit-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
  z-index: -1;
}

/* Status Bar */
.hk-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 54px 20px 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #1c1c1e;
}

.hk-status-time {
  font-size: 15px;
  font-weight: 700;
  color: #1c1c1e;
}

.hk-status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  opacity: 0.85;
  color: #1c1c1e;
}

/* Toolbar */
.hk-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 16px 6px;
}

.hk-toolbar-btn {
  background: rgba(0, 0, 0, 0.18);
  border: none;
  border-radius: 980px;
  color: #1c1c1e;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  padding: 5px 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Title Row */
.hk-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2px 16px 8px;
}

.hk-title-main {
  font-size: 26px;
  font-weight: 700;
  color: #1c1c1e;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hk-title-meta {
  font-size: 9px;
  color: rgba(28, 28, 30, 0.5);
  text-align: right;
  line-height: 1.4;
  max-width: 70px;
  word-break: break-word;
}

/* Category Pills */
.hk-pills {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hk-pills::-webkit-scrollbar { display: none; }

.hk-pill {
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.18);
  color: #1c1c1e;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 980px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: default;
  white-space: nowrap;
}

.hk-pill.active {
  background: rgba(255, 255, 255, 0.75);
  color: #1c1c1e;
}

/* Room List */
.hk-rooms {
  flex: 1;
  min-height: 0; /* critical: allows flex child to shrink below content height */
  overflow-y: auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hk-rooms::-webkit-scrollbar { display: none; }

.hk-room-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(28, 28, 30, 0.6);
  margin-top: 8px;
  margin-bottom: 2px;
}

.hk-device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 16, 8, 0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hk-device-row--passive {
  pointer-events: none;
  opacity: 0.75;
}

.hk-device-row:active {
  transform: scale(0.96);
}

.hk-device-row.on {
  background: rgba(255, 255, 255, 0.55);
}

.hk-device-row.on-green {
  background: rgba(255, 255, 255, 0.55);
}

.hk-device-row.on-blue {
  background: rgba(255, 255, 255, 0.55);
}

.hk-device-row.on-purple {
  background: rgba(255, 255, 255, 0.55);
}

.hk-device-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.hk-device-info {
  flex: 1;
  min-width: 0;
}

.hk-device-name {
  font-size: 12px;
  font-weight: 600;
  color: #1c1c1e;
  line-height: 1.2;
}

.hk-device-status {
  font-size: 10px;
  color: rgba(28, 28, 30, 0.55);
  margin-top: 1px;
}

.hk-device-row.on .hk-device-status { color: rgba(255, 154, 60, 0.9); }
.hk-device-row.on-green .hk-device-status { color: rgba(0, 160, 60, 0.9); }
.hk-device-row.on-blue .hk-device-status { color: rgba(0, 100, 200, 0.9); }
.hk-device-row.on-purple .hk-device-status { color: rgba(140, 60, 200, 0.9); }

/* Bottom Nav */
.hk-bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 20px 14px;
  background: rgba(190, 155, 90, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.hk-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hk-nav-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(28, 28, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  transition: background 0.3s var(--ease);
}

.hk-nav-label {
  font-size: 9px;
  font-weight: 500;
  color: rgba(28, 28, 30, 0.6);
  font-family: var(--font);
  transition: color 0.3s var(--ease);
}

.hk-nav-item.active .hk-nav-circle,
.hk-nav-item.on .hk-nav-circle {
  background: #e07d1a;
}

.hk-nav-item.active .hk-nav-label,
.hk-nav-item.on .hk-nav-label {
  color: #1c1c1e;
  font-weight: 600;
}

/* Glow halo on iPhone when active */
.iphone-glow {
  position: absolute;
  inset: -30px;
  border-radius: 80px;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(var(--glow-color), 0.18) 0%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s var(--ease), background 1s var(--ease);
  z-index: 0;
}

.iphone-wrapper.glowing .iphone-glow {
  opacity: 1;
}

/* ── SECTION 2: INTERACTIVE HOMEKIT ─────────────────── */
#landing-homekit {
  min-height: 100vh;
  padding-top: 60px;
  padding-bottom: 120px;
  padding-left: 40px;
  padding-right: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
}

.homekit-layout {
  display: flex;
  align-items: center;
  gap: 80px;
  max-width: 1000px;
  width: 100%;
}

.homekit-info {
  flex: 1;
  min-width: 0;
}

.homekit-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-tertiary);
  margin-top: 24px;
}

.homekit-hint-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  animation: hintPulse 2s ease-in-out infinite;
}

.homekit-phone-wrap {
  flex-shrink: 0;
  position: relative;
}

/* ── SECTION 3: FEATURES ─────────────────────────────── */
#landing-features {
  padding: 120px 40px;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.015) 50%, transparent 100%);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

.feature-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 36px 32px;
  transition:
    background 0.3s var(--ease),
    border-color 0.3s var(--ease),
    transform 0.3s var(--ease-spring);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.feature-card:hover {
  background: var(--glass-hover);
  border-color: rgba(255,255,255,0.16);
  transform: translateY(-4px);
}

.feature-icon {
  font-size: 36px;
  margin-bottom: 20px;
  display: block;
  line-height: 1;
}

.feature-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.feature-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── SECTION 4: CTA ──────────────────────────────────── */
#landing-cta {
  padding: 140px 40px;
  text-align: center;
  position: relative;
}

#landing-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(255,255,255,0.03), transparent 70%);
  pointer-events: none;
}

.cta-headline {
  font-size: clamp(40px, 5.5vw, 72px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
  margin-bottom: 20px;
}

.cta-sub {
  font-size: 19px;
  color: var(--text-secondary);
  margin-bottom: 48px;
  font-weight: 400;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 36px;
  background: #ffffff;
  color: #000000;
  border: none;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.2s var(--ease),
    transform 0.2s var(--ease-spring),
    box-shadow 0.2s var(--ease);
  box-shadow: 0 4px 24px rgba(255,255,255,0.12);
}

.btn-primary:hover {
  background: #f5f5f7;
  transform: scale(1.03);
  box-shadow: 0 8px 40px rgba(255,255,255,0.18);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 980px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.2s var(--ease-spring);
  margin-left: 16px;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.4);
  transform: scale(1.02);
}

/* ── Divider ─────────────────────────────────────────── */
.landing-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.08), transparent);
  margin: 0;
}

/* ── Keyframe Animations ─────────────────────────────── */
@keyframes scrollBounce {
  0%, 100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
  50%       { opacity: 0.8; transform: translateX(-50%) translateY(6px); }
}

@keyframes eqBounce {
  0%   { height: 8px; }
  100% { height: 80px; }
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.4); }
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.4); }
}

@keyframes ambientFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(10px, -15px) scale(1.04); }
  66%       { transform: translate(-8px, 10px) scale(0.97); }
}

@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.iphone-wrapper {
  animation: heroFadeIn 1.2s var(--ease) 0.4s both;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .homekit-layout {
    flex-direction: column;
    gap: 60px;
    text-align: center;
  }

  .homekit-info {
    order: 2;
  }

  .homekit-phone-wrap {
    order: 1;
  }

  .homekit-hint {
    justify-content: center;
  }

  .features-grid {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
}

@media (max-width: 600px) {
  .landing-container {
    padding: 0 24px;
  }

  #landing-homekit {
    padding: 60px 24px 60px;
  }

  #landing-features,
  #landing-cta {
    padding: 80px 24px;
  }

  .iphone-frame {
    width: 240px;
    height: 488px;
    border-radius: 42px;
  }

  .iphone-screen {
    border-radius: 36px;
  }

  .iphone-dynamic-island {
    width: 100px;
    height: 30px;
  }

  .btn-ghost {
    display: none;
  }
}
