@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap');

/* --- AEP Animation System Variables --- */
:root {
  --aep-electric-blue: #0d6efd;
  --aep-cyan: #00ffff;
  --aep-silver: #c0c0c0;
  --aep-bg-dark: #000813;
  --aep-glow-blue: 0 0 15px rgba(13, 110, 253, 0.6);
  --aep-glow-cyan: 0 0 20px rgba(0, 255, 255, 0.8);
  --aep-text-title: 'Orbitron', sans-serif;
  --aep-text-corp: 'Montserrat', sans-serif;
}

/* --- Studio Interface Layout --- */
.studio-container {
  display: block;
  max-width: 1200px;
  margin: 2rem auto 4rem auto;
}

@media (max-width: 1024px) {
  .studio-container {
    margin: 1.5rem auto 3rem auto;
  }
}

/* Viewport Panel */
.viewport-panel {
  display: flex;
  flex-direction: column;
  background: #000c1d;
  border: 1px solid rgba(0, 255, 255, 0.15);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(0, 128, 255, 0.1);
  position: relative;
  width: 100%;
}

/* The 16:9 Render Area */
.animation-viewport {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
  background-color: var(--aep-bg-dark);
  overflow: hidden;
  user-select: none;
}

/* Timeline Controls HUD (Absolute sliding overlay) - Hidden permanently */
.controls-hud {
  display: none !important;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Custom Timeline Scrubber */
.timeline-slider {
  flex-grow: 1;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 255, 255, 0.1);
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  transition: background 0.3s;
}

.timeline-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--aep-cyan);
  box-shadow: var(--aep-glow-cyan);
  cursor: pointer;
  margin-top: -5px;
  transition: transform 0.1s;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Frame and Time readouts */
.hud-time {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: var(--aep-cyan);
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
  min-width: 130px;
  text-align: right;
}

.hud-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

.hud-btn {
  background: rgba(13, 110, 253, 0.15);
  border: 1px solid var(--aep-electric-blue);
  color: #fff;
  border-radius: 4px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
}

.hud-btn:hover {
  background: var(--aep-electric-blue);
  box-shadow: var(--aep-glow-blue);
  transform: translateY(-1px);
}

.hud-btn.active {
  background: var(--aep-cyan);
  border-color: var(--aep-cyan);
  color: var(--aep-bg-dark);
  box-shadow: var(--aep-glow-cyan);
}

.hud-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Layer Inspector Panel - Hidden by default */
.sidebar-panel {
  display: none;
}

/* --- Animation Elements & Canvas Layers --- */

.view-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.view-layer.active-layer {
  opacity: 1;
}

/* Background digital city */
.layer-city-bg {
  background-image: url('../assets/images/digital_city_circuits.png');
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

.layer-city-bg.active-layer {
  opacity: 0.45; /* Curated opacity to blend with cyberspace elements */
}

/* Pulse keyframes for digital lights */
.digital-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 30%, rgba(0, 8, 19, 0.8) 100%);
  animation: bg-pulse 6s ease-in-out infinite;
}

@keyframes bg-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.95; }
}

/* Binary falling code canvas */
#binary-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Holographic Smartphone */
.layer-phone {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.phone-hologram {
  width: 200px;
  height: 380px;
  border: 2px solid var(--aep-cyan);
  border-radius: 28px;
  background: rgba(0, 24, 49, 0.45);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.2), inset 0 0 15px rgba(0, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(10px) rotateX(15deg);
  transform-style: preserve-3d;
  opacity: 0;
  transition: all 1s cubic-bezier(0.19, 1, 0.22, 1);
}

.phone-hologram.materialize {
  opacity: 1;
  transform: translateY(0) rotateX(0deg);
}

/* Scanner Laser Sweep */
.phone-scanner {
  position: absolute;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--aep-cyan);
  box-shadow: 0 0 12px var(--aep-cyan), 0 0 25px var(--aep-cyan);
  opacity: 0.8;
  animation: laser-sweep 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes laser-sweep {
  0% { top: 5%; }
  50% { top: 95%; }
  100% { top: 5%; }
}

/* Grid overlay inside phone */
.phone-grid {
  position: absolute;
  top: 15px;
  left: 10px;
  right: 10px;
  bottom: 15px;
  border-radius: 18px;
  background-image: 
    linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 0),
    linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 0);
  background-size: 15px 15px;
  overflow: hidden;
}

/* Shield and Lock element */
.layer-shield {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.neon-shield-svg {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 0 8px var(--aep-electric-blue));
  transform: scale(0.6);
  opacity: 0;
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.neon-shield-svg.active {
  transform: scale(1);
  opacity: 1;
}

.neon-shield-svg.flash {
  animation: shield-flash 0.5s ease-out;
}

.neon-shield-svg.pulse {
  animation: shield-pulse 2s ease-in-out infinite;
}

@keyframes shield-flash {
  0% { filter: drop-shadow(0 0 50px #fff); transform: scale(0.5); opacity: 0; }
  50% { filter: drop-shadow(0 0 100px var(--aep-cyan)); transform: scale(1.2); opacity: 1; }
  100% { filter: drop-shadow(0 0 8px var(--aep-electric-blue)); transform: scale(1); }
}

@keyframes shield-pulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--aep-electric-blue)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 25px var(--aep-cyan)); transform: scale(1.06); }
}

/* Curved data flows (Trim Paths) */
.layer-flows {
  z-index: 2;
}

.data-flow-svg {
  width: 100%;
  height: 100%;
}

.flow-path {
  fill: none;
  stroke: var(--aep-electric-blue);
  stroke-width: 1.5;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  opacity: 0;
  transition: opacity 1s;
}

.flow-path.active {
  opacity: 0.45;
}

/* Pulsing packet animation moving along the SVG path */
.flow-packet {
  fill: none;
  stroke: var(--aep-cyan);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 15, 200;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px var(--aep-cyan));
  opacity: 0;
  transition: opacity 0.5s;
}

.flow-packet.active {
  opacity: 1;
  animation: packet-move 4s linear infinite;
}

@keyframes packet-move {
  0% { stroke-dashoffset: 250; }
  100% { stroke-dashoffset: -250; }
}

/* Floating App Icons */
.layer-apps {
  z-index: 4;
}

.floating-app-icon {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(0, 12, 29, 0.85);
  border: 1px solid var(--aep-cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.8s, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-app-icon.active {
  opacity: 1;
  transform: scale(1);
}

.floating-app-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--aep-cyan);
  stroke-width: 2;
  filter: drop-shadow(0 0 4px var(--aep-cyan));
}

/* Absolute positions for App Icons around the Phone */
.app-mail { top: 22%; left: 30%; }
.app-cloud { top: 22%; right: 30%; }
.app-cart { bottom: 22%; left: 30%; }
.app-chat { bottom: 22%; right: 30%; }



/* Corporate Texts */
.layer-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 80px;
  z-index: 6;
  text-align: left;
  width: 480px; /* Constraints width to align with left margin */
}

.layer-text h2 {
  font-family: var(--aep-text-corp);
  font-size: 2.2rem;
  font-weight: 700; /* Montserrat Bold */
  color: #fff;
  text-align: left;
  margin-bottom: 0.5rem;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0;
  transform: translateY(15px);
  transition: all 1s cubic-bezier(0.19, 1, 0.22, 1);
}

.layer-text p {
  font-family: var(--aep-text-corp);
  font-size: 1.15rem;
  font-weight: 400; /* Montserrat Regular */
  color: var(--aep-silver);
  margin-bottom: 0;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(15px);
  transition: all 1s cubic-bezier(0.19, 1, 0.22, 1);
  max-width: 500px;
}

/* Right-aligned Statistics Layer */
.view-layer.layer-stats {
  position: absolute;
  top: 0;
  left: auto;
  right: 0;
  width: 480px;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.stat-message {
  font-family: var(--aep-text-corp);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--aep-silver);
  line-height: 1.5;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
  opacity: 0;
  transform: translateY(-50%) translateY(15px);
  position: absolute;
  top: 50%;
  right: 80px;
  width: calc(100% - 80px);
  max-width: 380px;
  text-align: left;
  transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.stat-message.active-stat {
  opacity: 1;
  transform: translateY(-50%) translateY(0);
  pointer-events: auto;
}

.stat-highlight {
  color: var(--aep-cyan);
  font-weight: 700;
  text-shadow: var(--aep-glow-cyan);
}

.layer-text.active-text h2, .layer-text.active-text p {
  opacity: 1;
  transform: translateY(0);
}

.layer-text.active-text p {
  transition-delay: 0.25s;
}

/* Glow pulse animation triggered on the corporate text */
.glow-pulse-active {
  animation: text-glow-pulse 4s infinite alternate;
}

@keyframes text-glow-pulse {
  0% { text-shadow: none; }
  100% { text-shadow: 0 0 12px rgba(0, 255, 255, 0.5), 0 0 25px rgba(0, 255, 255, 0.2); }
}

/* CSTY Outro Logo Reveal */
.layer-logo-outro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 8, 19, 0.9);
  z-index: 7;
}

.outro-logo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  opacity: 0;
  transform: scale(0.8);
  transition: all 1.2s cubic-bezier(0.19, 1, 0.22, 1);
}

.outro-logo-wrapper.reveal {
  opacity: 1;
  transform: scale(1);
}

.outro-logo-svg {
  width: 130px;
  height: 130px;
  filter: drop-shadow(0 0 0px var(--aep-cyan));
  transition: filter 1s;
}

.outro-logo-wrapper.reveal .outro-logo-svg {
  filter: drop-shadow(0 0 20px var(--aep-cyan));
}

.outro-text {
  font-family: var(--aep-text-title);
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 5px;
  text-shadow: 0 0 0px rgba(0, 255, 255, 0);
  transition: text-shadow 1s;
}

.outro-logo-wrapper.reveal .outro-text {
  text-shadow: 0 0 15px var(--aep-cyan);
}

.outro-sub {
  font-family: var(--aep-text-corp);
  font-size: 0.9rem;
  color: var(--aep-silver);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* --- Replay Screen Overlay --- */
.replay-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 8, 19, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.replay-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.replay-btn {
  background: transparent;
  border: 2px solid var(--aep-cyan);
  color: #fff;
  font-family: var(--aep-text-title);
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 2.2rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.3s;
  box-shadow: var(--aep-glow-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.replay-btn:hover {
  background: var(--aep-cyan);
  color: var(--aep-bg-dark);
  box-shadow: 0 0 35px var(--aep-cyan);
  transform: translateY(-2px);
}

.replay-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* --- Mobile Responsive adjustments for Vertical Viewport --- */
@media (max-width: 768px) {
  /* 1. Change viewport to vertical aspect ratio (9:16) */
  .animation-viewport {
    aspect-ratio: 9 / 16;
  }

  /* 2. Capa 4: Texto Corporativo (Show at top, smaller text) */
  .layer-text {
    width: 100%;
    padding: 1.5rem 1rem;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    top: 15px;
    bottom: auto;
    height: auto;
  }
  .layer-text h2 {
    font-size: 1.35rem;
    text-align: center;
    margin-bottom: 0.35rem;
  }
  .layer-text p {
    font-size: 0.85rem;
    text-align: center;
    max-width: 90%;
  }

  /* 3. Capa 10: Datos Estadísticos (Show at bottom, smaller text) */
  .view-layer.layer-stats {
    width: 100%;
    height: auto;
    top: auto;
    bottom: 25px;
    left: 0;
    right: 0;
  }
  .stat-message {
    font-size: 0.85rem;
    text-align: center;
    width: 90%;
    max-width: 90%;
    right: auto;
    left: 5%;
    top: auto;
    bottom: 0;
    transform: translateY(15px);
  }
  .stat-message.active-stat {
    transform: translateY(0);
  }

  /* 4. Phone Hologram size reduction for vertical fit */
  .phone-hologram {
    width: 150px;
    height: 285px;
  }

  /* 5. Floating app icons scale & adjusted position to avoid overlaps */
  .floating-app-icon {
    width: 36px;
    height: 36px;
  }
  .floating-app-icon svg {
    width: 16px;
    height: 16px;
  }
  .app-mail { top: 28%; left: 8%; }
  .app-cloud { top: 28%; right: 8%; }
  .app-cart { bottom: 28%; left: 8%; }
  .app-chat { bottom: 28%; right: 8%; }

  /* 6. Neon Shield size reduction */
  .neon-shield-svg {
    width: 90px;
    height: 90px;
  }

  /* 7. Outro Logo size reduction */
  .outro-logo-svg {
    width: 90px;
    height: 90px;
  }
  .outro-text {
    font-size: 1.8rem;
  }
  .outro-sub {
    font-size: 0.75rem;
  }
}

