/* MATERIA · versión scroll
   Una escena 3D fija (canvas) y secciones HTML que se fijan (sticky) mientras
   el scroll avanza. Cada sección es "alta" para que el scroll tenga recorrido. */

:root {
  color-scheme: dark;
  --void: #06070b;
  --ink: #0e1017;
  --panel: rgba(14, 16, 23, 0.7);
  --line: rgba(236, 233, 225, 0.16);
  --bone: #ece9e1;
  --muted: #9aa0b0;
  --ion: #c8ff3d;
  --cobalt: #4c5bff;
  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pad: clamp(20px, 4.5vw, 64px);
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; background: var(--void); }
html.is-loading, html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--void);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
.mono:empty { display: none; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ion); outline-offset: 3px; }
::selection { background: var(--ion); color: var(--void); }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
main { position: relative; z-index: 10; }

/* ---------- Barra superior y progreso ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 28px var(--pad);
  font-family: var(--mono); font-size: 13px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.logo { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 0; cursor: pointer; letter-spacing: 0.08em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ion); }
.nav { display: flex; gap: 32px; }
.nav button { background: none; border: 0; padding: 6px 0; cursor: pointer; color: var(--bone); transition: color .2s; }
.nav button:hover, .nav button.is-active { color: var(--ion); }
.idx { color: var(--muted); }
.lang { color: var(--muted); }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 31; background: transparent; }
.progress i { display: block; height: 100%; background: var(--ion); transform: scaleX(0); transform-origin: 0 50%; }

/* ---------- Secciones altas con contenido fijo ---------- */
.pin { position: relative; }
.sticky {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  padding: 120px var(--pad) 110px;
  display: flex; flex-direction: column; gap: 18px;
}
.sticky.hero { justify-content: flex-end; gap: 26px; }
.sticky.center { justify-content: center; }

[data-in] { opacity: 0; }

.eyebrow { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ion); }
.display { margin: 0; font-size: clamp(44px, 7vw, 96px); line-height: 0.98; font-weight: 500; letter-spacing: -0.03em; max-width: min(840px, 100%); text-wrap: balance; }
.display.sm { font-size: clamp(36px, 5.5vw, 72px); }
.title { margin: 0; font-size: clamp(30px, 4.2vw, 56px); line-height: 1.02; font-weight: 500; letter-spacing: -0.02em; }
.lead { margin: 0; max-width: 520px; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.55; color: #b9bdca; }
.lead:empty { display: none; }
.hint { margin: 0; display: flex; align-items: center; gap: 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hint .line { display: block; width: 44px; height: 1px; background: var(--ion); transform-origin: 0 50%; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scaleX(0.3); } 50% { transform: scaleX(1); } }
.mono { font-family: var(--mono); font-size: 12px; margin: 0; }
.muted { color: var(--muted); }
.word { display: inline-block; white-space: nowrap; }
.ch { display: inline-block; will-change: transform, opacity; }

/* ---------- Manifiesto ---------- */
.statement { margin: 0; max-width: 1100px; font-size: clamp(28px, 4.8vw, 70px); line-height: 1.12; font-weight: 500; letter-spacing: -0.03em; text-wrap: balance; }
.statement .w { opacity: 0.14; }

/* ---------- Botones ---------- */
.btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 22px;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
  color: var(--ion); background: transparent;
  border: 1px solid var(--ion); border-radius: 999px; cursor: pointer;
  transition: background .2s, color .2s, opacity .2s;
}
.btn:hover:not(:disabled) { background: var(--ion); color: var(--void); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.ghost { color: var(--bone); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--bone); color: var(--void); }

/* ---------- Proyectos: galería horizontal ---------- */
.sticky.proj { padding: 0; }
.track { display: flex; align-items: center; gap: clamp(16px, 2.5vw, 32px); height: 100%; width: max-content; padding: 96px var(--pad) 84px; will-change: transform; }
.slide-intro { flex: none; width: min(80vw, 480px); display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.card {
  flex: none; width: min(78vw, 500px); height: min(64vh, 520px);
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; padding: 22px; text-align: left;
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 18px;
  transition: border-color .25s, background .25s;
}
button.card { cursor: pointer; }
button.card:hover { border-color: var(--ion); background: rgba(20, 24, 34, 0.9); }
.card.is-empty { background: transparent; border-style: dashed; color: var(--muted); backdrop-filter: none; -webkit-backdrop-filter: none; }
.card .idx-big { font-size: clamp(64px, 9vw, 132px); line-height: 0.9; font-weight: 500; letter-spacing: -0.04em; color: transparent; -webkit-text-stroke: 1px rgba(236, 233, 225, 0.35); transition: color .3s; }
button.card:hover .idx-big { color: var(--ion); -webkit-text-stroke-color: var(--ion); }
.card .bottom { display: flex; flex-direction: column; gap: 10px; }
.card .num { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.card .t { font-size: clamp(26px, 3vw, 38px); font-weight: 500; letter-spacing: -0.02em; }
.hprogress { position: absolute; left: var(--pad); right: var(--pad); bottom: 44px; height: 2px; background: rgba(236, 233, 225, 0.14); }
.hprogress i { display: block; height: 100%; background: var(--ion); transform: scaleX(0); transform-origin: 0 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chips:empty { display: none; }
.chips li { font-family: var(--mono); font-size: 11px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: #b9bdca; }

/* ---------- Sobre mí ---------- */
.about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: clamp(24px, 5vw, 72px); align-items: center; width: 100%; max-width: 1180px; }
.about-text { display: flex; flex-direction: column; gap: 18px; }
.skill-now { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.skill-name { display: block; font-size: clamp(40px, 6vw, 84px); line-height: 1; font-weight: 500; letter-spacing: -0.03em; color: var(--ion); min-height: 1em; }
.periodic { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile {
  position: relative; aspect-ratio: 1 / 1.05;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .25s, background .25s;
}
.tile.is-on { border-color: var(--ion); background: rgba(200, 255, 61, 0.12); }
.tile .n { position: absolute; left: 8px; top: 6px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tile .s { font-size: clamp(24px, 3vw, 34px); font-weight: 500; color: var(--ion); }
.tile .l { font-family: var(--mono); font-size: 11px; color: #b9bdca; text-align: center; padding: 0 4px; }
.tile.is-empty { background: transparent; border-style: dashed; }
.tile.is-empty .s { color: var(--muted); }

/* ---------- Marquesina ---------- */
.strip { position: relative; height: 90vh; display: flex; flex-direction: column; justify-content: center; gap: 2vw; overflow: hidden; }
.mq { display: flex; width: max-content; white-space: nowrap; will-change: transform; font-size: clamp(64px, 13vw, 200px); line-height: 1; font-weight: 500; letter-spacing: -0.04em; }
.mq.out { font-size: clamp(48px, 9vw, 140px); color: transparent; -webkit-text-stroke: 1.5px var(--bone); }
.mq-g { display: flex; flex: none; }
.mq-t { padding-right: 0.3em; }
.mq-s { padding-right: 0.3em; color: var(--ion); -webkit-text-stroke: 0; }

/* ---------- Contacto ---------- */
#contact { position: relative; padding: 0 var(--pad) var(--pad); }
.contact-card {
  min-height: 92vh; padding: clamp(28px, 5vw, 80px);
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 36px; will-change: transform;
}
.huge { margin: 0; font-size: clamp(52px, 14vw, 230px); line-height: 0.92; letter-spacing: -0.05em; font-weight: 500; }
.mask { display: inline-block; overflow: hidden; padding-bottom: 0.08em; }
.cc { display: inline-block; }
.contact { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.row {
  display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: 52px; padding: 0 22px; max-width: 100%;
  font-family: var(--mono); font-size: 15px; text-decoration: none;
  background: rgba(6, 7, 11, 0.5); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .25s, color .25s;
}
a.row:hover { border-color: var(--ion); color: var(--ion); }
.row .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.row.is-empty { border-style: dashed; background: transparent; color: var(--muted); }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }

/* ---------- Detalle de proyecto (portal) ---------- */
.detail { position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: var(--void); visibility: hidden; clip-path: circle(0 at 50% 50%); }
.detail.is-open { visibility: visible; }
.detail-inner { max-width: 880px; margin: 0 auto; padding: 100px var(--pad) 72px; display: flex; flex-direction: column; gap: 20px; }
.shot { width: 100%; max-height: 420px; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 12px; }
.links:empty { display: none; }
.links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; font-family: var(--mono); font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; transition: border-color .2s, color .2s; }
.links a:hover { border-color: var(--ion); color: var(--ion); }
.note { color: var(--muted); font-style: italic; }
[data-d] { opacity: 0; }

/* ---------- Carga ---------- */
.loader { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: var(--pad); }
.count { font-family: var(--mono); font-size: clamp(72px, 14vw, 180px); line-height: 0.9; letter-spacing: -0.04em; }
#enter { opacity: 0; }

/* ---------- Indicador y cursor ---------- */
.pager { position: fixed; right: var(--pad); bottom: 28px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--muted); }
.bullets { display: flex; }
.bul { position: relative; width: 36px; height: 28px; padding: 0; background: none; border: 0; cursor: pointer; }
.bul::after { content: ''; position: absolute; left: 4px; right: 4px; top: 12px; height: 3px; background: #3a3e4c; transition: background .25s; }
.bul.is-active::after { background: var(--ion); }
.cursor { position: fixed; left: 0; top: 0; z-index: 60; width: 44px; height: 44px; border: 1px solid var(--ion); border-radius: 50%; pointer-events: none; opacity: 0; display: flex; align-items: center; justify-content: center; }
.cursor span { font-family: var(--mono); font-size: 11px; color: var(--ion); opacity: 0; }

/* ---------- Móvil ---------- */
@media (max-width: 860px) {
  .nav, .lang { display: none; }
  .bar { padding-top: 20px; }
  .about { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .periodic { max-width: 340px; gap: 8px; }
  .hint { display: none; }
  .sticky { padding-top: 84px; padding-bottom: 96px; }
  .slide-intro .hint { display: flex; }
}
@media (max-height: 700px) and (max-width: 860px) {
  .skill-name { font-size: 36px; }
  .about-text { gap: 10px; }
}

/* ---------- Sin WebGL ---------- */
.no-gl #gl, .no-gl .loader { display: none; }
.no-gl [data-in] { opacity: 1; }

/* ---------- Movimiento reducido o sin ScrollTrigger: página normal ---------- */
.rm .pin { height: auto !important; }
.rm .sticky { position: relative; height: auto; min-height: 100vh; overflow: visible; }
.rm .sticky.proj { overflow-x: auto; }
.rm .statement .w { opacity: 1; }
.rm [data-in] { opacity: 1; }
.rm .hprogress { display: none; }
.rm .hint .line { animation: none; }
