/* Portada de The White Riggs. Las subpaginas siguen con styles.css.
   Sin .js-motion (sin JS) todo es una lista estatica. */

:root {
  --bg: #000;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --line: rgba(255, 255, 255, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max: 1200px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --icon-radius: 22.37%;
  --header-h: 64px;
  --stage-size: min(36vw, 420px);
  --lead-size: 132px;
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body { line-height: 1.47; letter-spacing: -0.015em; overflow-x: clip; }
img { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 8px; }
#apps, #riggs { scroll-margin-top: var(--header-h); }

/* ---------- Cabecera ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: var(--header-h);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav {
  max-width: var(--max);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.2); }

.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--text-2); font-size: 14px; text-decoration: none; transition: color 0.3s; }
.nav-links a:hover { color: var(--text); }

.lang-toggle { display: flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: 600 12px/1 var(--font);
  letter-spacing: 0.04em;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}

.lang-btn.active { background: var(--text); color: #000; }

/* ---------- Escenario fijo ---------- */

.stage { display: none; }

.js-motion .stage {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Velo que protege el contraste de la columna de texto. */
.js-motion .stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.35) 45%, transparent 70%);
}

.halo {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(55% 60% at 72% 50%, rgb(var(--c1) / 0.5), rgb(var(--c2) / 0.85) 45%, #000 82%);
}

.stage-slot {
  position: absolute;
  top: 50%;
  left: calc(50% + min(24vw, 300px));
  width: var(--stage-size);
  aspect-ratio: 1;
  translate: -50% -50%;
  perspective: 1200px;
  z-index: 1;
}

.dock-on .stage-slot { visibility: hidden; }

.stage-icon {
  width: 100%;
  height: 100%;
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) scale(var(--s, 1)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
}

.stage-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateY(var(--flip, 0deg));
  transform-style: preserve-3d;
}

.stage-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--icon-radius);
  opacity: 0;
  box-shadow: 0 30px 90px -10px rgb(var(--c1) / 0.55), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.stage-face.is-shown { opacity: 1; }

.shine {
  position: absolute;
  inset: 0;
  border-radius: var(--icon-radius);
  overflow: hidden;
}

.shine::before {
  content: "";
  position: absolute;
  inset: -20% -60%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.18) 50%, transparent 58%);
  transform: translateX(calc((var(--shine, 0) * 2 - 1) * 45%));
}

/* ---------- Capas de contenido ---------- */

main, .site-footer { position: relative; z-index: 1; }

/* ---------- Hero ---------- */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: calc(var(--header-h) + 40px) 24px 112px;
  text-align: center;
  position: relative;
  /* Los iconos de la constelacion salen volando de pantalla: sin esto ensanchan el layout en movil. */
  overflow-x: clip;
}

.hero-copy { max-width: 1000px; }

.js-motion .hero-copy {
  transform: translate3d(0, calc(var(--p, 0) * -80px), 0);
  opacity: calc(1 - var(--p, 0) * 2);
}

.hero-badge {
  display: inline-block;
  margin-bottom: 28px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(44px, 8.4vw, 112px);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.hero-subtitle {
  max-width: 620px;
  margin: 24px auto 0;
  color: var(--text-2);
  font-size: clamp(17px, 2vw, 21px);
  text-wrap: pretty;
}

.word { display: inline-block; }

.js-motion .hero-title.is-revealing .word {
  animation: word-in 1.1s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms + 100ms);
}

.js-motion .hero-badge,
.js-motion .hero-subtitle {
  animation: fade-up 1.1s var(--ease) both;
  animation-delay: 0.75s;
}

@keyframes word-in {
  from { opacity: 0; filter: blur(12px); transform: translateY(0.18em); }
  to { opacity: 1; filter: blur(0); transform: none; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.constellation { position: relative; width: min(760px, 100%); height: 240px; }

.c-icon {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--size) * var(--c-scale, 1));
  aspect-ratio: 1;
  translate: -50% -50%;
}

.c-move { width: 100%; height: 100%; }

.js-motion .c-move {
  transform: translate3d(
    calc(var(--vx, 0px) * var(--p, 0) + var(--mx, 0px) * var(--depth, 1)),
    calc(var(--vy, 0px) * var(--p, 0) + var(--my, 0px) * var(--depth, 1)),
    0);
  opacity: calc(1 - var(--p, 0) * 1.6);
}

.c-icon img {
  width: 100%;
  height: 100%;
  border-radius: var(--icon-radius);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.js-motion .c-icon:not([data-lead]) img {
  animation: float 7s ease-in-out infinite;
  animation-delay: var(--phase, 0s);
}

/* El icono principal lo sustituye el del escenario, que sale exactamente de aqui. */
.js-motion .c-icon[data-lead] { visibility: hidden; }

@keyframes float {
  50% { transform: translateY(-8px); }
}

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  translate: -50% 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 28px;
  margin: 10px auto 0;
  background: linear-gradient(var(--text-3), transparent);
}

.js-motion .scroll-hint { opacity: calc(1 - var(--p, 0) * 8); }

/* ---------- Capitulos ---------- */

.chapter { padding: 72px 24px; }
.chapter-inner { max-width: var(--max); margin: 0 auto; }

.chapter-icon {
  width: 112px;
  height: 112px;
  margin-bottom: 24px;
  border-radius: var(--icon-radius);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.chapter-cat {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-name {
  margin: 10px 0 18px;
  padding-bottom: 0.08em;
  overflow: hidden;
  font-size: clamp(44px, 6.4vw, 96px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
}

.chapter-name span { display: block; }

.chapter-desc {
  max-width: 520px;
  color: var(--text-2);
  font-size: clamp(17px, 1.6vw, 21px);
  text-wrap: pretty;
}

.chapter-downloads {
  margin-top: 18px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chapter-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font: 600 15px/1 var(--font);
  text-decoration: none;
  transition: transform 0.3s var(--ease), background 0.3s;
}

.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--text); color: #000; }

.btn-glass {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.btn-glass:hover { background: rgba(255, 255, 255, 0.16); }

.js-motion .chapter {
  min-height: 120vh;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.js-motion .chapter-inner { width: 100%; }
.js-motion .chapter-inner > * { max-width: min(46vw, 540px); }
.js-motion .chapter-icon { display: none; }

.js-motion .chapter-name span {
  transform: translateY(105%);
  transition: transform 1s var(--ease);
}

.js-motion :is(.chapter-cat, .chapter-desc, .chapter-downloads, .chapter-actions) {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.js-motion :is(.chapter.is-active, .chapter:focus-within) .chapter-name span { transform: none; }

.js-motion :is(.chapter.is-active, .chapter:focus-within) :is(.chapter-cat, .chapter-desc, .chapter-downloads, .chapter-actions) {
  opacity: 1;
  transform: none;
}

.js-motion .chapter.is-active .chapter-desc { transition-delay: 0.15s; }
.js-motion .chapter.is-active .chapter-downloads { transition-delay: 0.25s; }
.js-motion .chapter.is-active .chapter-actions { transition-delay: 0.35s; }

/* ---------- Rail ---------- */

.rail { display: none; }

@media (min-width: 1024px) {
  .js-motion .rail {
    position: fixed;
    top: 50%;
    right: 24px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 10px;
    translate: 0 -50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
  }

  .js-motion.rail-on .rail { opacity: 1; pointer-events: auto; }
}

.rail button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  cursor: pointer;
  opacity: 0.35;
  transform: scale(0.82);
  transition: opacity 0.4s, transform 0.4s var(--ease);
}

.rail button img { width: 100%; height: 100%; border-radius: var(--icon-radius); }
.rail button.is-active, .rail button:hover, .rail button:focus-visible { opacity: 1; transform: none; }

/* ---------- Dock ---------- */

.dock-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 96px 24px;
  text-align: center;
  overflow-x: clip;
}

.dock-title {
  font-size: clamp(36px, 5.6vw, 72px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.js-motion .dock-title {
  opacity: calc((var(--p, 0) - 0.55) * 2.4);
  transform: translateY(calc((1 - var(--p, 0)) * 30px));
}

.dock {
  position: relative;
  display: flex;
  gap: 18px;
  padding: 16px 20px;
}

/* El cristal va en un pseudo: si la opacidad estuviera en .dock, apagaria tambien los iconos en vuelo. */
.dock::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}

.js-motion .dock::before { opacity: calc((var(--p, 0) - 0.6) * 2.5); }

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.dock-slot { display: block; width: 72px; height: 72px; }
.dock-move { display: block; width: 100%; height: 100%; }

.js-motion .dock-move {
  transform: translate3d(var(--dx, 0px), var(--dy, 0px), 0) scale(var(--ds, 1));
  opacity: var(--do, 1);
}

.dock-move img {
  width: 100%;
  height: 100%;
  border-radius: var(--icon-radius);
  transform-origin: 50% 100%;
  transition: scale 0.35s var(--ease);
}

/* Magnificacion del dock de macOS: el icono crece y los vecinos lo acompañan. */
.dock-item:hover .dock-move img,
.dock-item:focus-visible .dock-move img { scale: 1.18; }
.dock-item:hover + .dock-item .dock-move img,
.dock-item:has(+ .dock-item:hover) .dock-move img { scale: 1.07; }

.dock-label { color: var(--text-2); font-size: 12px; }
.js-motion .dock-label { opacity: calc((var(--p, 0) - 0.7) * 3.3); }

/* ---------- Riggs y pie ---------- */

.riggs { max-width: 860px; margin: 0 auto; padding: 120px 24px 140px; text-align: center; }

.riggs img {
  width: 96px;
  height: 96px;
  margin: 0 auto 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.riggs blockquote {
  color: var(--text-2);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.riggs-sign { margin-top: 24px; color: var(--text-3); font-size: 14px; }

.site-footer {
  padding: 32px 24px 48px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-3);
  font-size: 12px;
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
}

.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; }
.footer-links a { color: var(--text-2); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- Movil ---------- */

/* Pantallas de escritorio bajas: que el hero entero, con la pista de scroll, quepa sin desplazarse. */
@media (min-width: 761px) and (max-height: 960px) {
  .hero { gap: 28px; padding-top: calc(var(--header-h) + 28px); }
  .hero-badge { margin-bottom: 20px; }
  .hero-title { font-size: clamp(44px, min(7vw, 10.5vh), 112px); }
  .constellation { height: 210px; }
}

@media (max-width: 760px) {
  :root {
    --stage-size: min(52vw, 230px);
    --lead-size: 104px;
    --stage-top: calc(var(--header-h) + 3vh);
  }

  .nav { gap: 16px; padding: 0 16px; }
  .nav-links { display: none; }
  .brand { font-size: 16px; }

  .constellation { height: 190px; --c-scale: 0.7; }
  .c-icon[data-lead] { --c-scale: 1; }

  .stage-slot { top: calc(var(--stage-top) + var(--stage-size) / 2); left: 50%; }

  .halo { background: radial-gradient(85% 45% at 50% 24%, rgb(var(--c1) / 0.5), rgb(var(--c2) / 0.85) 50%, #000 88%); }

  .js-motion .stage::after { background: linear-gradient(180deg, transparent 35%, rgba(0, 0, 0, 0.55) 60%); }

  .js-motion .chapter { min-height: 65svh; padding: 0; }

  /* Los cinco textos viven fijos bajo el icono. home.js escribe --o (opacidad) y --d (distancia al
     centro del capitulo) en cada frame: el texto entra desde abajo, sube con el dedo y sale por arriba,
     y en la frontera entre apps, con el icono de canto, ambos textos estan a cero. */
  .js-motion .chapter-inner {
    position: fixed;
    top: calc(var(--stage-top) + var(--stage-size) + 28px);
    left: 20px;
    right: 20px;
    width: auto;
    opacity: var(--o, 0);
    pointer-events: none;
  }

  .js-motion .chapter.is-active .chapter-inner { pointer-events: auto; }

  .js-motion .chapter-inner > * { max-width: none; }
  .js-motion .chapter-name { overflow: visible; }

  /* Cada capa a su velocidad, mas rapida cuanto mas arriba: al salir se abren en abanico y no se pisan. */
  html.js-motion .chapter .chapter-inner :is(.chapter-cat, .chapter-desc, .chapter-downloads, .chapter-actions),
  html.js-motion .chapter .chapter-inner .chapter-name span {
    opacity: 1;
    transition: none;
  }

  html.js-motion .chapter .chapter-inner .chapter-cat { transform: translateY(calc(var(--d, 0) * -150px)); }
  html.js-motion .chapter .chapter-inner .chapter-name span { transform: translateY(calc(var(--d, 0) * -130px)); }
  html.js-motion .chapter .chapter-inner .chapter-desc { transform: translateY(calc(var(--d, 0) * -105px)); }
  html.js-motion .chapter .chapter-inner .chapter-downloads { transform: translateY(calc(var(--d, 0) * -90px)); }
  html.js-motion .chapter .chapter-inner .chapter-actions { transform: translateY(calc(var(--d, 0) * -75px)); }

  .chapter-name { font-size: clamp(40px, 12vw, 60px); }

  .dock { gap: 10px; padding: 12px 14px; }
  .dock::before { border-radius: 26px; }
  .dock-slot { width: 52px; height: 52px; }
  .dock-label { display: none; }
}

/* iPhone SE y similares: icono algo menor para que texto e indicador quepan sin pisarse. */
@media (max-width: 760px) and (max-height: 700px) {
  :root { --stage-size: min(40vw, 170px); --stage-top: calc(var(--header-h) + 2vh); }
  .chapter-name { font-size: clamp(36px, 10vw, 48px); }
  .chapter-desc { font-size: 16px; }
}
