/* nano-site/app/styles.css */

/*
  ── SYSTEM FONT STACK ─────────────────────────────────────────────────────
  Sin ningún request externo. El browser usa la mejor fuente disponible
  en el sistema operativo del usuario.

  Mono:  Cascadia Code (Win11) → SF Mono (macOS/iOS) → Consolas (Win)
         → Menlo (macOS legacy) → DejaVu Sans Mono (Linux) → monospace
  Sans:  -apple-system / Segoe UI / Ubuntu según el SO
  ─────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/*
  content-visibility: auto → el browser omite el layout y paint de
  secciones fuera del viewport. Mejora el TBT (Total Blocking Time).
*/
section, .page > * {
  content-visibility: auto;
  contain-intrinsic-size: 0 400px;
}

:root {
  --bg:        #080b08;
  --surface:   #0d110d;
  --surface2:  #111611;
  --border:    #1a2a1a;
  --green:     #39ff6e;
  --green-dim: #1a7a35;
  --green-glow:#39ff6e44;
  --amber:     #ffb347;
  --blue:      #5bc8fa;
  --red:       #ff5f5f;
  --text:      #c8e6c8;
  --muted:     #4a664a;

  /* System font stack — 0 requests externos */
  --font-mono: 'Cascadia Code', 'SF Mono', Consolas, Menlo,
               'DejaVu Sans Mono', 'Liberation Mono', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Ubuntu, Roboto, sans-serif;
  --scanline:  repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  cursor: none;
}

/* ── Custom cursor ───────────────────────── */
#cursor {
  position: fixed;
  width: 14px; height: 18px;
  background: var(--green);
  opacity: 0.85;
  pointer-events: none;
  z-index: 9999;
  animation: blink 1.1s step-end infinite;
  mix-blend-mode: screen;
  transform: translateY(-2px);
}
@keyframes blink { 0%,100%{opacity:.85} 50%{opacity:0} }

/* ── CRT scanline overlay ────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--scanline);
  pointer-events: none;
  z-index: 1000;
  opacity: 0.4;
}

/* ── Navbar ──────────────────────────────── */
#nav {
  position: sticky; top: 0; z-index: 100;
}

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 40px;
  background: rgba(8,11,8,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.nav-logo {
  font-size: 20px; font-weight: 700;
  color: var(--green);
  letter-spacing: -1px;
  text-shadow: 0 0 20px var(--green-glow);
  cursor: pointer;
}

.nav-logo::before { content: '> '; color: var(--muted); }

.nav-links {
  list-style: none;
  display: flex; gap: 4px;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--green);
  border-color: var(--border);
  text-shadow: 0 0 12px var(--green-glow);
  background: rgba(57,255,110,0.04);
}

/* ── Page base ───────────────────────────── */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 40px;
}

/* ── Animations ──────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes typeIn {
  from { width: 0; }
  to   { width: 100%; }
}
@keyframes glitch {
  0%,100% { transform: translate(0); }
  20%     { transform: translate(-2px, 1px); }
  40%     { transform: translate(2px, -1px); filter: hue-rotate(90deg); }
  60%     { transform: translate(-1px, 2px); }
  80%     { transform: translate(1px, -1px); }
}
@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 0 rgba(57,255,110,0); }
  50%     { box-shadow: 0 0 24px rgba(57,255,110,0.25); }
}

/* ── HOME PAGE ───────────────────────────── */
.hero {
  min-height: 88vh;
  display: flex; flex-direction: column; justify-content: center;
  gap: 48px;
}

.hero-eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  animation: fadeUp 0.5s ease both;
}

.hero-title {
  font-size: clamp(64px, 12vw, 120px);
  font-weight: 700;
  color: var(--green);
  letter-spacing: -4px;
  line-height: 0.9;
  text-shadow: 0 0 60px rgba(57,255,110,0.3);
  animation: fadeUp 0.5s 0.1s ease both;
}

.hero-title:hover { animation: glitch 0.4s ease; }

.hero-sub {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 300;
  color: var(--text);
  line-height: 1.6;
  max-width: 500px;
  animation: fadeUp 0.5s 0.2s ease both;
  opacity: 0;
  animation-fill-mode: forwards;
}

.hero-stats {
  display: flex; gap: 40px; flex-wrap: wrap;
  animation: fadeUp 0.5s 0.3s ease both;
  opacity: 0;
  animation-fill-mode: forwards;
}

.stat {
  display: flex; flex-direction: column; gap: 4px;
}
.stat-val {
  font-size: 28px; font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 20px var(--green-glow);
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hero-cta {
  display: flex; gap: 12px; flex-wrap: wrap;
  animation: fadeUp 0.5s 0.4s ease both;
  opacity: 0;
  animation-fill-mode: forwards;
}

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  border: 1px solid;
}

.btn-primary {
  background: var(--green);
  color: var(--bg);
  border-color: var(--green);
  font-weight: 700;
}
.btn-primary:hover {
  background: transparent;
  color: var(--green);
  box-shadow: 0 0 24px var(--green-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* Features grid */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 80px;
}

.feature {
  background: var(--surface);
  padding: 28px;
  transition: background 0.15s;
}
.feature:hover { background: var(--surface2); }

.feature-icon {
  font-size: 20px; margin-bottom: 12px;
  display: block;
}
.feature-name {
  font-size: 13px; font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.feature-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  font-family: var(--font-sans);
}

/* ── SECTION HEADER ──────────────────────── */
.section-header {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 40px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.section-num {
  font-size: 11px; color: var(--muted);
  letter-spacing: 2px;
}

.section-title {
  font-size: 13px; font-weight: 700;
  color: var(--green);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── CODE BLOCKS ─────────────────────────── */
.code-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 20px 0;
}

.code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.code-dots {
  display: flex; gap: 6px;
}
.code-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.code-dot:nth-child(1) { background: #ff5f56; }
.code-dot:nth-child(2) { background: #ffbd2e; }
.code-dot:nth-child(3) { background: #27c93f; }

.code-filename {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.5px;
}

.code-copy {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--muted);
  background: none; border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 3px;
  cursor: pointer; transition: all 0.15s;
  letter-spacing: 0.5px;
}
.code-copy:hover { color: var(--green); border-color: var(--green-dim); }

pre {
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 2;
  overflow-x: auto;
  color: #c8e6c8;
}

/* Syntax tokens */
.t-kw   { color: #5bc8fa; }  /* keyword: import, const, export, function */
.t-fn   { color: #ffb347; }  /* function name */
.t-str  { color: #a8e6a3; }  /* strings */
.t-num  { color: var(--green); } /* numbers */
.t-cmt  { color: #2a4a2a; font-style: italic; }  /* comments */
.t-tag  { color: #ff9eb5; }  /* html tags */
.t-attr { color: var(--blue); } /* attributes */
.t-op   { color: var(--muted); } /* operators */

/* ── DEMO WIDGETS ────────────────────────── */
.demo-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: pulse-glow 3s ease infinite;
  margin: 24px 0;
}

.demo-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  align-self: flex-start;
}

/* Counter demo */
.counter-display {
  font-size: 80px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 40px var(--green-glow);
  letter-spacing: -4px;
  line-height: 1;
  min-width: 160px;
  text-align: center;
  transition: transform 0.1s;
}
.counter-display.bump { transform: scale(1.08); }

.counter-controls {
  display: flex; gap: 12px; align-items: center;
}

.counter-btn {
  font-family: var(--font-mono);
  font-size: 24px; font-weight: 700;
  width: 52px; height: 52px;
  border-radius: 4px;
  border: 1px solid var(--green-dim);
  background: transparent;
  color: var(--green);
  cursor: pointer;
  transition: all 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.counter-btn:hover {
  background: rgba(57,255,110,0.1);
  box-shadow: 0 0 16px var(--green-glow);
}
.counter-btn:active { transform: scale(0.93); }

.counter-reset {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.counter-reset:hover { color: var(--red); border-color: var(--red); }

/* Todo demo */
.todo-demo-wrap { width: 100%; max-width: 460px; }

.todo-input-row {
  display: flex; gap: 8px; margin-bottom: 16px;
}

.todo-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}
.todo-input:focus { border-color: var(--green-dim); }
.todo-input::placeholder { color: var(--muted); }

.todo-add {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--green);
  color: var(--bg);
  border: none;
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.15s;
}
.todo-add:hover { opacity: 0.85; box-shadow: 0 0 16px var(--green-glow); }

.todo-list-demo {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}

.todo-item-demo {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  animation: fadeUp 0.2s ease;
}
.todo-item-demo.done { opacity: 0.4; }
.todo-item-demo.done .todo-txt { text-decoration: line-through; }

.todo-toggle {
  background: none; border: 1px solid var(--green-dim);
  color: var(--green); width: 20px; height: 20px;
  border-radius: 3px; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.todo-toggle:hover { background: rgba(57,255,110,0.15); }
.todo-item-demo.done .todo-toggle {
  background: var(--green-dim); border-color: var(--green-dim);
}

.todo-txt { flex: 1; }

.todo-del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px;
  transition: color 0.15s;
}
.todo-del:hover { color: var(--red); }

.todo-empty-demo {
  text-align: center; color: var(--muted);
  font-size: 12px; padding: 20px;
  font-family: var(--font-sans);
}

/* Signal demo */
.signal-demo {
  width: 100%; max-width: 460px;
}
.signal-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.signal-row:last-child { border-bottom: none; }
.signal-label { font-size: 12px; color: var(--muted); width: 100px; flex-shrink: 0; }
.signal-val {
  font-size: 14px; font-weight: 700;
  color: var(--green);
  font-family: var(--font-mono);
  text-shadow: 0 0 10px var(--green-glow);
  min-width: 80px;
  transition: all 0.15s;
}
.signal-val.flash {
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255,179,71,0.5);
}
.signal-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
}
.signal-input:focus { border-color: var(--green-dim); }

/* ── ABOUT PAGE ──────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
}

.about-card h3 {
  font-size: 13px; color: var(--green);
  margin-bottom: 12px; letter-spacing: 0.5px;
}

.about-card p {
  font-family: var(--font-sans);
  font-size: 14px; color: var(--muted);
  line-height: 1.7;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 20px 0;
}
.api-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 1px;
  font-size: 10px;
  text-transform: uppercase;
}
.api-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(26,42,26,0.5);
  vertical-align: top;
}
.api-table tr:hover td { background: var(--surface2); }
.api-fn  { color: var(--amber); font-weight: 700; }
.api-mod { color: var(--blue); font-size: 11px; }
.api-desc { color: var(--muted); font-family: var(--font-sans); line-height: 1.5; }

.terminal-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  font-size: 13px;
  line-height: 2;
  margin: 20px 0;
}
.t-prompt { color: var(--green); }
.t-prompt::before { content: '$ '; color: var(--muted); }

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 700px) {
  .page { padding: 40px 20px; }
  .hero-title { font-size: 64px; letter-spacing: -2px; }
  .features { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .navbar { padding: 14px 20px; }
  .hero-stats { gap: 24px; }
}

/* ══════════════════════════════════════════
   CORE WEB VITALS — OPTIMIZACIONES
══════════════════════════════════════════ */

/*
  will-change solo en elementos que realmente animan.
  Usarlo en todo causa más daño que beneficio (consume
  memoria de GPU innecesariamente).
*/
.hero-title,
.counter-display,
.signal-val { will-change: transform; }

/*
  Evitar layout shift (CLS) reservando espacio
  para elementos que cargan tarde.
*/
.demo-wrap    { min-height: 260px; }
.features     { min-height: 320px; }
.api-table    { min-height: 400px; }

/*
  Reducir trabajo de paint en animaciones:
  transform y opacity son las únicas propiedades
  que el browser puede animar sin repintar el layout.
  Reemplazamos cualquier animación de color/background
  por estas dos donde sea posible.
*/
.nav-links a,
.btn,
.counter-btn,
.feature,
.about-card,
.habito-row {
  transform: translateZ(0); /* promueve a capa GPU */
}

/*
  prefers-reduced-motion: respeta la configuración
  de accesibilidad del usuario. Google la valora en CWV.
  Si el usuario tiene activado "reducir movimiento",
  apagamos todas las animaciones.
*/
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #cursor { display: none; }
  body::before { display: none; } /* scanlines */
}

/*
  Optimización de fuentes: font-display: optional
  hace que si la fuente del sistema tarda en cargar,
  el browser usa el fallback permanentemente
  (sin FOUT — Flash Of Unstyled Text).
  Con system fonts esto no aplica, pero lo dejamos
  por si en el futuro se auto-hostean fuentes locales.
*/
@font-face {
  font-family: 'Cascadia Code';
  font-display: optional;
  src: local('Cascadia Code'), local('CascadiaCode');
}
@font-face {
  font-family: 'SF Mono';
  font-display: optional;
  src: local('SF Mono'), local('SFMono-Regular');
}
