/* =========================================================
   1. RESET Y ESTILOS GENERALES
   ========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  min-height: 100svh;
  overflow: hidden;

  font-family: Arial, Helvetica, sans-serif;
  color: white;

  background-image: url("../images/backgrounds/fondoCuantico.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* =========================================================
   2. ESTRUCTURA PRINCIPAL DEL PORTAL
   ========================================================= */

.portal {
  min-height: 100svh;

  display: grid;

  grid-template-rows:
    auto
    1fr
    auto;

  padding: clamp(20px, 3vw, 40px) clamp(18px, 4vw, 60px);
}

/* =========================================================
   3. CABECERA
   Logo · tagline · introducción
   ========================================================= */

.portal__header {
  text-align: center;
}

.portal__title {
  margin: 0;

  display: flex;
  justify-content: center;
  align-items: center;
}

.portal__logo {
  display: block;

  width: clamp(260px, 32vw, 480px);
  height: auto;

  margin: 0 auto;
}

.portal__tagline {
  margin-top: 6px;

  font-size: clamp(12px, 1.25vw, 17px);
  letter-spacing: 0.4em;
}

.portal__intro {
  margin: clamp(14px, 2vw, 24px) auto 0;

  max-width: 720px;

  font-size: clamp(12px, 1.15vw, 16px);
  line-height: 1.5;

  color: rgba(110, 230, 255, 0.9);
}

/* =========================================================
   4. CAMPO DE APLICACIONES
   Espacio en el que se distribuyen las badges.
   Más adelante será la zona de flotación y colisiones.
   ========================================================= */

.portal__apps {
  position: relative;

  width: 100%;
  min-height: clamp(320px, 42vh, 520px);
}

/* Posición y tamaño base de cada aplicación */

.portal__app {
  cursor: pointer;
  position: absolute;

  width: clamp(100px, 13vw, 180px);

  display: flex;
  align-items: center;
  justify-content: center;

  transform: translate(-50%, -50%);
}

/* Posiciones iniciales de las cuatro aplicaciones */

.portal__app:nth-child(1) {
  left: 20%;
  top: 38%;
}

.portal__app:nth-child(2) {
  left: 40%;
  top: 62%;
}

.portal__app:nth-child(3) {
  left: 62%;
  top: 36%;
}

.portal__app:nth-child(4) {
  left: 80%;
  top: 60%;
}

/* =========================================================
   5. BADGES
   Aspecto general de las imágenes de las aplicaciones.
   ========================================================= */

.portal__app img {
  display: block;

  width: 100%;
  height: auto;

  object-fit: contain;

  filter: drop-shadow(0 0 18px rgba(100, 200, 255, 0.18))
    drop-shadow(0 0 35px rgba(120, 60, 255, 0.12));
}

/* =========================================================
   6. POMPAS CUÁNTICAS

   Cada aplicación está contenida dentro de una pompa
   transparente formada por varias capas:

   .portal__app
       → membrana transparente de la pompa

   ::before
       → filamento exterior cálido (naranja/dorado)

   ::after
       → filamento interior frío (cian/violeta)

   img
       → badge / núcleo de la aplicación
   ========================================================= */

/* ---------------------------------------------------------
   6.1. Membrana transparente
   --------------------------------------------------------- */

.portal__app {
  width: clamp(220px, 18vw, 270px);
  aspect-ratio: 1;

  border-radius: 43% 57% 48% 52% / 55% 44% 56% 45%;

  background:
    radial-gradient(
      circle at 28% 24%,
      rgba(255, 255, 255, 0.18),
      rgba(255, 255, 255, 0.04) 24%,
      transparent 58%
    ),
    radial-gradient(
      circle at 72% 70%,
      rgba(80, 210, 255, 0.1),
      transparent 52%
    ),
    radial-gradient(
      circle at 58% 40%,
      rgba(200, 100, 255, 0.08),
      transparent 55%
    );

  border: 1px solid rgba(255, 255, 255, 0.2);

  box-shadow:
    inset 12px -8px 30px rgba(120, 80, 255, 0.08),
    inset -10px 10px 28px rgba(80, 220, 255, 0.08),
    0 0 20px rgba(100, 220, 255, 0.1),
    0 0 36px rgba(190, 90, 255, 0.08);

  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);

  isolation: isolate;
}

/* ---------------------------------------------------------
   6.2. Filamento exterior cálido
   Halo irregular naranja/dorado situado junto a la membrana.
   --------------------------------------------------------- */

.portal__app::before {
  content: "";

  position: absolute;
  inset: -5%;

  border-radius: 43% 57% 48% 52% / 55% 44% 56% 45%;

  border: 2px solid rgba(255, 185, 75, 0.9);

  box-shadow:
    0 0 4px rgba(255, 185, 75, 0.9),
    0 0 10px rgba(255, 140, 40, 0.55),
    inset 0 0 5px rgba(255, 210, 120, 0.45);

  transform: rotate(-7deg) scaleX(1.05) scaleY(0.97);

  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------
   6.3. Filamento interior frío
   Segundo halo irregular cian/violeta.
   Su forma y orientación no coinciden con el filamento cálido.
   --------------------------------------------------------- */

.portal__app::after {
  content: "";

  position: absolute;
  inset: -2%;

  border-radius: 55% 45% 51% 49% / 46% 57% 43% 54%;

  border: 1.5px solid rgba(105, 220, 255, 0.85);

  box-shadow:
    0 0 4px rgba(80, 220, 255, 0.8),
    0 0 9px rgba(160, 90, 255, 0.55),
    inset 0 0 4px rgba(210, 120, 255, 0.4);

  transform: rotate(11deg) scaleX(0.97) scaleY(1.04);

  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------
   6.4. Núcleo de la pompa
   La badge permanece por encima de membrana y filamentos.
   --------------------------------------------------------- */

.portal__app img {
  width: 62%;

  position: relative;
  z-index: 3;
}

/* ---------------------------------------------------------
   6.5. Respiración de las pompas
   --------------------------------------------------------- */

/* Knowledge */
.portal__app:nth-child(1),
.portal__app:nth-child(1)::before,
.portal__app:nth-child(1)::after {
  animation: quantumBreath 5s ease-in-out infinite alternate;
  animation-delay: -1.3s;
}

/* English & CLIL */
.portal__app:nth-child(2),
.portal__app:nth-child(2)::before,
.portal__app:nth-child(2)::after {
  animation: quantumBreath 6.4s ease-in-out infinite alternate;
  animation-delay: -3.7s;
}

/* ListeningWeb */
.portal__app:nth-child(3),
.portal__app:nth-child(3)::before,
.portal__app:nth-child(3)::after {
  animation: quantumBreath 4.6s ease-in-out infinite alternate;
  animation-delay: -2.1s;
}

/* Other Links */
.portal__app:nth-child(4),
.portal__app:nth-child(4)::before,
.portal__app:nth-child(4)::after {
  animation: quantumBreath 7.2s ease-in-out infinite alternate;
  animation-delay: -5.4s;
}

@keyframes quantumBreath {
  0% {
    border-radius: 35% 65% 42% 58% / 62% 38% 66% 34%;
  }

  50% {
    border-radius: 58% 42% 65% 35% / 38% 64% 36% 62%;
  }

  100% {
    border-radius: 44% 56% 34% 66% / 68% 35% 65% 32%;
  }
}

/* ---------------------------------------------------------
   6.6. Estallido cuántico
   --------------------------------------------------------- */

/* Durante la ruptura dejamos de "respirar" */

.portal__app.is-bursting,
.portal__app.is-bursting::before,
.portal__app.is-bursting::after {
  animation: none;
}

/* La membrana desaparece rápidamente */

.portal__app.is-bursting {
  background: transparent;
  border-color: transparent;
  box-shadow: none;

  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Los filamentos desaparecen al romperse */

.portal__app.is-bursting::before,
.portal__app.is-bursting::after {
  opacity: 0;
}

/* Fragmentos creados dinámicamente por JavaScript */

.quantum-shard {
  position: absolute;

  left: 50%;
  top: 50%;

  width: var(--shard-width);
  height: var(--shard-height);

  background: var(--shard-color);

  clip-path: polygon(50% 0%, 100% 35%, 72% 100%, 12% 76%, 0% 25%);

  box-shadow:
    0 0 5px currentColor,
    0 0 12px currentColor;

  pointer-events: none;

  z-index: 5;

  animation: quantumShardBurst var(--duration) ease-out forwards;
}

@keyframes quantumShardBurst {
  0% {
    opacity: 1;

    transform: translate(-50%, -50%) translate(var(--start-x), var(--start-y))
      rotate(0deg) scale(1);
  }

  100% {
    opacity: 0;

    transform: translate(-50%, -50%) translate(var(--end-x), var(--end-y))
      rotate(var(--rotation)) scale(0.35);
  }
}

/* ---------------------------------------------------------
   6.7. Botón para cerrar la aplicación liberada
   --------------------------------------------------------- */

.quantum-close {
  position: absolute;

  top: 4%;
  right: 4%;

  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(120, 230, 255, 0.8);
  border-radius: 50%;

  background: rgba(10, 15, 35, 0.72);

  color: rgba(255, 255, 255, 0.95);

  font-size: 22px;
  line-height: 1;

  box-shadow:
    0 0 8px rgba(120, 230, 255, 0.55),
    0 0 16px rgba(190, 110, 255, 0.3);

  cursor: pointer;

  z-index: 10;

  opacity: 0;

  animation: quantumCloseAppear 0.35s ease-out forwards;
}

/* Aparición suave de la cruz */

@keyframes quantumCloseAppear {
  from {
    opacity: 0;
    transform: scale(0.4);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* =========================================================
   7. LIBERACIÓN DE UNA APLICACIÓN
   ========================================================= */

.portal__app.is-released {
  animation: none;

  background: transparent;
  border-color: transparent;
  box-shadow: none;

  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.portal__app.is-released::before,
.portal__app.is-released::after {
  display: none;
}

/* =========================================================
   8. INDICACIÓN INFERIOR
   Ratón y texto de ayuda.
   ========================================================= */

.portal__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;

  max-width: 620px;
  margin: 0 auto;

  color: rgba(255, 255, 255, 0.82);
}

.portal__hint p {
  margin: 0;

  font-size: clamp(13px, 1.2vw, 18px);
  line-height: 1.45;

  text-align: left;
}

/* Ratón dibujado únicamente con CSS */

.portal__mouse {
  position: relative;
  flex: 0 0 auto;

  width: 34px;
  height: 52px;

  border: 2px solid rgba(112, 225, 255, 0.95);
  border-radius: 18px;

  box-shadow:
    0 0 8px rgba(70, 210, 255, 0.35),
    inset 0 0 8px rgba(70, 210, 255, 0.12);
}

/* Línea superior del ratón */

.portal__mouse::before {
  content: "";

  position: absolute;
  top: -9px;
  left: 50%;

  width: 2px;
  height: 16px;

  background: rgba(112, 225, 255, 0.95);

  transform: translateX(-50%);
}

/* Rueda del ratón */

.portal__mouse-wheel {
  position: absolute;

  top: 10px;
  left: 50%;

  width: 3px;
  height: 9px;

  border-radius: 3px;

  background: rgba(255, 255, 255, 0.95);

  transform: translateX(-50%);
}

/* =========================================================
   9. RESPONSIVE — TABLET
   ========================================================= */

@media (max-width: 900px) {
  .portal__app {
    width: clamp(150px, 28vw, 260px);
  }
}

/* =========================================================
   10. RESPONSIVE — MÓVIL
   ========================================================= */

@media (max-width: 600px) {
  body {
    overflow-y: auto;
  }

  .portal {
    grid-template-rows:
      auto
      auto
      auto;

    gap: 24px;
  }

  .portal__app {
    width: min(72vw, 280px);
  }

  .portal__tagline {
    letter-spacing: 0.18em;
  }
}
