/* ─── Design tokens ──────────────────────────────────────────────────────────
   Dos temas definidos desde el principio como variables CSS.
   Cualquier componente futuro reutiliza --bg y --text sin hardcodear colores.
   El atributo data-theme en <html> actúa como switch; JS solo lo cambia.
──────────────────────────────────────────────────────────────────────────── */

:root {
  --size-base: 18px;  /* tamaño de párrafo estándar */
  --scroll-t: 1;      /* fallback = estado compacto (sin JS el navbar queda funcional) */
}

:root[data-theme="light"] {
  --bg:   #EFFF00;
  --text: #1C1B1F;
}

:root[data-theme="dark"] {
  --bg:   #1C1B1F;
  --text: #EFFF00;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */

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

/* ─── Base ───────────────────────────────────────────────────────────────── */

body {
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.25s ease;
  min-height: calc(100vh + 400px); /* espacio para completar el scroll de animación */
  overflow-anchor: none; /* evita reposicionamiento automático al cambiar padding-top en JS */
  padding: 20px;
  padding-top: 20px;    /* scroll-hero.js actualiza esto dinámicamente en cada frame */
  padding-bottom: 82px; /* footer ~62px + 20px de respiro */
  font-family: "Fjalla One", sans-serif;
  
}

h1 {
  font-size: clamp(2rem, 5vw, 6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

section {
  text-align: left;
  margin: 100px 0;
}

section p {
  font-size: var(--size-base);
  line-height: 1.8;
}

p:has(.customDots) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.customDots {
  width: 0.4em;
  height: 0.4em;
  border-radius: 50%;
  background-color: var(--text);
  flex-shrink: 0;
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--text) 45%, transparent);
}

/* ─── Footer ─────────────────────────────────────────────────────────────────
   Fijo en la parte inferior, ocupa todo el ancho, space-between.
──────────────────────────────────────────────────────────────────────────── */

#site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;

  display: flex;
  justify-content: space-between;
  align-items: end;

  font-size: var(--size-base);
  color: var(--text);

  transition: color 0.25s ease;
}

#site-footer a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#site-footer a:hover {
  opacity: 0.6;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────────
   Barra fija top, ancho completo, logo izquierda / toggle derecha.
──────────────────────────────────────────────────────────────────────────── */

#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100; /* siempre por encima del contenido scrollable y del canvas p5 */
}

.logotype {
  font-family: "Jaro", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  /* Interpola de tamaño hero a tamaño navbar según --scroll-t */
  font-size: calc(25vw * (1 - var(--scroll-t)) + 2.4rem * var(--scroll-t));
  line-height: 0.75;
  /* Compensa side bearings de Jaro — ajusta si el glyph no queda alineado ópticamente */
  margin-left: -0.05em;
  color: var(--text);
  transition: color 0.25s ease;
}

/* ─── Toggle button ──────────────────────────────────────────────────────────
   Pill dentro del navbar; sin posicionamiento fijo propio.
──────────────────────────────────────────────────────────────────────────── */

#theme-toggle {
  padding: 8px 8px 8px 8px;
  gap: 6px;

  display: inline-flex;
  align-items: center;

  background-color: var(--bg) 0% 0%;
  color: var(--text);
  border: 2px solid var(--text);
  border-radius: 9999px; /* siempre pill — el ancho cambia, no la forma */
  cursor: pointer;

  font-family: inherit;
  /* Crece de hero (18px) a navbar (28px) al hacer scroll */
  font-size: calc(18px * (1 - var(--scroll-t)) + 22px * var(--scroll-t));
  line-height: 1;

  transition:
    background-color 0.2s ease,
    color 0.3s ease;
}

.toggle-label {
  margin: 0;
  padding: 0 8px;
}

#theme-toggle:hover {
  background-color: color-mix(in srgb, var(--bg) 75%, var(--text));
}

body:has(#theme-toggle:hover) {
  background-color: color-mix(in srgb, var(--bg) 75%, var(--text));
}

#theme-toggle:active {
  background-color: color-mix(in srgb, var(--text) 60%, var(--bg));
}

/* Círculo al mismo tamaño que el texto; sombra difusa del color contrario al fondo */
/* cursor: none lo gestiona el bloque Custom cursor al final del archivo */
.toggle-dot {
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background-color: var(--text);
  flex-shrink: 0;
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--text) 45%, transparent);
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* ─── Custom cursor ──────────────────────────────────────────────────────────
   Diamante pixel: cuadrado 10×10px rotado 45°, sin border-radius.
   Usa propiedades CSS individuales (translate / rotate / scale) para que
   la posición sea instantánea y solo rotate+scale tengan transición.
──────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  cursor: none !important;
}

#cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;   /* centra el elemento sobre la coordenada del ratón */
  border-radius: 0;
  background-color: var(--text);
  box-shadow:
    0 0 6px 1px color-mix(in srgb, var(--text) 70%, transparent),
    0 0 12px 2px color-mix(in srgb, var(--text) 35%, transparent);
  translate: -100px -100px; /* posición inicial fuera de pantalla, JS la actualiza */
  rotate: 45deg;
  scale: 1;
  /* translate sin transición → movimiento 1:1 sin lag */
  transition:
    rotate 0.15s ease,
    scale 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.25s ease;
  pointer-events: none;
  z-index: 9999;
}

#cursor-dot[data-cursor="hover"] {
  rotate: 0deg;
  scale: 1.4;
  box-shadow:
    0 0 8px 2px color-mix(in srgb, var(--text) 80%, transparent),
    0 0 16px 4px color-mix(in srgb, var(--text) 40%, transparent);
}

#cursor-dot[data-cursor="click"] {
  rotate: 0deg;
  scale: 0.7;
  box-shadow:
    0 0 4px 1px color-mix(in srgb, var(--text) 60%, transparent);
}

#p5-label {
  position: fixed;
  top: 0;
  left: 0;
  padding: 12px 10px;
  background: #fff;
  color: #1C1B1F;
  border-radius: 12px;
  font-size: 1rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.2s ease;
  translate: -200px -200px;
}

#p5-label.visible {
  opacity: 1;
}

/* ─── P5 Library Section ──────────────────────────────────────────────────── */

#p5Library {
  position: relative;
  height: 90vh;
  min-height: 320px;
  overflow: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center; /* título anclado al borde inferior */
  justify-content: center;
}

/* Seccion Animaciones GSAP */

.wrapper {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: -60px;
}

.container {
  width: 100%;
  padding: 12px;
  display: flex;
  gap: 8px;
  border: 2px dashed white;
  border-radius: 14px;
}

.carousel-img {
  flex: 1;
  min-width: 0;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.buttons {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.buttons button {
  padding: 10px 24px;
  background-color: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 9999px;
  font-family: inherit;
  font-size: var(--size-base);
  line-height: 1;
  min-width: 120px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.buttons button:hover {
  background-color: color-mix(in srgb, var(--text) 75%, var(--bg));
}

.hide {
  display: none;
}


/* El canvas (position:absolute, inyectado por p5) cubre toda la sección */
/* El h2 queda por encima gracias a position:relative + z-index:1        */
#p5Library h2 {
  position: relative;
  z-index: 1;
  font-size: clamp(1.4rem, 3vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  padding-bottom: 4px;
  transition: color 0.25s ease;
  pointer-events: none; /* el cursor no interfiere con la animación */
}

/* ─── Infinite Scroll ─────────────────────────────────────────────────────── */

.infinite-scroll-section {
  position: relative;
  overflow: hidden;
  /* height set by JS after measuring item line-height */
}

.scroll-list {
  list-style: none;
  position: relative;
  width: 100%;
  height: 100%;
}

.scroll-item {
  position: absolute;
  left: 0;
  right: 40px;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  font-size: var(--size-base);
  line-height: 1.6;
  color: var(--text);
  will-change: transform, opacity;
  transition: color 0.25s ease;
}

/* position:absolute hace que ::marker se renderice igualmente aunque el ul padre
   tenga list-style:none — hay que suprimirlo explícitamente en el li */
.scroll-item::marker {
  display: none;
  content: '';
}

/* ─── Scroll Indicator ────────────────────────────────────────────────────── */

.scroll-indicator {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.scroll-indicator__track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text) 25%, transparent);
  transition: background-color 0.25s ease;
}

.scroll-indicator__dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 8px 2px color-mix(in srgb, var(--text) 40%, transparent);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  will-change: transform;
}
