/* ═══════════════════════════════════════════════
   CLOUDYCLOUDS — styles.css
   Dark & Stormy · Snap Scroll · Gothic Storm-Punk
   ═══════════════════════════════════════════════ */

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #060b14;
  --bg2:          #0c1526;
  --bg3:          #111e35;
  --storm:        #1a2a4a;
  --electric:     #4fc3f7;
  --electric-dim: #1a6a8a;
  --lightning:    #e8f4fd;
  --gold:         #d4a853;
  --gold-dim:     #7a5a20;
  --text:         #c8d8f0;
  --text-dim:     #5a7090;
  --danger:       #e05555;

  --font-display: 'Cinzel Decorative', serif;
  --font-title:   'Cinzel', serif;
  --font-body:    'Raleway', sans-serif;

  --ease-swoop:   cubic-bezier(0.76, 0, 0.24, 1);
  --ease-pop:     cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;               /* JS controls scrolling */
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
  cursor: crosshair;
}

/* Custom scrollbar (desktop) */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--electric-dim); border-radius: 2px; }

/* ── STORM CANVAS (fixed bg layer) ── */
#stormCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── PANEL SYSTEM ── */
.panel {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* panels start stacked below; JS controls transform */
  transform: translateY(100%);
  transition: transform 0.52s var(--ease-swoop);
  will-change: transform;
  overflow: hidden;
}

.panel.is-active {
  transform: translateY(0%);
}

.panel.is-above {
  transform: translateY(-100%);
}

/* ── INNER CONTAINER ── */
.panel-inner {
  position: relative;
  z-index: 2;
  max-width: 900px;
  width: 90%;
  padding: 2rem;
}

/* ── SECTION LABEL ── */
.section-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--electric);
  margin-bottom: 1.2rem;
  opacity: 0.8;
}

/* ── SECTION TITLE ── */
.section-title {
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--lightning);
  margin-bottom: 2rem;
  text-shadow: 0 0 60px rgba(79, 195, 247, 0.25);
}

.section-title em {
  font-style: italic;
  color: var(--electric);
}

/* ═══════════════════════════════════════════════
   HERO PANEL
   ═══════════════════════════════════════════════ */
/* Semi-transparent so #stormCanvas (rain/lightning) shows through */
#panel-hero {
  background: radial-gradient(ellipse 80% 60% at 50% 40%,
    rgba(26, 42, 74, 0.62) 0%,
    rgba(6, 11, 20, 0.78) 100%);
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.4rem;
}

/* Logo */
.logo-ring {
  position: relative;
  width: clamp(140px, 22vw, 220px);
  height: clamp(140px, 22vw, 220px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 24px rgba(79, 195, 247, 0.6));
  animation: logoFloat 6s ease-in-out infinite;
}

/* Fallback if no logo provided */
.logo-img[src="logo.png"]:not([complete]) ,
.logo-img.broken {
  /* show a cloud emoji placeholder */
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0px);   filter: drop-shadow(0 0 24px rgba(79, 195, 247, 0.6)); }
  50%       { transform: translateY(-12px); filter: drop-shadow(0 0 40px rgba(79, 195, 247, 0.9)); }
}

.logo-glow-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(79, 195, 247, 0.3);
  animation: ringPulse 3s ease-in-out infinite;
}

.logo-glow-ring::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(79, 195, 247, 0.12);
  animation: ringPulse 3s ease-in-out infinite 0.5s;
}

@keyframes ringPulse {
  0%, 100% { opacity: 0.4; transform: scale(1);    }
  50%       { opacity: 1;   transform: scale(1.06); }
}

/* Studio Name */
.studio-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow:
    0 0 80px rgba(79, 195, 247, 0.4),
    0 2px 40px rgba(0,0,0,0.8);
}

.studio-cloudy { color: var(--lightning); }
.studio-clouds { color: var(--electric);  }

.studio-tagline {
  font-family: var(--font-body);
  font-size: clamp(0.6rem, 1.5vw, 0.85rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

/* Scroll Cue */
.scroll-cue {
  position: absolute;
  bottom: -38vh;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: scrollFade 2.5s ease-in-out infinite;
}

.scroll-arrow {
  width: 20px;
  height: 20px;
  color: var(--electric);
}

@keyframes scrollFade {
  0%, 100% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
  50%       { opacity: 0.9; transform: translateX(-50%) translateY(6px); }
}

/* ═══════════════════════════════════════════════
   ABOUT PANEL
   ═══════════════════════════════════════════════ */
#panel-about {
  background:
    radial-gradient(ellipse 100% 80% at 80% 50%,
      rgba(26, 42, 74, 0.5) 0%, transparent 70%),
    linear-gradient(170deg, rgba(6, 11, 20, 0.78) 0%, rgba(12, 21, 38, 0.85) 100%);
}

.about-inner {}

.about-body {
  max-width: 560px;
  line-height: 1.85;
  font-size: 1rem;
  color: var(--text);
  font-weight: 300;
}

.about-body p + p { margin-top: 1rem; }

.about-body strong {
  color: var(--electric);
  font-weight: 500;
}

.about-stats {
  display: flex;
  gap: 3rem;
  margin-top: 3rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-num {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--electric);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Decorative clouds */
.cloud-deco {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  opacity: 0.04;
  border-radius: 50%;
  background: var(--electric);
  filter: blur(80px);
}

.cloud-deco-left  { width: 400px; height: 300px; left: -120px; top: 50%; transform: translateY(-50%); }
.cloud-deco-right { width: 300px; height: 250px; right: -80px; bottom: 10%; }

/* ═══════════════════════════════════════════════
   GAMES PANEL
   ═══════════════════════════════════════════════ */
#panel-games {
  background:
    radial-gradient(ellipse 70% 80% at 20% 60%,
      rgba(12, 21, 38, 0.55) 0%, transparent 70%),
    linear-gradient(160deg, rgba(12, 21, 38, 0.8) 0%, rgba(6, 11, 20, 0.86) 100%);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 1.25rem;
  box-sizing: border-box;
}

/* Above dim overlay (199) while a card is flipped so the games UI (and card) are not dimmed */
#panel-games.game-card-flipped {
  z-index: 200;
}

#panel-games.game-card-flipped ~ .nav-dots {
  z-index: 210;
}

.games-inner {
  max-width: 1400px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.games-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 3.5rem;
  margin-top: 1rem;
}

/* Game Card — overflow visible so 3D flip / enlarged flipper are not clipped */
.game-card {
  perspective: 1200px;
  position: relative;
  z-index: 0;
  height: 420px;
  background: transparent;
  border: none;
  border-radius: 12px;
  overflow: visible;
  cursor: default;
}

.game-card-art {
  position: relative;
  height: 130px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-card-art-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 80%,
    hsl(var(--card-hue), 70%, 25%) 0%,
    hsl(var(--card-hue), 50%, 8%)  100%);
  transition: opacity 0.4s ease;
}

.game-card:hover .game-card-art-bg {
  opacity: 0.8;
}

.game-card-art-icon {
  font-size: 3rem;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 16px rgba(255,255,255,0.5));
  transition: transform 0.4s var(--ease-pop);
}

.game-card:hover .game-card-art-icon {
  transform: scale(1.2);
}

.game-card-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-genre {
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.game-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--lightning);
}

.game-desc {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-dim);
  font-weight: 300;
  flex: 1;
}

.play-btn {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: 1px solid var(--electric-dim);
  border-radius: 6px;
  color: var(--electric);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
}

.play-btn svg { width: 14px; height: 14px; }

.play-btn:hover {
  background: var(--electric);
  border-color: var(--electric);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(79, 195, 247, 0.4);
}

/* ═══════════════════════════════════════════════
   CONTACT PANEL
   ═══════════════════════════════════════════════ */
#panel-contact {
  background: linear-gradient(175deg, rgba(12, 21, 38, 0.82) 0%, rgba(6, 11, 20, 0.88) 100%);
}

.contact-inner {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.contact-copy {
  font-size: 1rem;
  color: var(--text-dim);
  font-weight: 300;
  line-height: 1.7;
  max-width: 480px;
}

.contact-email {
  font-family: var(--font-title);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--electric);
  text-decoration: none;
  letter-spacing: 0.05em;
  position: relative;
  display: inline-block;
  transition: color 0.25s;
}

.contact-email::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--electric);
  transition: width 0.4s ease;
}

.contact-email:hover { color: var(--lightning); }
.contact-email:hover::after { width: 100%; }

.social-links {
  display: flex;
  gap: 2rem;
  margin-top: 0.5rem;
}

.social-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: color 0.25s;
}

.social-link:hover { color: var(--electric); }

.footer-sig {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(79, 195, 247, 0.08);
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  gap: 1rem;
  letter-spacing: 0.1em;
}

.footer-dot { color: var(--electric-dim); }

/* Lightning fork decoration — needs real width so clip-path reads as a fork, not a 2px “seam” */
.lightning-fork {
  position: absolute;
  right: 6%;
  top: 10%;
  width: 52px;
  height: 180px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--electric), transparent);
  clip-path: polygon(50% 0%, 60% 40%, 100% 40%, 40% 70%, 60% 70%, 0% 100%, 30% 60%, 0% 60%);
  opacity: 0.15;
  animation: lightningStatic 6s ease-in-out infinite;
}

@keyframes lightningStatic {
  0%, 90%, 100% { opacity: 0.15; }
  92%           { opacity: 0.6; }
  94%           { opacity: 0.1; }
  96%           { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════
   GAME OVERLAY
   ═══════════════════════════════════════════════ */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transition: opacity 0.4s ease, transform 0.4s var(--ease-swoop);
}

.game-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(79, 195, 247, 0.15);
  background: var(--bg2);
  flex-shrink: 0;
}

.overlay-title {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--electric);
  letter-spacing: 0.1em;
}

.overlay-close {
  background: transparent;
  border: 1px solid rgba(79, 195, 247, 0.3);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.overlay-close:hover {
  background: rgba(224, 85, 85, 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.game-frame {
  flex: 1;
  border: none;
  width: 100%;
}

/* ═══════════════════════════════════════════════
   NAV DOTS
   ═══════════════════════════════════════════════ */
.nav-dots {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  border: none;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
  padding: 0;
}

.nav-dot.active {
  background: var(--electric);
  transform: scale(1.5);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.7);
}

.nav-dot:hover:not(.active) {
  background: var(--text);
  transform: scale(1.3);
}

/* ═══════════════════════════════════════════════
   PANEL ENTRY ANIMATIONS (children animate in)
   ═══════════════════════════════════════════════ */
.panel-inner > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.panel.is-active .panel-inner > * {
  opacity: 1;
  transform: translateY(0);
}

/* stagger */
.panel.is-active .panel-inner > *:nth-child(1) { transition-delay: 0.3s; }
.panel.is-active .panel-inner > *:nth-child(2) { transition-delay: 0.45s; }
.panel.is-active .panel-inner > *:nth-child(3) { transition-delay: 0.6s; }
.panel.is-active .panel-inner > *:nth-child(4) { transition-delay: 0.75s; }
.panel.is-active .panel-inner > *:nth-child(5) { transition-delay: 0.9s; }

/* Hero content also animates */
.hero-content > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#panel-hero.is-active .hero-content > * {
  opacity: 1;
  transform: translateY(0);
}

#panel-hero.is-active .hero-content > *:nth-child(1) { transition-delay: 0.2s; }
#panel-hero.is-active .hero-content > *:nth-child(2) { transition-delay: 0.4s; }
#panel-hero.is-active .hero-content > *:nth-child(3) { transition-delay: 0.6s; }
#panel-hero.is-active .hero-content > *:nth-child(4) { transition-delay: 0.9s; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .about-stats { gap: 1.5rem; }
  .games-grid  { grid-template-columns: 1fr; gap: 2rem; }
  .game-card { height: auto; min-height: 280px; }
  .card-flipper { height: 100%; }
  .card-front { position: relative; }
  .card-back { position: relative; transform: rotateY(180deg); }
  .game-card-art { height: 100px; }
  .card-back-content { padding: 1.2rem 1rem; }
  .card-instructions { font-size: 0.72rem; line-height: 1.6; }
  .social-links { flex-wrap: wrap; gap: 1rem; }
  .nav-dots { right: 0.6rem; }
  .scroll-cue { bottom: -30vh; }
}

/* ═══════════════════════════════════════════════
   CARD FLIP
   ═══════════════════════════════════════════════ */

.game-card.is-flipped {
  z-index: 200;
}

/* In-place flip toward the viewer (no XY move to center — avoids cross-card hover thrashing). */
.card-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: center center;
  transform:
    translateZ(var(--flip-z, 0px))
    rotateY(var(--flip-r, 0deg));
  transition:
    transform 0.75s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.75s ease;
  border-radius: 12px;
  will-change: transform;
}

.game-card.is-flipped .card-flipper {
  --flip-r: 180deg;
  --flip-z: 28px;
  box-shadow:
    0 0 80px rgba(79, 195, 247, 0.25),
    0 40px 100px rgba(0, 0, 0, 0.85);
}

.game-card:not(.is-flipped) .card-flipper {
  will-change: auto;
}

/* Shared face styles */
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  transform: translateZ(0);
}

/* Explicitly hide front content when flipped to fix icon bleed-through */
.game-card.is-flipped .card-front {
  visibility: hidden;
}

/* Front face — keep existing card appearance */
.card-front {
  background: rgba(12, 21, 38, 0.8);
  border: 1px solid rgba(79, 195, 247, 0.1);
  display: flex;
  flex-direction: column;
}

/* Back face — starts flipped 180deg */
.card-back {
  background: radial-gradient(ellipse at 50% 0%,
    hsl(var(--card-hue), 60%, 18%) 0%,
    hsl(var(--card-hue), 40%, 6%)  100%);
  border: 1px solid rgba(79, 195, 247, 0.25);
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-content {
  padding: 1.8rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  justify-content: center;
}

.card-back-content .game-title {
  color: var(--electric);
  font-size: 1.1rem;
}

.card-instructions {
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--text);
  font-weight: 300;
  flex: 1;
}

.card-instructions strong {
  font-weight: 600;
  color: var(--electric);
}

/* Move game-card-body styles onto .card-front's body */
.card-front .game-card-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}