/* ==========================================================================
   Saúl Rocha Yebra — Design tokens
   Identidad: bitácora de campo / estación hidrométrica.
   Paleta de agua nocturna (tinta índigo) + ocre de cantera para acentos.
   Tipografía: Bricolage Grotesque (encabezados, fresco/tecnológico) +
   Source Sans 3 (cuerpo) + JetBrains Mono (coordenadas, fechas, datos).
   Diseño oscuro deliberado — no es un tema alternable.
   ========================================================================== */
:root {
  --ink-950: #070f16;
  --ink-900: #0b1620;
  --ink-800: #10202b;
  --panel: #11212c;
  --panel-border: rgba(163, 196, 199, 0.16);
  --text: #eef2ee;
  --text-muted: #9bb0ac;
  --text-faint: #61787a;

  --water: #1c9891;
  --water-dim: #12615d;
  --ochre: #d98a3d;
  --ochre-dim: #a5642a;

  --font-display: 'Bricolage Grotesque', 'Source Sans 3', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;

  --max: 1160px;
  --radius-sm: 3px;
  --radius: 5px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink-950);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
p { margin: 0 0 1em; color: var(--text-muted); max-width: 68ch; }
ul { padding: 0; margin: 0; list-style: none; }
a { color: inherit; text-decoration: none; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 999;
  background: var(--water); color: var(--ink-950); padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 12px; top: 12px; }

/* Texture layers ---------------------------------------------------------- */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0.03; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.contour-field {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 15%, rgba(28,152,145,0.07), transparent 42%),
    radial-gradient(circle at 88% 80%, rgba(217,138,61,0.05), transparent 42%);
}

/* ==========================================================================
   Nav
   ========================================================================== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  backdrop-filter: blur(14px);
  background: rgba(7, 15, 22, 0.6);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.nav.scrolled { border-bottom-color: var(--panel-border); background: rgba(7, 15, 22, 0.92); }
.nav-inner {
  max-width: var(--max); margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; letter-spacing: -0.01em;
  color: var(--water);
}
.brand-full { font-size: 0.82rem; color: var(--text-muted); font-family: var(--font-mono); }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { font-size: 0.9rem; color: var(--text-muted); transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-cta {
  border: 1px solid var(--panel-border); padding: 7px 16px; border-radius: var(--radius-sm);
  color: var(--text) !important;
}
.nav-cta:hover { border-color: var(--water); color: var(--water) !important; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative; min-height: 100vh; display: flex; align-items: center;
  overflow: hidden; padding: 140px 24px 80px;
}
.hero-contours { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: 0.5; }
.hero-contours .c { fill: none; stroke-width: 1.2; }
.c1 { stroke: rgba(28,152,145,0.4); }
.c2 { stroke: rgba(28,152,145,0.3); }
.c3 { stroke: rgba(217,138,61,0.22); }
.c4 { stroke: rgba(28,152,145,0.2); }
.c5 { stroke: rgba(217,138,61,0.14); }

.hero-inner {
  position: relative; z-index: 1; max-width: var(--max); margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 60px; align-items: end;
}
.eyebrow {
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--water); margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2.9rem, 6.4vw, 5.2rem); line-height: 0.96; margin-bottom: 26px; color: var(--text);
  font-weight: 700; letter-spacing: -0.01em; font-optical-sizing: auto;
}
.hero-role { font-size: 1.06rem; color: var(--text); font-weight: 600; margin-bottom: 18px; max-width: 46ch; }
.hero-traits {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px;
}
.hero-traits li {
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.03em; color: var(--water);
  border: 1px solid rgba(28,152,145,0.35); padding: 5px 12px; border-radius: var(--radius-sm);
}
.hero-lead { max-width: 50ch; font-size: 1.02rem; margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.92rem; transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s, background 0.25s;
  border: 1px solid transparent;
}
.btn-primary { background: var(--water); color: var(--ink-950); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(28,152,145,0.25); background: #22aca4; }
.btn-ghost { border-color: var(--panel-border); color: var(--text); }
.btn-ghost:hover { border-color: var(--water); transform: translateY(-2px); }

.hero-readout {
  border: 1px solid var(--panel-border); border-radius: var(--radius);
  background: rgba(17, 33, 44, 0.55); backdrop-filter: blur(6px);
  padding: 20px 22px; font-family: var(--font-mono); font-size: 0.78rem;
  margin-bottom: 6px;
}
.readout-row {
  display: flex; justify-content: space-between; gap: 16px; padding: 9px 0;
  border-bottom: 1px solid var(--panel-border); color: var(--text-muted);
}
.readout-row:last-child { border-bottom: none; }
.readout-row span:first-child { color: var(--text-faint); letter-spacing: 0.06em; }
.readout-row span:last-child { color: var(--text); text-align: right; }
.readout-row .ok { color: var(--water); }
.readout-row .ok::before { content: "● "; }

.scroll-cue {
  position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 1;
  width: 22px; height: 36px; border: 1.5px solid var(--panel-border); border-radius: 12px;
}
.scroll-cue span {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 8px; border-radius: 2px; background: var(--water);
  animation: scrollcue 1.8s infinite ease-in-out;
}
@keyframes scrollcue { 0% { opacity: 1; top: 6px; } 70% { opacity: 0; top: 18px; } 100% { opacity: 0; top: 18px; } }

/* ==========================================================================
   Section shared
   ========================================================================== */
section { position: relative; z-index: 1; padding: 110px 24px; }
.section-head { max-width: var(--max); margin: 0 auto 56px; }
.section-kicker {
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--water); margin-bottom: 14px;
}
.section-head h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); max-width: 780px; color: var(--text); font-weight: 600; }

.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ==========================================================================
   Historia
   ========================================================================== */
.historia { max-width: var(--max); margin: 0 auto; }
.story { max-width: 720px; margin: 0 0 70px; }
.story-lead { font-size: 1.05rem; color: var(--text); }
.story-quote {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(1.3rem, 3vw, 1.85rem); color: var(--text);
  padding-left: 22px; border-left: 2px solid var(--water); margin: 26px 0;
}
.story-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--panel-border); border: 1px solid var(--panel-border); margin-bottom: 60px; }
.story-card {
  background: var(--panel); padding: 30px 26px; transition: background 0.25s;
}
.story-card:hover { background: var(--ink-800); }
.story-num {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--ochre); display: block; margin-bottom: 16px;
}
.story-card h3 { font-size: 1.18rem; margin-bottom: 12px; color: var(--text); font-weight: 600; }
.story-card p { font-size: 0.94rem; }
.story-highlight {
  color: var(--text); font-size: 0.94rem; padding-top: 14px; margin-top: 12px;
  border-top: 1px solid var(--panel-border); font-family: var(--font-body); font-style: italic;
}
.story-tags li { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }
.story-tags strong { color: var(--text); font-family: var(--font-body); font-style: normal; }

.story-close { max-width: 780px; }
.story-thread {
  font-family: var(--font-mono); font-size: 0.9rem; color: var(--water); line-height: 2.1;
}

/* ==========================================================================
   Trayectoria / Timeline
   ========================================================================== */
.trayectoria { max-width: var(--max); margin: 0 auto; }
.timeline { position: relative; max-width: 820px; margin: 0 auto; padding-left: 34px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px;
  background: linear-gradient(180deg, var(--water), rgba(28,152,145,0.06));
}
.tl-item { position: relative; padding-bottom: 46px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-marker {
  position: absolute; left: -34px; top: 4px; width: 13px; height: 13px;
  background: var(--ink-950); border: 2px solid var(--water); transform: rotate(45deg);
}
.tl-date {
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--water); letter-spacing: 0.03em;
}
.tl-content h3 { font-size: 1.2rem; margin: 8px 0 4px; color: var(--text); font-weight: 600; }
.tl-org { color: var(--text-faint); font-size: 0.9rem; margin-bottom: 12px; font-family: var(--font-mono); }
.tl-content ul { margin-top: 10px; }
.tl-content li {
  font-size: 0.93rem; color: var(--text-muted); padding-left: 18px; position: relative; margin-bottom: 8px;
}
.tl-content li::before {
  content: ""; position: absolute; left: 0; top: 9px; width: 6px; height: 1px;
  background: var(--ochre);
}
.tl-content strong { color: var(--text); }

/* ==========================================================================
   Proyectos
   ========================================================================== */
.proyectos { max-width: var(--max); margin: 0 auto; }
.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--panel-border); border: 1px solid var(--panel-border); }
.project-card {
  background: var(--panel); padding: 0 28px 26px; transition: background 0.25s;
  display: flex; flex-direction: column;
}
.project-card:hover { background: var(--ink-800); }
.project-card h3 { font-size: 1.1rem; margin-bottom: 10px; color: var(--text); font-weight: 600; }
.project-card p { font-size: 0.92rem; margin-bottom: 0; }
.project-card--featured {
  grid-column: span 3;
  background: var(--ink-800);
}
.project-card--featured h3 { font-size: 1.5rem; }
.project-tag {
  display: inline-block; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-950); background: var(--ochre); padding: 3px 10px; border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* Portadas abstractas del portafolio — patrones instrumentales, sin iconos */
.project-cover {
  height: 88px; margin: 0 -28px 22px; background: var(--ink-900);
  border-bottom: 1px solid var(--panel-border);
}
.project-card--featured .project-cover { height: 130px; }
.cover--water {
  background-image: repeating-radial-gradient(circle at 15% 130%, transparent 0 9px, rgba(28,152,145,0.3) 9px 11px);
}
.cover--data {
  background-image: radial-gradient(rgba(217,138,61,0.45) 1.6px, transparent 1.6px);
  background-size: 15px 15px;
}
.cover--database {
  background-image: repeating-linear-gradient(0deg, rgba(28,152,145,0.32) 0 2px, transparent 2px 15px);
}
.cover--chart {
  background-image: repeating-linear-gradient(65deg, rgba(217,138,61,0.32) 0 5px, transparent 5px 16px);
}
.cover--ledger {
  background-image:
    linear-gradient(90deg, transparent 22%, rgba(217,138,61,0.32) 22% 23%, transparent 23%),
    repeating-linear-gradient(0deg, rgba(238,242,238,0.1) 0 1px, transparent 1px 11px);
}
.cover--infra {
  background-image: repeating-linear-gradient(90deg, rgba(28,152,145,0.32) 0 3px, transparent 3px 13px);
}
.cover--mixed {
  background-image:
    repeating-linear-gradient(0deg, rgba(217,138,61,0.18) 0 1px, transparent 1px 20px),
    repeating-linear-gradient(90deg, rgba(28,152,145,0.18) 0 1px, transparent 1px 20px);
}
.project-meta {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.02em; color: var(--text-faint);
  margin-top: auto; padding-top: 14px;
}

/* ==========================================================================
   Habilidades
   ========================================================================== */
.habilidades { max-width: var(--max); margin: 0 auto; }
.skills-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--panel-border); border: 1px solid var(--panel-border); }
.skill-block {
  background: var(--panel); padding: 24px;
}
.skill-block h3 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--water);
  font-family: var(--font-mono); margin-bottom: 16px; font-weight: 500;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud span {
  font-size: 0.8rem; color: var(--text-muted); border: 1px solid var(--panel-border);
  padding: 5px 11px; border-radius: var(--radius-sm);
}
.edu-list li { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.edu-list strong { color: var(--text); display: block; margin-bottom: 2px; font-size: 0.88rem; font-family: var(--font-body); font-weight: 600; }

/* ==========================================================================
   Cierre
   ========================================================================== */
.cierre { background: var(--ink-900); border-top: 1px solid var(--panel-border); border-bottom: 1px solid var(--panel-border); }
.cierre-inner { max-width: 680px; margin: 0 auto; text-align: center; }
.cierre-inner p { margin-left: auto; margin-right: auto; }
.cierre-quote {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 3.2vw, 2.1rem); color: var(--water);
  margin: 30px 0; line-height: 1.35;
}
.cierre-tail { font-style: italic; color: var(--text-faint); }

/* ==========================================================================
   Contacto
   ========================================================================== */
.contacto { text-align: center; }
.contacto-inner { max-width: 600px; margin: 0 auto; }
.contacto h2 { margin: 14px 0 30px; font-size: clamp(1.6rem, 3.2vw, 2.2rem); }
.email-link {
  display: inline-block; font-family: var(--font-mono); font-size: 1.1rem; color: var(--water);
  padding-bottom: 4px; border-bottom: 1px solid rgba(28,152,145,0.4); transition: color 0.2s, border-color 0.2s;
}
.email-link:hover { color: var(--ochre); border-color: var(--ochre); }
.contacto-loc { margin-top: 18px; font-size: 0.86rem; color: var(--text-faint); font-family: var(--font-mono); }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  text-align: center; padding: 34px 24px; border-top: 1px solid var(--panel-border);
  font-size: 0.8rem; color: var(--text-faint); font-family: var(--font-mono);
}
.footer p { margin: 0 0 8px; max-width: none; }
.footer p:last-child { margin-bottom: 0; }
.visit-counter { letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.vc-dot { color: var(--water); font-size: 0.7em; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; gap: 40px; }
  .hero-readout { max-width: 420px; }
}

@media (max-width: 880px) {
  .story-grid { grid-template-columns: 1fr 1fr; }
  .project-grid { grid-template-columns: 1fr 1fr; }
  .project-card--featured { grid-column: span 2; }
  .skills-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .nav-links {
    position: fixed; top: 64px; left: 0; right: 0; flex-direction: column; align-items: flex-start;
    background: rgba(7,15,22,0.98); border-bottom: 1px solid var(--panel-border);
    padding: 20px 24px 28px; gap: 18px; transform: translateY(-130%); transition: transform 0.3s var(--ease);
  }
  .nav-links.open { transform: translateY(0); }
  .nav-toggle { display: flex; }
  .story-grid, .project-grid, .skills-grid { grid-template-columns: 1fr; }
  .project-card--featured { grid-column: span 1; }
  section { padding: 80px 20px; }
  .timeline { padding-left: 26px; }
  .tl-marker { left: -26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
