/* =============================================================
   DAVID GUTIÉRREZ ENCINAS — PORTFOLIO
   Tema: "Dehydration" (terminal/dashboard), oscuro y editorial.
   =============================================================
   Índice:
   1. Tokens
   2. Reset & base
   3. Utilidades
   4. Tipografía
   5. Componentes (nav, btn, card, terminal-window, tags)
   6. Secciones
   7. Efectos (reveal, tilt)
   8. Responsive
   9. Reduced-motion
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  /* Base — paleta "Dehydration" */
  --bg-0: #141414;
  --bg-1: #1a1a1a;
  --bg-2: #232323;
  --bg-3: #2b2b2b;
  --bg-4: #333333;
  --line: #3a3a3a;
  --line-soft: rgba(204, 204, 204, 0.1);
  --text: #cccccc;
  --text-bright: #f2f2f2;
  --text-mute: #8a8a8a;
  --text-faint: #5c5c5c;

  /* Acentos por marca */
  --chiwis: #5fd38d;
  --geni: #bc5fd3;
  --scout: #5fd3bc;
  --novafit: #ff9955;
  --red: #ff5555;
  --blue: #3771c8;

  /* Uso general */
  --accent: var(--chiwis);
  --accent-soft: rgba(95, 211, 141, 0.14);

  /* Tipografía */
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--sans);

  /* Easings */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --container: 1240px;
  --radius: 10px;
  --radius-lg: 16px;
  --nav-h: 72px;
}

[data-theme="light"] {
  /* No usado por defecto — el sitio es oscuro por diseño de marca */
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
  overflow-x: clip;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.08; letter-spacing: -0.02em; font-family: var(--display); color: var(--text-bright); }
ul { list-style: none; padding: 0; }
::selection { background: var(--accent); color: var(--bg-0); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--text-bright); color: var(--bg-0);
  border-radius: 8px; font-weight: 600; font-family: var(--mono); font-size: .85rem;
  transition: top .3s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.section { position: relative; padding-block: clamp(4.5rem, 9vw, 8rem); }
.section-head { max-width: 46rem; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.eyebrow {
  display: inline-flex; align-items: center; gap: .6em;
  font-family: var(--mono); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1rem;
}
.eyebrow::before { content: "//"; opacity: .6; }
.section-title { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.section-lede { margin-top: 1rem; color: var(--text-mute); font-size: 1.05rem; max-width: 42rem; }

.grain-overlay {
  position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* =============================================================
   4. Tipografía
   ============================================================= */
.mono { font-family: var(--mono); }
.text-accent { color: var(--accent); }
.big-quote {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.5rem, 3.4vw, 2.4rem);
  line-height: 1.3;
  color: var(--text-bright);
  text-wrap: balance;
}
.big-quote .hl { color: var(--accent); }

/* =============================================================
   5. Componentes
   ============================================================= */

/* --- Botones --- */
.btn {
  display: inline-flex; align-items: center; gap: .6em;
  font-family: var(--mono); font-size: .92rem; font-weight: 500;
  padding: .95rem 1.6rem; border-radius: 999px;
  transition: transform .45s var(--ease-soft), box-shadow .45s var(--ease-soft), background .3s, border-color .3s, color .3s;
}
.btn-primary {
  background: var(--accent); color: var(--bg-0);
  box-shadow: 0 4px 20px -4px rgba(95,211,141,.35);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 16px 34px -8px rgba(95,211,141,.45); }
.btn-primary:active { transform: translateY(-1px); transition-duration: .12s; }
.btn-ghost {
  border: 1px solid var(--line); color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-3px); }
.btn::before { content: "$ "; opacity: .55; }
.btn-ghost::before { content: "→ "; opacity: .6; }

/* --- Nav --- */
.nav {
  position: fixed; top: 0; inset-inline: 0; z-index: 100; height: var(--nav-h);
  display: flex; align-items: center;
  border-bottom: 1px solid transparent;
  transition: background-color .4s var(--ease-out), border-color .4s var(--ease-out), backdrop-filter .4s var(--ease-out);
}
.nav.is-scrolled {
  background: rgba(20,20,20,.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line-soft);
}
.nav-inner { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.nav-logo {
  font-family: var(--mono); font-size: .95rem; color: var(--text-bright);
  display: flex; align-items: center; gap: .5rem;
}
.nav-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulseDot 2.4s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.nav-links { display: none; align-items: center; gap: 2rem; font-family: var(--mono); font-size: .85rem; }
@media (min-width: 960px) { .nav-links { display: flex; } }
.nav-link { position: relative; padding-block: .25rem; color: var(--text-mute); transition: color .3s; }
.nav-link:hover, .nav-link.is-active { color: var(--text-bright); }
.nav-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--accent);
  transform: scaleX(0); transform-origin: right; transition: transform .45s var(--ease-out);
}
.nav-link:hover::after, .nav-link.is-active::after { transform: scaleX(1); transform-origin: left; }
.nav-cta { display: none; }
@media (min-width: 720px) { .nav-cta { display: inline-flex; padding: .6rem 1.2rem; font-size: .8rem; } }

.nav-burger {
  position: relative; z-index: 101;
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--line);
}
@media (min-width: 960px) { .nav-burger { display: none; } }
.nav-burger-icon, .nav-burger-icon::before, .nav-burger-icon::after {
  display: block; width: 16px; height: 1px; background: var(--text);
  transition: transform .3s var(--ease-out), opacity .3s var(--ease-out), background .3s;
}
.nav-burger-icon { position: relative; }
.nav-burger-icon::before, .nav-burger-icon::after { content: ""; position: absolute; left: 0; }
.nav-burger-icon::before { top: -5px; }
.nav-burger-icon::after { top: 5px; }
.nav-burger[aria-expanded="true"] .nav-burger-icon { background: transparent; }
.nav-burger[aria-expanded="true"] .nav-burger-icon::before { top: 0; transform: rotate(45deg); background: var(--accent); }
.nav-burger[aria-expanded="true"] .nav-burger-icon::after { top: 0; transform: rotate(-45deg); background: var(--accent); }

.nav-mobile {
  position: fixed; inset: 0; z-index: 95; background: var(--bg-0);
  display: grid; place-items: center; clip-path: inset(0 0 100% 0);
  transition: clip-path .6s var(--ease-soft);
}
.nav-mobile[data-open="true"] { clip-path: inset(0); }
.nav-mobile-inner { display: flex; flex-direction: column; gap: 1.6rem; text-align: center; font-family: var(--mono); font-size: 1.3rem; }

/* --- Terminal window chrome --- */
.term {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.6);
}
.term-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.term-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.term-title {
  margin-left: .5rem; font-family: var(--mono); font-size: .74rem; color: var(--text-faint);
}
.term-body { padding: 1.4rem; }

/* --- Cards --- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  padding: 1.75rem;
  transition: transform .5s var(--ease-soft), border-color .4s, box-shadow .5s var(--ease-soft);
  --rx: 0deg; --ry: 0deg;
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry));
}
.card:hover { border-color: var(--card-accent, var(--accent)); }
.card-icon {
  font-family: var(--mono); font-size: .78rem; color: var(--card-accent, var(--accent));
  display: inline-flex; align-items: center; gap: .4em; margin-bottom: 1rem;
}
.card h3 { font-size: 1.2rem; margin-bottom: .6rem; }
.card p { color: var(--text-mute); font-size: .96rem; }

/* --- Tags --- */
.tag {
  display: inline-flex; align-items: center; font-family: var(--mono); font-size: .74rem;
  padding: .28rem .7rem; border-radius: 999px; border: 1px solid var(--line); color: var(--text-mute);
}

/* =============================================================
   6. Secciones
   ============================================================= */

/* --- Splash --- */
.splash {
  position: fixed; inset: 0; z-index: 10000; background: var(--bg-0);
  display: grid; place-items: center;
  transition: opacity .7s var(--ease-out), clip-path .9s var(--ease-out);
  animation: splashSafety .01s 3.2s forwards;
}
.splash.is-out { opacity: 0; pointer-events: none; clip-path: inset(0 0 100% 0); }
@keyframes splashSafety { to { opacity: 0; pointer-events: none; clip-path: inset(0 0 100% 0); } }
.splash-line { font-family: var(--mono); font-size: .95rem; color: var(--text-mute); }
.splash-line .cur { display: inline-block; width: .55em; height: 1.05em; background: var(--accent); margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* --- Background layers (fixed, whole page) --- */
.bg-layer {
  position: fixed; inset: 0; z-index: -2;
  background: radial-gradient(120% 90% at 50% -10%, var(--bg-3), var(--bg-1) 55%, var(--bg-0));
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(90% 60% at 50% 0%, #000 40%, transparent 90%);
}
.bg-scanline {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .025;
  background: repeating-linear-gradient(0deg, #fff 0px, #fff 1px, transparent 1px, transparent 3px);
}

/* --- Hero --- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex; align-items: center;
  padding-top: calc(var(--nav-h) + 2rem);
  padding-bottom: 4rem;
}
.hero-kicker {
  font-family: var(--mono); font-size: .85rem; color: var(--text-mute);
  display: flex; align-items: center; gap: .6rem; margin-bottom: 1.6rem;
}
.hero-kicker .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.hero-title {
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  line-height: .98;
  max-width: 16ch;
}
.hero-title .last { color: var(--accent); }
.hero-roles {
  margin-top: 1.4rem; font-family: var(--mono); font-size: clamp(.95rem, 1.6vw, 1.15rem);
  color: var(--text-mute); min-height: 1.6em;
}
.hero-roles .cur {
  display: inline-block; width: .5em; height: 1em; background: var(--accent);
  margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(1) infinite;
}
.hero-quote {
  margin-top: 2.2rem; padding-left: 1.3rem; border-left: 2px solid var(--accent);
  max-width: 38rem;
}
.hero-actions { margin-top: 2.6rem; display: flex; flex-wrap: wrap; gap: 1rem; }
.hero-meta {
  margin-top: 3.2rem; display: flex; gap: 2rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: .8rem; color: var(--text-faint);
}
.hero-meta span b { color: var(--text-mute); font-weight: 500; }

/* --- Stats band --- */
.stats {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line);
}
@media (min-width: 720px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--bg-2); padding: clamp(1.6rem, 3vw, 2.4rem) 1.4rem; text-align: left;
}
.stat-num {
  font-family: var(--mono); font-size: clamp(2rem, 4vw, 2.8rem); color: var(--accent); font-weight: 600;
  display: block; line-height: 1;
}
.stat-label { margin-top: .6rem; font-size: .88rem; color: var(--text-mute); }

/* --- Origin story --- */
.story-grid { display: grid; gap: 3rem; align-items: start; }
@media (min-width: 960px) { .story-grid { grid-template-columns: .85fr 1.15fr; gap: 4.5rem; } }
.story-visual { position: relative; }
.story-term .term-body { display: flex; flex-direction: column; gap: .55rem; font-family: var(--mono); font-size: .82rem; color: var(--text-mute); }
.story-term .ln { display: flex; gap: .6rem; }
.story-term .ln .k { color: var(--accent); white-space: nowrap; }
.story-term .cursor-line { color: var(--text-faint); }
.story-text p { margin-bottom: 1.2rem; color: var(--text); font-size: 1.02rem; line-height: 1.75; }
.story-text p:first-of-type::first-letter {
  float: left; font-family: var(--display); font-size: 3.6rem; line-height: .85;
  margin: .12rem .5rem -.1rem 0; color: var(--accent); font-weight: 600;
}

/* --- Process steps / servicios grids --- */
.pillars-grid, .services-grid { display: grid; gap: 1.4rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .pillars-grid, .services-grid { grid-template-columns: repeat(3, 1fr); } }
.service-card { display: flex; flex-direction: column; }
.service-card p { flex: 1; }
.service-card .btn { margin-top: 1.3rem; align-self: flex-start; padding: .7rem 1.2rem; font-size: .82rem; }

/* --- Manifesto --- */
.manifesto { text-align: center; }
.manifesto .container { max-width: 52rem; }
.manifesto .big-quote { font-size: clamp(1.5rem, 3.6vw, 2.5rem); margin-inline: auto; }
.manifesto-mark { font-family: var(--mono); color: var(--accent); font-size: 1.4rem; display: block; margin-bottom: 1.4rem; }
.manifesto-cta { margin-top: 2.4rem; display: flex; justify-content: center; }

/* --- Collaborations --- */
.collab-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .collab-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .collab-grid { grid-template-columns: repeat(3, 1fr); } }
.collab-card { padding: 1.4rem 1.5rem; }
.collab-num { font-family: var(--mono); font-size: .78rem; color: var(--text-faint); margin-bottom: .5rem; display: block; }
.collab-card p { color: var(--text); font-size: .95rem; }

/* --- Contact --- */
.contact { position: relative; }
.contact-term { max-width: 46rem; margin-inline: auto; }
.contact-term .term-body { display: flex; flex-direction: column; gap: 1.1rem; font-family: var(--mono); font-size: .95rem; }
.contact-term .ln { display: flex; flex-wrap: wrap; gap: .6rem; align-items: baseline; }
.contact-term .k { color: var(--text-faint); }
.contact-term .v { color: var(--text-bright); }
.contact-email {
  color: var(--accent); font-size: 1.05rem; word-break: break-all;
}
.contact-email:hover { text-decoration: underline; }
.contact-socials { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-top: 1.4rem; }
.contact-socials a { font-size: .82rem; color: var(--text-mute); border: 1px solid var(--line); border-radius: 999px; padding: .4rem .9rem; transition: color .3s, border-color .3s; }
.contact-socials a:hover { color: var(--accent); border-color: var(--accent); }
.contact-actions { margin-top: 2.2rem; display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; }

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--line);
  padding-block: 2.4rem;
}
.footer-inner {
  display: flex; flex-direction: column; gap: 1.2rem; align-items: center; text-align: center;
  font-family: var(--mono); font-size: .8rem; color: var(--text-faint);
}
@media (min-width: 720px) { .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; } }
.footer-back { color: var(--text-mute); }
.footer-back:hover { color: var(--accent); }

/* =============================================================
   7. Efectos
   ============================================================= */
[data-reveal] {
  opacity: 0; transform: translateY(28px);
  transition: opacity .8s var(--ease-soft), transform .8s var(--ease-soft);
}
[data-reveal].is-revealed { opacity: 1; transform: none; }
[data-reveal-stagger] > * {
  opacity: 0; transform: translateY(22px);
  transition: opacity .7s var(--ease-soft), transform .7s var(--ease-soft);
}
[data-reveal-stagger].is-revealed > * { opacity: 1; transform: none; }
[data-reveal-stagger].is-revealed > *:nth-child(1) { transition-delay: 0s; }
[data-reveal-stagger].is-revealed > *:nth-child(2) { transition-delay: .08s; }
[data-reveal-stagger].is-revealed > *:nth-child(3) { transition-delay: .16s; }
[data-reveal-stagger].is-revealed > *:nth-child(4) { transition-delay: .24s; }

/* Tilt */
.has-tilt { transition: transform .5s var(--ease-soft); transform-style: preserve-3d; }
.has-tilt:hover { transition-duration: .15s; }

/* =============================================================
   8. Responsive extra
   ============================================================= */
@media (min-width: 540px)  { .container { padding-inline: var(--gutter); } }
@media (min-width: 1600px) { .container { max-width: 1360px; } }

/* =============================================================
   9. Reduced-motion — solo lo intrusivo
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .nav-logo .dot, .hero-kicker .dot { animation: none; }
  .hero-roles .cur, .splash-line .cur { animation: none; opacity: 1; }
  /* No se desactivan: reveals, tilt, hover, count-up */
}
