/* ==========================================================================
   Low Key — hoja de estilos
   Réplica del sitio "Lowkey" (teclado mecánico low‑profile).
   Paleta: negro azulado / grafito / blanco / ámbar / bokeh azul.
   Tipografía: Manrope 400 (titulares y cuerpo) + DM Mono (overlines, labels).
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #06080c;
  --graphite: #1b1d22;
  --white: #f2f2f2;
  --amber: #f0a53a;
  --amber-deep: #a8661a;
  --amber-hi: #f5b954;
  --amber-lo: #d98d2a;
  --bokeh: #8fb6ff;
  --muted: rgba(242, 242, 242, 0.62);
  --line: rgba(242, 242, 242, 0.14);
  --card: rgba(12, 14, 19, 0.7);

  --font-sans: 'Manrope', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.7s;

  --side: 4vw; /* margen lateral de la referencia */
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body {
  margin: 0;
  overflow-x: hidden;
}
h1,
h2,
h3,
p,
ul {
  margin: 0;
}
h1,
h2,
h3 {
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}
main {
  position: relative;
  z-index: 2;
}

/* Tipos utilitarios */
.overline,
.mono-label,
.callout-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.overline {
  color: var(--muted);
}
.mono-label {
  color: var(--muted);
  font-size: 9.5px;
}
.body-sm {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.lede {
  font-size: 15px;
  color: rgba(242, 242, 242, 0.85);
}

/* ---------- Escenario fijo (foto + canvas) ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg);
}
.stage-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}
/* Difumina el teclado que trae la foto para que el modelo 3D lo reemplace:
   una copia de la foto, alineada con la de fondo, recortada a la zona del
   teclado, desenfocada y oscurecida, con máscara radial para fundir los bordes */
.stage-smudge {
  position: absolute;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent),
    linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent),
    linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
  pointer-events: none;
}
.stage-smudge img {
  position: absolute;
  max-width: none;
  filter: blur(30px) brightness(0.42) saturate(0.85);
}
.no-webgl .stage-smudge,
.no-webgl .stage-canvas {
  display: none;
}
.stage-dark {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0;
}
.stage-lamp {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 34% 42% at 94% 8%, rgba(240, 165, 58, 0.55), rgba(240, 165, 58, 0.12) 45%, transparent 75%);
  mix-blend-mode: screen;
  opacity: 0.85;
}
.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Partículas de polvo iluminadas (CSS, lentas) */
.dust {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.dust i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 190, 0.95), rgba(255, 210, 150, 0) 70%);
  filter: blur(0.6px);
  opacity: 0;
  animation: dust-float var(--d, 14s) linear infinite;
  animation-delay: var(--delay, 0s);
  left: var(--x);
  top: var(--y);
  transform: scale(var(--s, 1));
}
@keyframes dust-float {
  0% {
    transform: translate(0, 0) scale(var(--s, 1));
    opacity: 0;
  }
  15% {
    opacity: 0.9;
  }
  85% {
    opacity: 0.7;
  }
  100% {
    transform: translate(var(--dx, 30px), var(--dy, -80px)) scale(var(--s, 1));
    opacity: 0;
  }
}

/* ---------- Header: badge keycap "LK" ---------- */
.header {
  position: fixed;
  left: 2vw;
  top: 6vh;
  z-index: 20;
}
.badge,
.snd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(#2a2d33, #1b1d22);
  border: 1px solid rgba(242, 242, 242, 0.18);
  box-shadow: 0 3px 0 #0d0e11, 0 8px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--white);
}
.snd {
  position: fixed;
  right: 2vw;
  bottom: 4vh;
  z-index: 20;
  width: 46px;
  height: 46px;
  flex-direction: column;
  gap: 1px;
  font-size: 9px;
  line-height: 1.1;
  padding: 0;
}
.snd .snd-state {
  color: var(--muted);
}
.snd[aria-pressed='true'] .snd-state {
  color: var(--amber);
}
.snd:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0d0e11, 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* ---------- 1. Hero ---------- */
.hero {
  position: relative;
  height: 100vh;
}
.hero-copy {
  position: absolute;
  left: var(--side);
  top: 14vh;
  width: 31vw;
  min-width: 300px;
}
.hero-copy .overline {
  margin-bottom: 1.6vh;
}
.hero h1 {
  font-size: clamp(44px, 5.55vw, 80px);
  margin-bottom: 3vh;
}
.hero .lede {
  max-width: 34ch;
  margin-bottom: 4.5vh;
}
.hero .mono-label {
  display: block;
  margin-bottom: 1.4vh;
}
.type-input {
  display: block;
  width: min(100%, 300px);
  height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(6, 8, 12, 0.55);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 13px;
  backdrop-filter: blur(6px);
  margin-bottom: 4.5vh;
}
.type-input::placeholder {
  color: rgba(242, 242, 242, 0.4);
}
.type-input:focus {
  border-color: rgba(240, 165, 58, 0.6);
  outline: none;
}
.btn-light {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 22px;
  border-radius: 10px;
  background: var(--white);
  color: #0b0d12;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.btn-light:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* ---------- Secciones "pinned" ----------
   Línea de tiempo en vh (scrollY / alto de viewport):
   hero 0–100 · desk 100–300 · side 300–500 · open 500–650 · explode 650–950 ·
   finishes 950–1250 · closing 1250–1400. Los keyframes de scene.js usan la misma escala. */
.pin {
  position: relative;
  height: 200vh;
}
.pin-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.open {
  height: 150vh;
}
.explode,
.finishes {
  height: 300vh;
}

/* Captions: entran con fade + leve translate y salen con fade (por --p de la sección) */
.caption {
  opacity: clamp(0, min(calc((var(--p, 0) - 0.05) * 8), calc((1 - var(--p, 0)) * 7)), 1);
  transform: translateY(calc(clamp(0, calc(1 - (var(--p, 0) - 0.05) * 8), 1) * 14px));
}

/* ---------- 2. El escritorio que tenés ---------- */
.desk-copy {
  position: absolute;
  left: 62vw;
  right: 5vw;
  top: 55vh;
}
.desk-copy .overline {
  margin-bottom: 1.4vh;
}
.desk-copy h2 {
  font-size: clamp(28px, 2.8vw, 40px);
  min-height: 3.15em;
  margin-bottom: 2.4vh;
}
.desk-copy .body-sm {
  max-width: 46ch;
}
.tw-caret {
  display: inline-block;
  width: 0.06em;
  height: 0.95em;
  margin-left: 0.08em;
  vertical-align: -0.08em;
  background: var(--amber);
  animation: caret 0.9s steps(2) infinite;
}
.typewriter.done .tw-caret {
  display: none;
}
@keyframes caret {
  to {
    opacity: 0;
  }
}

/* ---------- 3. Desde el costado ---------- */
.side-copy {
  position: absolute;
  left: var(--side);
  top: 30vh;
  width: 34vw;
  min-width: 300px;
}
.side-copy .overline {
  margin-bottom: 1.4vh;
}
.side-copy h2 {
  font-size: clamp(28px, 2.8vw, 40px);
  margin-bottom: 2.4vh;
}
.side-copy .body-sm {
  max-width: 44ch;
}

/* ---------- 4. Ahora abrilo. ---------- */
.open-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: 26vh;
  text-align: center;
  font-size: 24px;
  letter-spacing: -0.01em;
}

/* ---------- 5. Vista explotada ---------- */
.callout-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.callout-lines line {
  stroke: rgba(240, 165, 58, 0.55);
  stroke-width: 1;
}
.callout-lines circle {
  fill: var(--amber);
}
.callout-lines line,
.callout-lines circle {
  opacity: clamp(0, calc((var(--d, 0) - 0.22 - var(--i) * 0.11) * 6), 1);
}
.callouts {
  list-style: none;
  padding: 0;
  position: absolute;
  inset: 0;
}
.callout {
  position: absolute;
  width: 280px;
  padding: 14px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* aparición escalonada: cada callout arranca 0,11 más tarde en la explosión */
  opacity: clamp(0, calc((var(--d, 0) - 0.22 - var(--i) * 0.11) * 6), 1);
  transform: translateY(calc((1 - clamp(0, calc((var(--d, 0) - 0.22 - var(--i) * 0.11) * 6), 1)) * 12px));
}
.callout-label {
  display: block;
  color: var(--amber);
  margin-bottom: 6px;
}
.callout p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--white);
}
.callout[data-layer='keycaps'] {
  left: var(--side);
  top: 16vh;
}
.callout[data-layer='switches'] {
  left: var(--side);
  top: 40vh;
}
.callout[data-layer='plate'] {
  left: var(--side);
  top: 64vh;
}
.callout[data-layer='board'] {
  right: var(--side);
  top: 30vh;
}
.callout[data-layer='case'] {
  right: var(--side);
  top: 58vh;
}
.explode-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5vh;
  text-align: center;
  opacity: clamp(0, calc((var(--d, 0) - 0.75) * 5), 1);
}

/* ---------- 6. Acabados (fila horizontal) ---------- */
.finishes {
  background: var(--bg);
}
.finishes .pin-inner {
  display: flex;
  align-items: center;
}
.finish-track {
  display: flex;
  align-items: center;
  gap: 3vw;
  padding-left: 5vw;
  width: max-content;
  /* el titular sale por la izquierda y las tarjetas recorren ≈100 % del ancho */
  transform: translateX(calc(var(--p, 0) * (100vw - 100%)));
  will-change: transform;
}
.finish-title {
  flex: 0 0 auto;
  width: 36vw;
  font-size: clamp(30px, 2.9vw, 42px);
}
.finish-card {
  flex: 0 0 auto;
  width: 30vw;
  min-width: 300px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b0d12;
  padding: 0 0 22px;
  overflow: hidden;
}
.finish-img {
  aspect-ratio: 720 / 460;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, #171a21, #0b0d12 80%);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.finish-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.finish-card h3 {
  font-size: 18px;
  font-weight: 500;
  padding: 18px 22px 4px;
}
.finish-card p {
  font-size: 13px;
  color: var(--muted);
  padding: 0 22px;
}
.finish-note {
  flex: 0 0 auto;
  width: 30vw;
  min-width: 260px;
  padding-right: 6vw;
}

/* ---------- 7. Cierre ---------- */
.closing {
  position: relative;
  height: 150vh;
}
.closing-copy {
  position: absolute;
  top: 50vh;
  left: 0;
  right: 0;
  height: 100vh;
  padding-top: 14vh;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.closing h2 {
  font-size: clamp(32px, 3.05vw, 44px);
  margin-bottom: 2vh;
}
.closing .body-sm {
  max-width: 48ch;
  margin-bottom: 4vh;
}
.keycap-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 168px;
  padding: 14px 16px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(var(--amber-hi), var(--amber-lo));
  color: #2a1704;
  box-shadow: 0 6px 0 var(--amber-deep), 0 10px 30px rgba(240, 165, 58, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}
.keycap-btn .keycap-legend {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.keycap-btn .keycap-text {
  font-size: 15px;
  font-weight: 500;
}
.keycap-btn:hover {
  box-shadow: 0 6px 0 var(--amber-deep), 0 14px 40px rgba(240, 165, 58, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.keycap-btn:active,
.keycap-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--amber-deep), 0 6px 18px rgba(240, 165, 58, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.closing-note {
  margin-top: 4vh;
  font-size: 12px;
  color: var(--muted);
  max-width: 52ch;
}
.collection {
  margin-top: 3vh;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(242, 242, 242, 0.4);
  text-decoration: none;
}
.collection:hover {
  color: var(--amber);
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .hero-copy {
    width: 44vw;
  }
  .desk-copy {
    left: 50vw;
  }
  .callout {
    width: 230px;
  }
}
@media (max-width: 720px) {
  :root {
    --side: 6vw;
  }
  .hero-copy {
    top: 11vh;
    width: 88vw;
    min-width: 0;
  }
  .hero h1 {
    font-size: clamp(38px, 11vw, 46px);
    margin-bottom: 2vh;
  }
  .hero .lede {
    font-size: 14px;
    margin-bottom: 2.5vh;
  }
  .type-input {
    margin-bottom: 2.5vh;
  }
  .desk-copy {
    left: var(--side);
    right: var(--side);
    top: 56vh;
  }
  .desk-copy h2 {
    font-size: 26px;
  }
  .side-copy {
    width: 88vw;
    min-width: 0;
    top: 16vh;
  }
  .side-copy h2 {
    font-size: 28px;
  }
  .open-caption {
    top: 20vh;
  }
  .callout-lines {
    display: none;
  }
  .callouts {
    inset: auto var(--side) 12vh var(--side);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .callout,
  .callout[data-layer] {
    position: static;
    width: auto;
    padding: 10px 12px;
  }
  .callout p {
    font-size: 11px;
  }
  .explode-foot {
    bottom: 3vh;
    padding: 0 72px 0 var(--side);
    text-align: left;
  }
  .finish-track {
    gap: 5vw;
    padding-left: var(--side);
  }
  .finish-title {
    width: 80vw;
    font-size: 30px;
  }
  .finish-card {
    width: 78vw;
    min-width: 0;
  }
  .finish-note {
    width: 70vw;
    min-width: 0;
    padding-right: var(--side);
  }
  .closing-copy {
    padding: 12vh var(--side) 0;
  }
  .closing h2 {
    font-size: 32px;
  }
}

/* ---------- Reduced motion: todo visible y quieto ---------- */
@media (prefers-reduced-motion: reduce) {
  .dust i,
  .tw-caret {
    animation: none;
  }
  .caption,
  .callout,
  .callout-lines line,
  .callout-lines circle,
  .explode-foot {
    opacity: 1;
    transform: none;
  }
  .btn-light,
  .keycap-btn {
    transition: none;
  }
}
