/* ============================================================
   ClauNet — base
   Fuente única de tokens + cascarón compartido (nav, footer,
   utilidades, reveal). Lo cargan las tres páginas:
     index.html · trabajos.html · politica-de-privacidad.html
   Capas:
     base.css          tokens + cascarón (este archivo)
     home.css          secciones del home
     style.css         trabajos + legal
     cookie-consent.css
   ============================================================ */

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

/* ===== Design tokens =====
   Identidad: azul ClauNet #5aaeff → #1a6fff.
   --muted y --accent-strong ajustados para cumplir contraste
   AA (>= 4.5:1) sobre el fondo correspondiente. */
:root {
  --bg: #f5f6f8;
  --bg2: #f7f7f5;
  --border: #e8e8e8;
  --text: #111111;
  --muted: #707070;          /* 4.7:1 sobre --bg */
  --accent: #1a6fff;         /* marca — títulos grandes y detalles */
  --accent-strong: #0b5ce0;  /* 5.5:1 — acento para texto pequeño */
  --accent2: #5aaeff;
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --container: 1100px;
  --gutter: clamp(1.4rem, 5vw, 4rem);
  --section-y: clamp(4.5rem, 9vw, 7rem);
  --nav-h: 88px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --bg2: #1a1a1a;
    --border: #232323;
    --text: #f0f0f0;
    --muted: #8a8a8a;          /* 5.6:1 sobre --bg */
    --accent: #4d8fff;
    --accent-strong: #6aa3ff;  /* 7.6:1 sobre --bg */
    --accent2: #6aa3ff;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --border: #232323;
  --text: #f0f0f0;
  --muted: #8a8a8a;
  --accent: #4d8fff;
  --accent-strong: #6aa3ff;
  --accent2: #6aa3ff;
}

/* ===== Base ===== */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

img { max-width: 100%; }

/* Evita que las anclas queden tapadas por el nav sticky */
[id] { scroll-margin-top: calc(var(--nav-h) + 1rem); }

/* ===== Accesibilidad ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* El botón de tema no tiene sentido sin JS */
html:not(.js) .theme-toggle { display: none; }

/* ===== Nav ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(1rem, 3vw, 2rem);
  padding: 1.05rem var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-nav .nav-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-nav .logo-svg { height: 46px; width: auto; display: block; }
.site-nav .logo-text { fill: var(--text); }
.site-nav .logo-accent { fill: var(--accent); }
.site-nav .logo-sub { fill: var(--muted); }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.6vw, 2.2rem);
}

.nav-links a {
  position: relative;
  display: inline-block;
  padding-bottom: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

/* underline animado — microinteracción */
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after,
.nav-links a:focus-visible::after { transform: scaleX(1); }

/* ===== Theme toggle ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent2);
}

.theme-toggle svg { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ===== Utilidades compartidas ===== */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-title {
  margin-top: 0.9rem;
  font-size: clamp(1.9rem, 4.4vw, 3.1rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.section-sub {
  margin-top: 1.1rem;
  max-width: 54ch;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

.section-head { margin-bottom: clamp(2.2rem, 5vw, 3.6rem); }

/* Riel de metadata: CAÑETE / CHILE / 2026 / DIGITAL STUDIO */
.meta-rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}

.meta-rail > *:not(:last-child)::after {
  content: '/';
  margin-left: 0.9rem;
  color: var(--accent);
  opacity: 0.6;
}

/* Etiqueta de estado (LAB) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== Footer ===== */
.site-footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 3rem var(--gutter);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.6rem 2rem;
  flex-wrap: wrap;
}

.footer-brand {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 1.6rem 2rem;
  flex-wrap: wrap;
}

.footer-meta > span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.3rem;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.footer-links a:hover { color: var(--text); }

.footer-socials {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.footer-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.footer-social svg { width: 16px; height: 16px; display: block; }
.footer-social:hover { color: var(--accent-strong); }

/* ===== WhatsApp flotante =====
   Acción de contacto persistente, derivada del lenguaje del sitio:
   mismo gradiente y ángulo que el isotipo (azul ClauNet, 135°),
   radio 2px como las tarjetas de proyecto, tipografía mono para la
   etiqueta y el acento del sistema para el detalle.
   En reposo es un ícono compacto (54px); con puntero fino se expande
   al hover o al foco y revela «Hablemos». En táctil permanece
   compacto: el nombre accesible viene del aria-label del enlace. */
.wa-float {
  position: fixed;
  right: clamp(0.9rem, 3vw, 1.9rem);
  bottom: calc(clamp(0.9rem, 3vw, 1.9rem) + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease),
              visibility 0.3s var(--ease), border-color 0.25s var(--ease),
              box-shadow 0.25s var(--ease);
}

:root[data-theme="dark"] .wa-float {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

/* Se retira cuando el banner de cookies o el footer ocupan la esquina
   inferior derecha. El footer se detecta con .is-hidden (site.js). */
html:has(.cookie-banner:not(.cookie-hidden)) .wa-float,
.wa-float.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  pointer-events: none;
}

/* marca: tile geométrico con el gradiente de la identidad.
   Color de tinta = fondo (mismo criterio que .cookie-btn-accept),
   así el contraste se mantiene en claro y oscuro. */
.wa-float__mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--bg);
}

.wa-float__mark svg { width: 19px; height: 19px; display: block; }

/* etiqueta: colapsada en reposo, se despliega al hover/focus */
.wa-float__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 0;
  padding-inline: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: max-width 0.3s var(--ease), opacity 0.2s var(--ease),
              padding 0.3s var(--ease);
}

.wa-float__arrow {
  color: var(--accent-strong);
  transition: transform 0.25s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .wa-float:hover,
  .wa-float:focus-visible { border-color: var(--accent2); }

  .wa-float:hover .wa-float__label,
  .wa-float:focus-visible .wa-float__label {
    max-width: 7rem;
    padding-inline: 0.85rem 0.4rem;
    opacity: 1;
  }

  .wa-float:hover .wa-float__arrow,
  .wa-float:focus-visible .wa-float__arrow { transform: translateX(2px); }
}

/* ===== Radio flotante — placa colgante (easter egg) =====
   Acid Flashback Radio no se presenta como reproductor: es una placa
   pequeña colgada del borde inferior del nav, arriba a la derecha
   (el WhatsApp vive abajo, así nunca se cruzan). Reutiliza el idioma
   de .wa-float —borde de 1px, radio 2px, mono para la etiqueta—, y es
   un enlace: el clic abre el reproductor oficial de InternetFM en su
   propia ventana. Ningún audio sale de este sitio —la CSP de Vercel
   solo permite medios same-origin, y no se toca—, así que la placa
   nunca dice «sonando»: dice lo que hace (abrir) y dónde vive la
   radio (fuera). */
.radio-hang {
  position: fixed;
  top: 0;
  right: clamp(0.9rem, 3vw, 1.9rem);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 50% 0;   /* oscila desde el clavo, no desde el centro */
  animation: radio-swing 12s ease-in-out infinite;
}

/* cordel: arranca en el borde superior del viewport y el nav —opaco—
   lo tapa hasta su línea inferior, así la placa parece colgar de la
   barra y el punto de anclaje nunca queda a la vista */
.radio-hang::before {
  content: '';
  width: 1px;
  height: calc(var(--nav-h) + 1.15rem);
  background: var(--muted);
  opacity: 0.35;
}

/* aquí no hay <audio>: sin JS la placa sigue sirviendo, porque es un
   <a> al reproductor oficial y el navegador lo abre solo. Con JS solo
   se añade la ventana compacta y el aviso de estado. */

.radio-plate {
  position: relative;        /* ancla el «↗» de la esquina */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.5rem 0.68rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;     /* es un <a>, no un <button> */
  /* sin esto el <a> hereda el line-height 1.6 del body y la placa
     crece 6px: el <button> traía «normal» del navegador y esa caja
     es la que se conserva */
  line-height: normal;
  font-family: var(--font-mono);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.07);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
              transform 0.25s var(--ease);
}

:root[data-theme="dark"] .radio-plate {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* solo hay un estado visible a la vez y el texto es la señal:
   el color ilustra, no informa */
.radio-plate__title {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.radio-plate__title--opening,
.radio-plate__title--error { display: none; }

/* el fallo al abrir es una frase: se parte en dos líneas antes que
   ensanchar la placa */
.radio-plate__title--error {
  max-width: 9.5rem;
  font-size: 0.62rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: normal;
  color: var(--muted);
}

.radio-plate__meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* «↗» de la esquina: presente desde el reposo —muy tenue— para que el
   clic no prometa algo que no es. Se apaga cuando el texto de estado ya
   dice que la radio está fuera, y no ocupa espacio: la placa mide
   exactamente lo mismo que antes */
.radio-plate__ext {
  position: absolute;
  top: 0.28rem;
  right: 0.38rem;
  font-size: 0.5rem;
  line-height: 1;
  opacity: 0.45;
  transition: opacity 0.25s var(--ease);
}

.radio-hang.is-opening .radio-plate__ext,
.radio-hang.is-away .radio-plate__ext { opacity: 0; }

/* segunda línea: una sola frase visible, igual que el título */
.radio-plate__station--opening,
.radio-plate__station--away { display: none; }

/* ecualizador: barras planas = detenido, barras llenas = abriendo.
   El alto de la barra —no el color— comunica el estado; por eso al
   abrir también se fija scaleY(1), que sobrevive a la regla de
   animaciones reducidas */
.radio-plate__eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.radio-plate__bar {
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--accent-strong);
  opacity: 0.35;
  transform: scaleY(0.16);
  transform-origin: bottom;
  transition: opacity 0.25s var(--ease);
}

@keyframes radio-eq {
  0%, 100% { transform: scaleY(0.25); }
  50%      { transform: scaleY(1); }
}

/* colgado: oscilación apenas perceptible sobre el clavo */
@keyframes radio-swing {
  0%, 100% { transform: rotate(-1.1deg); }
  50%      { transform: rotate(-0.25deg); }
}

.radio-hang.is-opening .radio-plate__title--opening,
.radio-hang.is-away .radio-plate__title--opening,
.radio-hang.is-error .radio-plate__title--error { display: inline; }

.radio-hang.is-opening .radio-plate__title--idle,
.radio-hang.is-away .radio-plate__title--idle,
.radio-hang.is-error .radio-plate__title--idle { display: none; }

.radio-hang.is-opening .radio-plate__station--opening,
.radio-hang.is-away .radio-plate__station--away { display: inline; }

.radio-hang.is-opening .radio-plate__station--idle,
.radio-hang.is-away .radio-plate__station--idle { display: none; }

/* abriendo: las barras pulsan mientras la ventana carga el player.
   Es lo único que se mueve, y dura lo que dura el aviso */
.radio-hang.is-opening .radio-plate__bar {
  opacity: 1;
  transform: scaleY(1);
  animation: radio-eq 1.05s ease-in-out infinite;
}

.radio-hang.is-opening .radio-plate__bar:nth-child(2) { animation-duration: 0.8s; }
.radio-hang.is-opening .radio-plate__bar:nth-child(3) { animation-duration: 1.35s; }

/* mientras abre, la placa se mece un poco más rápido. En reposo y en
   «radio externa» las barras quedan planas: aquí no suena nada */
.radio-hang.is-opening { animation-duration: 7s; }

/* no se pudo abrir: borde discontinuo, como etiqueta descolgada */
.radio-hang.is-error .radio-plate { border-style: dashed; }

.radio-plate:active { transform: translateY(2px); }
.radio-plate:focus-visible { border-color: var(--accent2); }

@media (hover: hover) and (pointer: fine) {
  .radio-plate:hover {
    border-color: var(--accent2);
    box-shadow: 0 11px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(1px);
  }

  :root[data-theme="dark"] .radio-plate:hover {
    box-shadow: 0 11px 24px rgba(0, 0, 0, 0.5);
  }
}

/* tablet: placa algo más corta, cordel algo más corto */
@media (max-width: 900px) {
  .radio-hang::before { height: calc(var(--nav-h) + 0.9rem); }

  .radio-plate {
    gap: 0.26rem;
    padding: 0.46rem 0.6rem;
  }

  .radio-plate__title { font-size: 0.66rem; }
  .radio-plate__meta { font-size: 0.54rem; letter-spacing: 0.12em; }
  .radio-plate__eq { height: 9px; }
}

/* móvil: la placa se acerca al nav (para no tapar contenido) y crece
   un poco en alto para seguir siendo cómoda de tocar; sin hover como
   único mecanismo, el toque siempre funciona */
@media (max-width: 620px) {
  .radio-hang::before { height: calc(var(--nav-h) + 0.8rem); }

  .radio-plate {
    gap: 0.24rem;
    padding: 0.5rem 0.52rem;   /* alto final ≈45px: área táctil cómoda */
  }

  .radio-plate__title { font-size: 0.58rem; letter-spacing: 0.04em; }
  .radio-plate__meta { font-size: 0.46rem; letter-spacing: 0.09em; gap: 0.3rem; }
  .radio-plate__eq { height: 8px; }
  .radio-plate__title--error { max-width: 7.8rem; font-size: 0.54rem; }
}

/* ===== Reveal on scroll =====
   El retardo se controla con --reveal-delay en cada elemento,
   en lugar de nth-child, para que sobreviva a reordenamientos. */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  transition-delay: var(--reveal-delay, 0s);
}

.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* ===== prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

/* ===== Nav / footer — responsive ===== */
@media (max-width: 620px) {
  .site-nav {
    flex-wrap: wrap;
    row-gap: 0.55rem;
    padding: 0.8rem var(--gutter) 0.7rem;
  }

  .site-nav .logo-svg { height: 34px; }

  /* composición móvil: logo + toggle arriba, links en su propia fila */
  .nav-links {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .nav-links a {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 2.4rem var(--gutter);
  }

  .footer-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

@media (max-width: 380px) {
  .nav-links a {
    font-size: 0.56rem;
    letter-spacing: 0.06em;
  }
}
