:root {
  --bg: #050505;
  --fg: #f3f1ec;
  --accent: #ff4a1c;
  --ink: #0b0b0b;
  --paper: #f3f1ec;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 3vw, 40px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.is-loading { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.dim, .muted { opacity: .55; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: -.02em; line-height: 1.02; font-variation-settings: "opsz" 144; }
.display em { font-style: italic; font-weight: 300; }
.eyebrow { margin-bottom: 18px; opacity: .7; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6em;
  height: 48px; padding: 0 24px; border-radius: 999px;
  background: var(--fg); color: var(--bg);
  font-weight: 500; font-size: 15px; border: 1px solid var(--fg); cursor: pointer;
  transition: transform .25s ease, background-color .25s, color .25s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--fg); color: var(--bg); }
.btn-sm { height: 38px; padding: 0 18px; font-size: 14px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Canvas & capas fijas ---------- */
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
#glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0;
  background:
    radial-gradient(60% 55% at 50% 60%, rgba(255, 74, 28, .55), transparent 70%),
    radial-gradient(90% 70% at 50% 100%, rgba(170, 20, 8, .7), transparent 70%);
}
#grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 33%{transform:translate(-4%,3%)} 66%{transform:translate(3%,-2%)} 100%{transform:translate(0,0)} }

.layer { position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: 0; }
.layer.on * { pointer-events: auto; }
.about-ui .card:not(.show), .about-ui .card:not(.show) * { pointer-events: none !important; }
#track { position: relative; z-index: -1; width: 1px; }

/* ---------- Loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100; background: #050505; color: #f3f1ec;
  display: grid; place-items: center; transition: opacity .8s ease, visibility .8s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-box { display: grid; justify-items: center; gap: 10px; }
.loader-bar { width: 120px; height: 2px; background: rgba(255,255,255,.15); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: #f3f1ec; transition: width .3s ease; }
.loader-pct { opacity: .5; font-size: 10px; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px var(--gutter);
  color: var(--fg);
  background: linear-gradient(var(--bg) 35%, transparent);
}
.nav-logo, .footer-logo {
  display: block; width: 92px; aspect-ratio: 1174 / 343;
  background: var(--fg);
  -webkit-mask: url("assets/logo-white.png") center / contain no-repeat;
          mask: url("assets/logo-white.png") center / contain no-repeat;
}
.nav-links { display: flex; gap: 28px; font-size: 14px; }
.nav-links a { position: relative; opacity: .8; transition: opacity .2s; }
.nav-links a:hover { opacity: 1; }
.nav-links a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -3px; height: 1px; background: currentColor; transition: right .3s ease; }
.nav-links a:hover::after { right: 0; }
.progress { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 21; }
.progress i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Portada ---------- */
.hud { position: absolute; display: grid; gap: 6px; font-size: 10px; }
.hud-tl { top: 92px; left: var(--gutter); }
.hud-tr { top: 92px; right: var(--gutter); text-align: right; }
.hero-bottom {
  position: absolute; left: 0; right: 0; bottom: clamp(70px, 12vh, 130px);
  display: grid; justify-items: center; text-align: center; gap: 18px; padding: 0 var(--gutter);
}
.hero-sub { font-size: clamp(11px, 1.1vw, 14px); letter-spacing: .5em; margin-right: -.5em; }
.hero-tag { font-family: var(--display); font-size: clamp(22px, 2.6vw, 34px); line-height: 1.15; max-width: 22ch; }
.hero-tag em { font-style: italic; font-weight: 300; }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.scroll-hint { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; font-size: 9px; opacity: .6; }
.scroll-hint i { width: 1px; height: 36px; background: linear-gradient(var(--fg), transparent); animation: drip 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- Portafolio ---------- */
.work-intro { position: absolute; left: var(--gutter); right: var(--gutter); top: 50%; transform: translateY(-50%); text-align: center; display: grid; justify-items: center; }
.work-intro h2 { font-size: clamp(44px, 8vw, 128px); }
.work-intro p.muted { margin-top: 22px; max-width: 34ch; }
.work-list { position: absolute; left: var(--gutter); top: 50%; transform: translateY(-50%); width: 220px; }
.work-list ol { list-style: none; display: grid; gap: 6px; }
.work-list li button {
  all: unset; cursor: pointer; display: flex; gap: 10px; align-items: baseline;
  font-size: 13px; opacity: .35; transition: opacity .3s, transform .3s;
}
.work-list li button span { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; }
.work-list li button:hover { opacity: .75; }
.work-list li.active button { opacity: 1; transform: translateX(8px); }
.work-list li button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.work-caption { position: absolute; left: 50%; bottom: clamp(28px, 6vh, 64px); transform: translateX(-50%); text-align: center; display: grid; justify-items: center; gap: 8px; width: min(90vw, 900px); }
.wc-name { font-size: clamp(30px, 4.4vw, 64px); }
.wc-count, .wc-cat { opacity: .6; }
.work-hint { position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%) rotate(90deg); transform-origin: right center; font-size: 9px; opacity: .5; white-space: nowrap; }

/* ---------- Visor ---------- */
#viewer { position: fixed; inset: 0; z-index: 30; pointer-events: none; visibility: hidden; }
#viewer.open { pointer-events: auto; visibility: visible; }
.v-frame {
  position: absolute; overflow: hidden; background: #111; border-radius: 14px;
  box-shadow: 0 40px 120px rgba(0,0,0,.35);
  will-change: left, top, width, height;
}
#viewer.anim .v-frame { transition: left .75s cubic-bezier(.7,0,.2,1), top .75s cubic-bezier(.7,0,.2,1), width .75s cubic-bezier(.7,0,.2,1), height .75s cubic-bezier(.7,0,.2,1), border-radius .75s; }
#viewer.full .v-frame { border-radius: 0; }
.v-scroll { position: absolute; inset: 0; overflow: hidden; }
.v-scroll img { width: 100%; height: auto; will-change: transform; }
.v-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: rgba(20,20,20,.82); color: #f3f1ec; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; transform: translateY(-100%); transition: opacity .4s, transform .4s;
}
.v-dots { display: flex; gap: 6px; }
.v-dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.v-dots i:nth-child(2) { background: #febc2e; }
.v-dots i:nth-child(3) { background: #28c840; }
.v-url { flex: 1; text-align: center; font-size: 11px; letter-spacing: .04em; text-transform: none; background: rgba(255,255,255,.08); border-radius: 8px; padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; margin: 0 auto; }
.v-close { all: unset; cursor: pointer; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; }
.v-close:hover { background: rgba(255,255,255,.12); }
.v-info {
  position: absolute; left: 16px; bottom: 16px; max-width: min(460px, calc(100% - 32px));
  padding: 22px 24px; border-radius: 16px;
  background: rgba(10,10,10,.82); color: #f3f1ec; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; transform: translateY(20px); transition: opacity .45s, transform .45s;
  --fg: #f3f1ec; --bg: #0b0b0b;
}
.v-name { font-size: clamp(28px, 3vw, 40px); margin: 8px 0 8px; }
.v-desc { font-size: 14px; opacity: .75; margin-bottom: 16px; }
.v-count { opacity: .55; }
.v-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.v-hint { font-size: 9px; opacity: .5; }
#viewer.full .v-bar, #viewer.full .v-info { opacity: 1; transform: none; transition-delay: .25s; }

/* ---------- Nosotros (túnel) ---------- */
.about-ui .card {
  position: absolute; left: var(--gutter); top: 50%;
  width: min(620px, calc(100vw - 2 * var(--gutter)));
  transform: translateY(-50%); opacity: 0; visibility: hidden;
  padding: clamp(22px, 3vw, 36px); border-radius: 18px;
  background: rgba(5, 6, 10, .55); border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.about-ui .card h2 { font-size: clamp(32px, 4.4vw, 60px); margin-bottom: 18px; }
.about-ui .card h2.big { font-size: clamp(56px, 9vw, 132px); }
.about-ui .card p { opacity: .8; max-width: 52ch; }
.services { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.services h3 { font-size: 26px; margin-bottom: 8px; }
.services p { font-size: 14px; }
.stats { display: flex; gap: 40px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 22px; }
.stats strong { display: block; font-size: clamp(44px, 5vw, 72px); color: var(--accent); }
.stats span { opacity: .6; font-size: 10px; }
blockquote + blockquote { margin-top: 26px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.12); }
blockquote p.display { font-size: clamp(22px, 2.4vw, 30px); line-height: 1.2; opacity: 1 !important; }
blockquote cite { display: block; margin-top: 10px; font-style: normal; opacity: .55; color: var(--accent); }

/* ---------- Contacto ---------- */
.contact { position: relative; z-index: 3; min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; color: #fbeee6; }
.contact-inner { padding: clamp(110px, 16vh, 180px) var(--gutter) 60px; max-width: 1200px; margin: 0 auto; width: 100%; }
.contact-title { font-size: clamp(48px, 9vw, 150px); margin-bottom: 26px; }
.contact-lead { max-width: 46ch; font-size: 18px; opacity: .85; margin-bottom: 48px; }
.contact-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(24px, 4vw, 60px); align-items: start; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: grid; gap: 8px; }
.form label span { opacity: .7; font-size: 10px; }
.form input, .form textarea {
  width: 100%; padding: 14px 16px; border-radius: 12px; resize: vertical;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.18); color: #fff;
  transition: border-color .2s, background-color .2s;
}
.form input::placeholder, .form textarea::placeholder { color: rgba(255,255,255,.45); }
.form input:focus, .form textarea:focus { outline: none; border-color: #fff; background: rgba(0,0,0,.4); }
.form .btn { height: 54px; margin-top: 4px; }
.form-error { min-height: 1em; color: #ffd2c4; font-size: 10px; }
.contact-direct { display: grid; gap: 10px; }
.direct { display: grid; gap: 4px; padding: 18px 20px; border-radius: 14px; border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.18); transition: background-color .25s, transform .25s; }
.direct:hover { background: rgba(0,0,0,.35); transform: translateX(4px); }
.direct span { opacity: .65; font-size: 10px; }
.direct strong { font-weight: 500; font-size: 20px; }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 26px var(--gutter); border-top: 1px solid rgba(255,255,255,.15); --fg: #fbeee6; }
.footer .mono { font-size: 10px; opacity: .7; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .hud-tr { display: none; }
  .hud-tl { top: 80px; }
  .work-list { display: none; }
  .work-hint { display: none; }
  .services { grid-template-columns: 1fr; gap: 16px; }
  .stats { gap: 24px; }
  .contact-grid { grid-template-columns: 1fr; }
  .about-ui .card { top: auto; bottom: 24px; transform: none; }
}
@media (max-width: 520px) {
  .form { grid-template-columns: 1fr; }
  .v-info { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom, 0px)); max-width: none; padding: 14px 16px; border-radius: 14px; }
  .v-name { font-size: 24px; margin: 4px 0 10px; }
  .v-count { font-size: 9px; letter-spacing: .1em; }
  .v-desc, .v-hint { display: none; }
  .v-actions .btn { height: 40px; padding: 0 18px; font-size: 14px; }
  .v-bar { height: 40px; }
  .hero-ctas .btn { height: 44px; padding: 0 18px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  #grain, .scroll-hint i { animation: none; }
}

/* ---------- Selector de idioma ---------- */
.nav-right { display: flex; align-items: center; gap: 12px; }
.lang {
  display: flex; padding: 3px; gap: 2px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--fg) 35%, transparent);
}
.lang button {
  all: unset; cursor: pointer; height: 30px; min-width: 36px; padding: 0 8px; box-sizing: border-box;
  display: grid; place-items: center; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  color: var(--fg); opacity: .65; transition: background-color .25s, color .25s, opacity .25s;
}
.lang button:hover { opacity: 1; }
.lang button[aria-pressed="true"] { background: var(--fg); color: var(--bg); opacity: 1; }
.lang button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 420px) {
  .nav { gap: 10px; }
  .nav-logo { width: 78px; }
  .nav-right { gap: 8px; }
  .lang button { height: 28px; min-width: 32px; padding: 0 6px; font-size: 10px; }
  .nav .btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
}
