/* ═══════════════════════════════════════════════
   NANO-ZYRKEL-BASED WIDGET SHOWCASE ROOM — CINEMATIC STYLES
   ═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #050510;
  --surface: #0a0a1f;
  --brand: #8B5CF6;
  --accent: #06B6D4;
  --text: #E5E7EB;
  --text-dim: #6B7280;
  --white: #FFFFFF;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, .mono { font-family: 'JetBrains Mono', monospace; }

/* GLOBAL CANVAS */
canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}
#entry-canvas { z-index: 10; pointer-events: none; }
#main-canvas { z-index: 2; }
#lightning-canvas { z-index: 15; }

/* PHASES */
.phase {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.phase.active {
  opacity: 1;
  pointer-events: auto;
}

/* PHASE 0: Entry */
#phase-entry {
  cursor: pointer;
  background: var(--bg);
}

#entry-center {
  position: relative;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

#logo-container {
  position: relative;
  width: 180px; height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#logo {
  width: 120px; height: 120px;
  border-radius: 50%;
  object-fit: cover;
  animation: logoBreathe 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.5));
  position: relative;
  z-index: 2;
}

@keyframes logoBreathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.4)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 50px rgba(139, 92, 246, 0.7)); }
}

#enter-text {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--brand);
  animation: textPulse 2s ease-in-out infinite;
  text-transform: uppercase;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* SKIP BUTTON */
.skip-btn {
  position: fixed;
  bottom: 2rem; right: 2rem;
  z-index: 100;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-dim);
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.skip-btn:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text);
}

/* GATE LAYER */
#gate-layer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  pointer-events: none;
  perspective: 1200px;
}
.gate-half {
  position: absolute;
  top: 5%; bottom: 5%;
  width: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
#gate-left {
  left: 0;
  background-image: url('assets/gate-left.webp');
  background-position: right center;
  border-right: 2px solid rgba(6, 182, 212, 0.3);
}
#gate-right {
  right: 0;
  background-image: url('assets/gate-right.webp');
  background-position: left center;
  border-left: 2px solid rgba(6, 182, 212, 0.3);
}
#gate-glow {
  position: absolute;
  top: 20%; left: 25%; right: 25%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.6) 0%, rgba(139,92,246,0.2) 40%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

#gate-label {
  position: absolute;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(1rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.4em;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 0 20px rgba(139,92,246,0.6), 0 0 40px rgba(6,182,212,0.3);
  text-transform: uppercase;
  white-space: nowrap;
  animation: labelPulse 2s ease-in-out infinite;
}
#gate-sublabel {
  position: absolute;
  bottom: 3%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: rgba(6,182,212,0.6);
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes labelPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* FLASH OVERLAY */
#flash-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 50;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.05s;
}

/* CAMERA SHAKE */
.shake-light { animation: shakeLight 0.1s linear infinite; }
.shake-heavy { animation: shakeHeavy 0.08s linear infinite; }

@keyframes shakeLight {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(1px, 1px); }
}
@keyframes shakeHeavy {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(4px, -3px); }
  60% { transform: translate(-2px, 4px); }
  80% { transform: translate(3px, -2px); }
  100% { transform: translate(-4px, 3px); }
}

/* CHROMATIC ABERRATION */
.chromatic {
  animation: chromatic 0.15s steps(2) 3;
}
@keyframes chromatic {
  0% { filter: none; }
  33% { filter: drop-shadow(-3px 0 0 rgba(255,0,0,0.5)) drop-shadow(3px 0 0 rgba(0,100,255,0.5)); }
  66% { filter: drop-shadow(2px 0 0 rgba(255,0,0,0.4)) drop-shadow(-2px 0 0 rgba(0,100,255,0.4)); }
  100% { filter: none; }
}

/* SHOWCASE ROOM (Phase 6) */
#showcase-room {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  opacity: 0;
  transition: opacity 1s ease;
}
#showcase-room.visible {
  opacity: 1;
}

/* HEADER */
#showcase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  padding: 1rem 0 2rem;
  gap: 1rem;
}
#showcase-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.back-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
  white-space: nowrap;
}
.back-link:hover { color: var(--text); }
.powered-by {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.powered-by a { color: var(--brand); text-decoration: none; }
.powered-by a:hover { text-decoration: underline; }

/* WIDGET GRID */
#widget-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  width: 100%;
  max-width: 1100px;
  flex: 1;
}

/* WIDGET CARD */
.widget-card {
  position: relative;
  border-radius: 16px;
  overflow: visible;
  perspective: 1000px;
  transform-style: preserve-3d;
  opacity: 0;
  transform: translateZ(-500px) scale(0.3);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.widget-card.revealed {
  opacity: 1;
  transform: translateZ(0) scale(1);
}
.widget-card.float {
  animation: cardFloat 4s ease-in-out infinite;
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.card-glow {
  position: absolute;
  inset: -2px;
  border-radius: 18px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 0;
}
.widget-card:hover .card-glow {
  opacity: 1;
}

.card-inner {
  position: relative;
  z-index: 1;
  background: rgba(10, 10, 31, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.widget-card:hover .card-inner {
  border-color: rgba(255,255,255,0.2);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.card-icon {
  font-size: 2rem;
  line-height: 1;
}
.card-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--white);
}
.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-dim);
  margin-top: 0.125rem;
}
.card-description {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: justify;
}

.card-preview {
  position: relative;
  width: 100%;
  height: 350px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  background: var(--bg);
}
.card-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
  transform-origin: top left;
}
.card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(10,10,31,0.8) 100%);
  pointer-events: none;
}

/* Holographic scan line */
.widget-card.revealed .card-preview::before {
  content: '';
  position: absolute;
  top: -100%;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
  z-index: 2;
  animation: scanLine 2s ease-out forwards;
  animation-delay: inherit;
}
@keyframes scanLine {
  0% { top: -2px; opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.card-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-stats span {
  font-size: 0.6875rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 0.25rem 0.5rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: var(--text-dim);
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.btn-launch {
  flex: 1;
  text-align: center;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s;
  background: var(--brand);
  color: white;
}
.btn-launch:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}
.btn-source {
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
}
.btn-source:hover {
  background: rgba(255,255,255,0.12);
  color: var(--white);
}

/* Card particle canvas */
.card-particles {
  position: absolute;
  inset: -30px;
  width: calc(100% + 60px);
  height: calc(100% + 60px);
  z-index: 0;
  pointer-events: none;
}

/* HOLOGRAPHIC SHIMMER */
.widget-card:hover .card-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: conic-gradient(from var(--shimmer-angle, 0deg) at 50% 50%,
    transparent 0deg,
    rgba(139,92,246,0.05) 60deg,
    rgba(6,182,212,0.08) 120deg,
    transparent 180deg,
    rgba(139,92,246,0.05) 240deg,
    rgba(6,182,212,0.08) 300deg,
    transparent 360deg
  );
  mix-blend-mode: screen;
  pointer-events: none;
  animation: shimmerRotate 3s linear infinite;
}
@keyframes shimmerRotate {
  to { --shimmer-angle: 360deg; }
}
@property --shimmer-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* FOOTER */
#showcase-footer {
  width: 100%;
  max-width: 1100px;
  padding: 2rem 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 2rem;
}
#showcase-footer a {
  color: var(--brand);
  text-decoration: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  #widget-grid {
    grid-template-columns: 1fr;
  }
  #showcase-header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  .card-preview { height: 280px; }
  #showcase-room { padding: 1rem; }
  #logo { width: 80px; height: 80px; }
  #logo-container { width: 120px; height: 120px; }
  #enter-text { font-size: 0.875rem; }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* WIDGET EMBED FULLSCREEN */
#widget-embed {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: embedIn 0.4s ease-out;
}
@keyframes embedIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
#embed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 10, 31, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  gap: 1rem;
}
#embed-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
#embed-close:hover { background: rgba(255,255,255,0.12); }
#embed-title {
  font-weight: 700;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
#embed-external {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color 0.2s;
  white-space: nowrap;
}
#embed-external:hover { color: var(--text); }
#embed-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--bg);
}

/* HIDDEN UTILITY */
.hidden {
  display: none !important;
}
