/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: 'Zpix';
  src: url('https://cdn.jsdelivr.net/npm/zpix@3.1.0/dist/Zpix.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #f3f1ed;
  --text: #1d1b1b;
  --text-muted: #8a8580;
  --accent: #e8983e;
  --accent-dim: #c8782d;
  --card-border: #e0dcd6;
  --globe-size: min(480px, 75vw);
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-pixel: 'Zpix', var(--font-mono);
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* === Hero Section === */
#hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 60px 20px 40px;
  position: relative;
}

/* === Crystal Globe Container === */
.crystal-globe-container {
  position: relative;
  width: var(--globe-size);
  height: var(--globe-size);
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.crystal-globe-container:hover {
  transform: scale(1.03);
}

.crystal-globe-container:active {
  transform: scale(0.97);
}

/* The circular viewport */
.crystal-globe-safe-area {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.12),
    0 2px 8px rgba(0,0,0,0.08),
    inset 0 0 0 1px rgba(255,255,255,0.4);
}

.globe-inner {
  width: 100%;
  height: 100%;
  position: relative;
  background: #1a1225;
}

/* Canvas layers */
.globe-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.globe-scene { z-index: 1; }
.globe-stars { z-index: 2; pointer-events: none; }

/* Video layers */
.globe-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
.globe-video.active { opacity: 1; }
.globe-video.fading { opacity: 0; }

/* Glass veil overlay — dreamy magical feel */
.globe-veil {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 35% 28%, rgba(255,255,255,0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 65% 70%, rgba(180,200,255,0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(20,10,35,0.35) 100%),
    radial-gradient(circle at 50% 50%, transparent 0%, rgba(26,18,37,0.12) 100%);
  animation: veil-shimmer 6s ease-in-out infinite;
}

@keyframes veil-shimmer {
  0%, 100% {
    background:
      radial-gradient(ellipse at 35% 28%, rgba(255,255,255,0.18) 0%, transparent 50%),
      radial-gradient(ellipse at 65% 70%, rgba(180,200,255,0.08) 0%, transparent 45%),
      radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(20,10,35,0.35) 100%),
      radial-gradient(circle at 50% 50%, transparent 0%, rgba(26,18,37,0.12) 100%);
  }
  50% {
    background:
      radial-gradient(ellipse at 38% 30%, rgba(255,255,255,0.22) 0%, transparent 52%),
      radial-gradient(ellipse at 62% 72%, rgba(180,200,255,0.12) 0%, transparent 48%),
      radial-gradient(ellipse at 50% 50%, transparent 58%, rgba(15,5,30,0.32) 100%),
      radial-gradient(circle at 50% 50%, transparent 0%, rgba(26,18,37,0.10) 100%);
  }
}

/* Sparkle ring around the globe */
.globe-sparkle {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(232,152,62,0.15);
  pointer-events: none;
  animation: sparkle-pulse 4s ease-in-out infinite;
  box-shadow:
    0 0 20px rgba(200,160,220,0.08),
    0 0 40px rgba(180,200,240,0.05);
}

@keyframes sparkle-pulse {
  0%, 100% {
    border-color: rgba(232,152,62,0.1);
    box-shadow: 0 0 20px rgba(200,160,220,0.08), 0 0 40px rgba(180,200,240,0.05);
  }
  50% {
    border-color: rgba(232,152,62,0.25);
    box-shadow: 0 0 30px rgba(200,160,220,0.15), 0 0 60px rgba(180,200,240,0.1);
  }
}

/* Hero text */
.hero-tagline {
  margin-top: 28px;
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.hero-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 1px;
}

.hero-scroll {
  position: absolute;
  bottom: 30px;
  font-size: 16px;
  color: var(--text-muted);
  opacity: 0.4;
  animation: bounce 2s ease-in-out infinite;
}

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

/* === Scene Dots === */
#scene-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 0 32px;
}

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--card-border);
  transition: all 0.4s;
}

.dot.active {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(232,152,62,0.4);
}

/* === Letter Section === */
#letter-section {
  display: flex;
  justify-content: center;
  padding: 80px 20px 100px;
  opacity: 0;
  transition: opacity 0.8s;
}

#letter-section.visible { opacity: 1; }

.letter-paper {
  position: relative;
  max-width: 580px;
  width: 100%;
  min-height: 420px;
  background: #faf7f2;
  padding: 48px 40px 60px;
  box-shadow:
    0 2px 12px rgba(0,0,0,0.06),
    0 0 0 1px rgba(0,0,0,0.04);
  border-radius: 2px;
}

.letter-lines {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    rgba(180,160,140,0.15) 27px,
    rgba(180,160,140,0.15) 28px
  );
  mask-image: linear-gradient(to bottom, transparent 40px, black 48px, black calc(100% - 50px), transparent calc(100% - 42px));
  -webkit-mask-image: linear-gradient(to bottom, transparent 40px, black 48px, black calc(100% - 50px), transparent calc(100% - 42px));
}

.letter-content {
  position: relative;
  z-index: 1;
  font-family: var(--font-pixel);
  font-size: 15px;
  line-height: 28px;
  color: #5a3a2a;
  white-space: pre-wrap;
  padding-left: 12px;
}

.letter-sticker {
  position: absolute;
  right: 36px; bottom: 56px;
  width: 72px; height: 72px;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: default;
}

.letter-sticker:hover {
  transform: rotate(-3deg) scale(1.08);
}

.letter-sticker img {
  width: 100%; height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.letter-sticker.peeling {
  animation: peel-off 1.8s ease-in-out forwards;
}

@keyframes peel-off {
  0% { transform: rotate(0) scale(1); opacity: 1; }
  30% { transform: rotate(-8deg) scale(1.08) translateY(-6px); opacity: 1; }
  100% { transform: rotate(-20deg) scale(0.9) translateY(-180px) translateX(40px); opacity: 0; }
}

/* === Product Section === */
#product-section {
  max-width: 640px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s;
}

#product-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  font-family: var(--font-pixel);
  font-size: 32px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 6px;
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 48px;
}

.product-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 48px;
}

.product-card {
  display: flex;
  align-items: flex-start; gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--card-border);
  opacity: 0;
  transform: translateY(16px);
}

.product-card:first-child { border-top: 1px solid var(--card-border); }

.card-dot {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
}

.product-card h3 {
  font-family: var(--font-pixel);
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 2px;
}

.product-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* === Download Button === */
#download-btn {
  display: inline-flex;
  align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  padding: 14px 32px;
  border-radius: 4px;
  transition: all 0.25s;
  position: relative;
  letter-spacing: 0.5px;
}

#download-btn:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(200,120,40,0.3);
}

#download-btn .version {
  font-size: 10px;
  opacity: 0.6;
}

/* === Footer === */
footer {
  text-align: center;
  padding: 40px 20px 60px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* === Mute Button === */
#mute-btn {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 100;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center; justify-content: center;
}

#mute-btn:hover { border-color: var(--accent); color: var(--accent); }
#mute-btn.muted { color: var(--card-border); }

/* === Responsive === */
@media (max-width: 600px) {
  :root { --globe-size: 82vw; }
  .letter-paper { padding: 32px 20px 48px; }
  .letter-content { padding-left: 2px; font-size: 13px; }
  .section-title { font-size: 24px; }
  #product-section { padding: 40px 20px 60px; }
}
