/* ==========================================================================
   Portfolio — Matías Pérez
   Mobile-first. Breakpoints: 640px (sm) · 768px (md) · 1024px (lg) · 1280px (xl)

   Índice
   1.  Tokens: color, tipografía, espaciado
   2.  Tema oscuro (sistema + elección manual)
   3.  Reset y base
   4.  Utilidades
   5.  Layout: container, secciones, encabezados
   6.  Botones
   7.  Header y navegación
   8.  Hero + terminal
   9.  Sobre mí (ficha estilo neofetch)
   10. Stack
   11. Proyectos
   12. Contacto
   13. Footer
   14. Visor de demos
   15. Animaciones y movimiento reducido
   ========================================================================== */


/* 1. TOKENS
   ========================================================================== */
:root {
  /* Paleta clara — un solo color de acento (naranja) en dos tonos */
  --c-bg: #f7f6f2;
  --c-surface: #ffffff;
  --c-surface-2: #efede7;
  --c-text: #18181b;
  --c-text-muted: #57565e;       /* 6:1 sobre --c-bg */
  --c-border: #dcd9d0;           /* bordes decorativos */
  --c-border-strong: #8a877e;    /* bordes de inputs: 3:1 (WCAG 1.4.11) */
  --c-accent: #c2410c;           /* 4.8:1 sobre --c-bg */
  --c-accent-hover: #9a3412;
  --c-accent-strong: #9a3412;    /* texto de acento sobre fondos tintados */
  --c-accent-soft: rgb(194 65 12 / 0.1);
  --c-on-accent: #ffffff;
  --c-danger: #b91c1c;
  --c-dot: rgb(24 24 27 / 0.14); /* grilla de puntos del hero */

  /* Terminal: siempre oscura, en ambos temas */
  --c-term-bg: #141417;
  --c-term-bar: #1b1b1f;
  --c-term-text: #e4e4e7;
  --c-term-muted: #a1a1aa;
  --c-term-accent: #fb923c;
  --c-term-border: #2c2c33;

  --shadow-sm: 0 1px 2px rgb(24 24 27 / 0.06);
  --shadow-md: 0 10px 30px -12px rgb(24 24 27 / 0.18);
  --shadow-lg: 0 30px 70px -20px rgb(24 24 27 / 0.35);

  /* Tipografía */
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --fs-md: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --fs-lg: clamp(1.1875rem, 1.1rem + 0.45vw, 1.4rem);
  --fs-xl: clamp(1.375rem, 1.2rem + 0.9vw, 1.75rem);
  --fs-2xl: clamp(2.125rem, 1.6rem + 2.6vw, 3.5rem);
  --fs-hero: clamp(2.75rem, 1.5rem + 6.2vw, 6.25rem);

  --lh-tight: 1.02;
  --lh-snug: 1.2;
  --lh-body: 1.65;

  /* Espaciado (escala base 4px) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --section-pad: clamp(4.5rem, 3rem + 6vw, 8.5rem);
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 2rem);
  --container: 72rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --header-h: 4rem;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 180ms;

  /* El esquema por defecto es el del sistema; el toggle lo fija en <meta> y data-theme */
  color-scheme: light dark;
  accent-color: var(--c-accent);
}


/* 2. TEMA OSCURO
   Se aplica si el sistema lo pide (y el usuario no fijó "light"), o si el usuario fijó "dark".
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #0e0e10;
    --c-surface: #16161a;
    --c-surface-2: #1e1e23;
    --c-text: #ededf0;
    --c-text-muted: #a3a3ad;
    --c-border: #2a2a31;
    --c-border-strong: #6b6b75;
    --c-accent: #fb923c;
    --c-accent-hover: #fdba74;
    --c-accent-strong: #fdba74;
    --c-accent-soft: rgb(251 146 60 / 0.12);
    --c-on-accent: #1c0b02;
    --c-danger: #f87171;
    --c-dot: rgb(255 255 255 / 0.09);
    --c-term-bg: #121215;
    --c-term-bar: #18181c;
    --shadow-md: 0 10px 30px -12px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 30px 70px -20px rgb(0 0 0 / 0.75);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #0e0e10;
  --c-surface: #16161a;
  --c-surface-2: #1e1e23;
  --c-text: #ededf0;
  --c-text-muted: #a3a3ad;
  --c-border: #2a2a31;
  --c-border-strong: #6b6b75;
  --c-accent: #fb923c;
  --c-accent-hover: #fdba74;
  --c-accent-strong: #fdba74;
  --c-accent-soft: rgb(251 146 60 / 0.12);
  --c-on-accent: #1c0b02;
  --c-danger: #f87171;
  --c-dot: rgb(255 255 255 / 0.09);
  --c-term-bg: #121215;
  --c-term-bar: #18181c;
  --shadow-md: 0 10px 30px -12px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 30px 70px -20px rgb(0 0 0 / 0.75);
}

:root[data-theme="light"] {
  color-scheme: light;
}


/* 3. RESET Y BASE
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
  scrollbar-gutter: stable;
}

html.has-modal {
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
iframe {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
}

ul[class] {
  list-style: none;
  padding: 0;
}

::selection {
  background: var(--c-accent);
  color: var(--c-on-accent);
}

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

/* Títulos que reciben foco por código (ej. comando "cd"): sin recuadro */
[tabindex="-1"]:focus {
  outline: none;
}

/* "hidden" gana siempre, aunque el componente defina su propio display */
[hidden] {
  display: none !important;
}

/* Íconos SVG (sprite) */
.sprite {
  display: none;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--fill {
  fill: currentColor;
  stroke: none;
}


/* 4. UTILIDADES
   ========================================================================== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.nowrap {
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--c-accent);
  color: var(--c-on-accent);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.noscript-note {
  padding: var(--space-5);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-lg);
  color: var(--c-text-muted);
}


/* 5. LAYOUT
   ========================================================================== */
.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

.section {
  padding-block: var(--section-pad);
  border-top: 1px solid var(--c-border);
}

.section__head {
  max-width: 44rem;
  margin-bottom: clamp(2rem, 1.4rem + 2.4vw, 3.5rem);
}

.section__title {
  font-size: var(--fs-2xl);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.section__lead {
  margin-top: var(--space-4);
  font-size: var(--fs-md);
  color: var(--c-text-muted);
}

/* Eyebrow con forma de request HTTP: "GET /stack 200" */
.eyebrow {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.eyebrow__method {
  color: var(--c-accent);
  font-weight: 500;
}

.eyebrow__status {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
}


/* 6. BOTONES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.875rem;
  padding: 0.7rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--dur) ease,
    border-color var(--dur) ease,
    color var(--dur) ease,
    transform var(--dur) var(--ease-out);
}

.btn .icon {
  width: 1.1em;
  height: 1.1em;
}

.btn--primary {
  background: var(--c-accent);
  color: var(--c-on-accent);
}

.btn--primary:hover {
  background: var(--c-accent-hover);
}

.btn--ghost {
  background: var(--c-surface);
  border-color: var(--c-border);
  color: var(--c-text);
}

.btn--ghost:hover {
  border-color: var(--c-text);
}

.btn--text {
  padding-inline: var(--space-3);
  color: var(--c-text);
  text-decoration: underline;
  text-decoration-color: var(--c-border-strong);
}

.btn--text:hover {
  text-decoration-color: var(--c-accent);
}

.btn--sm {
  min-height: 2.5rem;
  padding: 0.5rem 0.95rem;
  font-size: 0.875rem;
}

/* Deshabilitado con aria-disabled: sigue siendo enfocable y anunciable */
.btn[aria-disabled="true"] {
  background: transparent;
  border: 1px dashed var(--c-border-strong);
  color: var(--c-text-muted);
  cursor: not-allowed;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn:not([aria-disabled="true"]):hover {
    transform: translateY(-1px);
  }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.625rem;
  height: 2.625rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color var(--dur) ease, color var(--dur) ease;
}

.icon-btn:hover {
  border-color: var(--c-text);
}


/* 7. HEADER Y NAVEGACIÓN
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--c-bg) 85%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--c-border);
}

.site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-h);
}

.logo {
  margin-right: auto;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.logo__prompt,
.logo__dot {
  color: var(--c-accent);
}

/* Hamburguesa: alterna ícono según aria-expanded */
.nav__toggle .icon--close,
.nav__toggle[aria-expanded="true"] .icon--open {
  display: none;
}

.nav__toggle[aria-expanded="true"] .icon--close {
  display: block;
}

.nav__list a {
  display: block;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--dur) ease, background-color var(--dur) ease;
}

/* Toggle de tema: luna en claro, sol en oscuro */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  transition: border-color var(--dur) ease;
}

.theme-toggle:hover {
  border-color: var(--c-text);
}

.theme-toggle__sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: none; }
}

:root[data-theme="dark"] .theme-toggle__sun { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }

/* --- Móvil: menú desplegable --- */
@media (max-width: 767.98px) {
  .nav__panel {
    position: absolute;
    top: 100%;
    left: calc(-1 * var(--gutter));
    right: calc(-1 * var(--gutter));
    padding: var(--space-2) var(--gutter) var(--space-5);
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-md);
  }

  .js .nav__panel:not(.is-open) {
    display: none;
  }

  .nav__list a {
    padding: 0.85rem var(--space-2);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid var(--c-border);
    border-radius: 0;
  }

  .nav__list a[aria-current="true"] {
    color: var(--c-accent);
  }

  .theme-toggle {
    width: 100%;
    margin-top: var(--space-4);
    padding: 0.75rem var(--space-4);
    font-size: var(--fs-sm);
    font-weight: 600;
  }

  /* Sin JS: el menú queda visible como lista simple */
  .no-js .nav__toggle { display: none; }
  .no-js .site-header__inner { flex-wrap: wrap; }
  .no-js .nav__panel { position: static; box-shadow: none; border: 0; padding: 0 0 var(--space-3); }
  .no-js .nav__list { display: flex; flex-wrap: wrap; gap: var(--space-3); }
  .no-js .nav__list a { border: 0; font-size: 1rem; padding: var(--space-1) 0; }
  .no-js .theme-toggle { display: none; }
}

/* --- Tablet y desktop: menú horizontal --- */
@media (min-width: 768px) {
  .nav__toggle {
    display: none;
  }

  .nav__panel {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .nav__list {
    display: flex;
    gap: var(--space-1);
  }

  .nav__list a {
    padding: 0.45rem 0.8rem;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
  }

  .nav__list a:hover,
  .nav__list a[aria-current="true"] {
    color: var(--c-text);
    background: var(--c-surface-2);
  }

  .theme-toggle {
    justify-content: center;
    width: 2.625rem;
    height: 2.625rem;
    padding: 0;
  }

  .theme-toggle__text {
    display: none;
  }
}


/* 8. HERO + TERMINAL
   ========================================================================== */
.hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-block: clamp(3rem, 1.5rem + 7vw, 7.5rem) var(--section-pad);
}

/* Grilla de puntos que se desvanece: el "papel cuadriculado" del fondo */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--c-dot) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 70% 35%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse 75% 65% at 70% 35%, #000 25%, transparent 75%);
}

.hero__grid {
  display: grid;
  gap: clamp(2.75rem, 2rem + 3vw, 4.5rem);
  align-items: center;
}

.hero__copy {
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  background: var(--c-surface);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.pulse-dot {
  position: relative;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--c-accent);
}

.hero__title {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.hero__cursor {
  color: var(--c-accent);
  font-weight: 500;
  margin-left: 0.04em;
}

.hero__role {
  margin-top: var(--space-5);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero__sep {
  color: var(--c-accent);
  margin-inline: 0.15em;
}

.hero__lead {
  max-width: 32rem;
  margin-top: var(--space-3);
  font-size: var(--fs-md);
  color: var(--c-text-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.terminal {
  container: terminal / inline-size;
  min-width: 0;
  max-width: 38rem;
  color-scheme: dark;
  background: var(--c-term-bg);
  color: var(--c-term-text);
  border: 1px solid var(--c-term-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  line-height: 1.75;
  overflow: hidden;
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.65rem 1rem;
  background: var(--c-term-bar);
  border-bottom: 1px solid var(--c-term-border);
}

.terminal__dots {
  display: flex;
  gap: 0.4rem;
}

.terminal__dots i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #3a3a42;
}

.terminal__dots i:first-child {
  background: var(--c-term-accent);
}

.terminal__title {
  font-size: 0.75rem;
  color: var(--c-term-muted);
}

.terminal__badge {
  margin-left: auto;
  padding: 0 0.5rem;
  border: 1px solid var(--c-term-border);
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  line-height: 1.6;
  color: var(--c-term-accent);
}

/* Alto fijo: al usarla, la terminal scrollea por dentro y el hero no salta */
.terminal__body {
  height: min(23.5rem, 72vh);
  padding: 1rem 1.15rem 1.25rem;
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #3a3a42 transparent;
}

.terminal :focus-visible {
  outline-color: var(--c-term-accent);
}

.t-line {
  white-space: pre-wrap;
}

.t-prompt,
.t-ok {
  color: var(--c-term-accent);
}

.t-out {
  color: var(--c-term-muted);
}

.t-out + .t-line:not(.t-out) {
  margin-top: 0.35rem;
}

.t-hash {
  color: var(--c-term-text);
}

/* Cursor: bloque de ancho neto cero (no corre el texto ni provoca saltos de línea) */
.t-cursor::after,
.t-line.is-typing .t-typed::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.15em;
  margin-right: -0.55em;
  vertical-align: text-bottom;
  background: var(--c-term-accent);
}

.t-line.is-typing ~ .t-line .t-cursor::after {
  opacity: 0;
}

.t-line.is-pending {
  visibility: hidden;
}

.t-ghost {
  visibility: hidden;
}

/* --- Terminal interactiva --- */
.terminal__prompt {
  display: flex;
  align-items: baseline;
  gap: 1ch;
  margin-top: 0.35rem;
  border-radius: 4px;
}

.terminal__prompt:focus-within {
  outline: 2px solid var(--c-term-accent);
  outline-offset: 2px;
}

.terminal__input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--c-term-text);
  font: inherit;
  line-height: inherit;
  caret-color: var(--c-term-accent);
}

.terminal__input:focus-visible {
  outline: none; /* el foco se marca en toda la línea (.terminal__prompt) */
}

.terminal__input::placeholder {
  color: var(--c-term-muted);
  opacity: 1;
}

.terminal__input:disabled {
  opacity: 0.5;
}

/* En pantallas táctiles, 16px evita que iOS haga zoom al enfocar el input */
@media (pointer: coarse) {
  .terminal__input {
    font-size: 16px;
  }
}

/* Salida de comandos */
.t-echo {
  margin-top: 0.35rem;
  color: var(--c-term-text);
}

.t-key,
.t-ai,
.t-thinking,
.t-link {
  color: var(--c-term-accent);
}

.t-dim {
  color: var(--c-term-muted);
}

.t-strong,
.t-answer {
  color: var(--c-term-text);
}

.t-strong {
  font-weight: 500;
}

.t-answer {
  margin-top: 0.2rem;
}

.t-err::before {
  content: "✗ " / "";
  color: var(--c-term-accent);
}

.t-link {
  text-underline-offset: 0.2em;
}

.t-link:hover {
  color: var(--c-term-text);
}

/* fastfetch: logo ASCII + ficha */
.t-fetch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  align-items: start;
  margin-block: 0.5rem;
  color: var(--c-term-text);
}

.t-fetch__logo {
  margin: 0;
  font: inherit;
  font-size: 0.8em;
  line-height: 1.15;
  white-space: pre;
  color: var(--c-term-accent);
}

.t-fetch__info p {
  white-space: pre-wrap;
}

.t-fetch__palette {
  display: flex;
  margin-top: 0.4rem;
}

.t-fetch__palette i {
  width: 1.6em;
  height: 0.9em;
}

.t-fetch__palette i:nth-child(1) { background: var(--c-term-text); }
.t-fetch__palette i:nth-child(2) { background: var(--c-term-muted); }
.t-fetch__palette i:nth-child(3) { background: #3a3a42; }
.t-fetch__palette i:nth-child(4) { background: var(--c-term-accent); }
.t-fetch__palette i:nth-child(5) { background: #fdba74; }
.t-fetch__palette i:nth-child(6) { background: #9a3412; }

@container terminal (max-width: 30rem) {
  .t-fetch {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Botón que queda después de "exit" */
.terminal-dock {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: var(--c-term-bg);
  color: var(--c-term-muted);
  border: 1px solid var(--c-term-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--dur) ease;
}

.terminal-dock:hover {
  border-color: var(--c-term-accent);
}

.terminal-dock__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #3a3a42;
}

.terminal-dock__action {
  color: var(--c-term-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* echo: el texto "escapado" que aparece corrupto en cualquier lugar de la pantalla */
.stray {
  position: fixed;
  z-index: 60;
  max-width: min(88vw, 30rem);
  font-family: var(--font-mono);
  font-size: clamp(1.125rem, 0.9rem + 1.4vw, 2rem);
  font-weight: 500;
  line-height: 1.25;
  color: var(--c-accent);
  text-shadow: -2px 0 var(--c-border-strong);
  rotate: var(--tilt, 0deg);
  overflow-wrap: anywhere;
  pointer-events: none;
  user-select: none;
}

.stray.is-leaving {
  opacity: 0;
}

@media (min-width: 1024px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  }

  .hero__console {
    justify-self: end;
    width: 100%;
  }
}

/* sudo rm -rf /: la página se rompe y solo queda este mensaje */
.is-nuking,
.is-dead {
  overflow: hidden;
}

.is-dead body {
  background: var(--c-term-bg);
}

.nuke {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-6) var(--gutter);
  background: var(--c-term-bg);
  color: var(--c-term-text);
  color-scheme: dark;
}

.nuke__box {
  width: min(100%, 40rem);
}

.nuke__log {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--c-term-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nuke__prompt {
  color: var(--c-term-accent);
}

.nuke__title {
  margin-top: var(--space-6);
  font-size: var(--fs-2xl);
  line-height: 1.05;
  color: var(--c-term-text);
}

.nuke__text {
  max-width: 34rem;
  margin-top: var(--space-4);
  font-size: var(--fs-md);
  color: var(--c-term-muted);
}

.nuke .btn {
  margin-top: var(--space-6);
}

.nuke__box.is-typing > :not(.nuke__log) {
  visibility: hidden;
}


/* 9. SOBRE MÍ
   ========================================================================== */
.about {
  display: grid;
  gap: clamp(2.5rem, 2rem + 2vw, 4rem);
}

.prose {
  max-width: 40rem;
  font-size: var(--fs-md);
}

.prose p + p {
  margin-top: 1.1em;
}

/* Ficha estilo neofetch */
.fetch {
  min-width: 0;
  max-width: 30rem;
  padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  box-shadow: var(--shadow-sm);
}

.fetch__head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.fetch__avatar {
  position: relative;
  flex-shrink: 0;
  width: 5.5rem;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c-term-bg);
  border: 1px solid var(--c-border);
}

.fetch__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fetch__avatar.is-missing img {
  display: none;
}

.fetch__monogram {
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--c-term-accent);
}

.fetch__host {
  font-size: 1rem;
  font-weight: 500;
  color: var(--c-accent);
}

.fetch__host span,
.fetch__rule {
  color: var(--c-text-muted);
}

.fetch__list {
  display: grid;
  gap: 0.35rem;
}

.fetch__list div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: var(--space-3);
}

.fetch__list dt {
  color: var(--c-accent);
  font-weight: 500;
}

.fetch__list dt::after {
  content: ":";
  color: var(--c-text-muted);
}

.fetch__list dd {
  overflow-wrap: anywhere;
}

/* Los clásicos bloques de color de neofetch, con la paleta del sitio */
.fetch__palette {
  display: flex;
  margin-top: var(--space-5);
}

.fetch__palette i {
  width: 1.75rem;
  height: 0.9rem;
}

.fetch__palette i:nth-child(1) { background: var(--c-text); }
.fetch__palette i:nth-child(2) { background: var(--c-text-muted); }
.fetch__palette i:nth-child(3) { background: var(--c-border-strong); }
.fetch__palette i:nth-child(4) { background: var(--c-border); }
.fetch__palette i:nth-child(5) { background: var(--c-accent); }
.fetch__palette i:nth-child(6) { background: var(--c-accent-hover); }

@media (min-width: 1024px) {
  .about {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
  }

  .fetch {
    justify-self: end;
    width: 100%;
  }
}


/* 10. STACK
   ========================================================================== */
.stack-grid {
  display: grid;
  gap: var(--space-4);
}

.stack-card {
  min-width: 0;
  padding: var(--space-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur) ease;
}

.stack-card:hover {
  border-color: var(--c-border-strong);
}

.stack-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.stack-card__head h3 {
  font-size: var(--fs-lg);
}

.stack-card__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.4;
}

@media (min-width: 640px) {
  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Franja a lo ancho (metodologías): título y chips en una sola fila */
  .stack-card--wide {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-6);
  }

  .stack-card--wide .stack-card__head {
    margin-bottom: 0;
  }
}

@media (min-width: 1280px) {
  .stack-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


/* 11. PROYECTOS
   Grilla: 1 columna en móvil; desde 768px, 2 columnas con el primer proyecto destacado a lo ancho.
   Cada tarjeta es un container: si es ancha (>= 40rem) pasa a layout horizontal.
   ========================================================================== */
.projects {
  display: grid;
  gap: var(--space-5);
}

.project {
  min-width: 0;
  container: project / inline-size;
}

.project__inner {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease, transform var(--dur) var(--ease-out);
}

.project__inner:hover {
  border-color: var(--c-border-strong);
  box-shadow: var(--shadow-md);
}

/* Portada: imagen real o portada generada (mini terminal) */
.project__cover {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--c-term-bg);
  border-bottom: 1px solid var(--c-border);
}

.project__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left; /* que se vean el menú y el encabezado de cada app */
}

.cover-gen {
  color-scheme: dark;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background-image: radial-gradient(rgb(255 255 255 / 0.08) 1px, transparent 1.4px);
  background-size: 18px 18px;
}

.cover-gen__initials {
  position: absolute;
  right: -0.06em;
  bottom: -0.28em;
  font-family: var(--font-display);
  font-size: clamp(7rem, 40cqi, 13rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgb(251 146 60 / 0.35);
  user-select: none;
}

.cover-gen__window {
  position: relative;
  width: min(100%, 22rem);
  background: rgb(18 18 21 / 0.92);
  border: 1px solid var(--c-term-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--c-term-text);
  box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.8);
  transition: transform 300ms var(--ease-out);
}

.cover-gen__bar {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--c-term-border);
}

.cover-gen__bar i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #3a3a42;
}

.cover-gen__bar i:first-child {
  background: var(--c-term-accent);
}

.cover-gen__code {
  padding: 0.65rem 0.85rem 0.8rem;
  overflow-wrap: anywhere;
}

.cover-gen__prompt,
.cover-gen__ok {
  color: var(--c-term-accent);
}

.cover-gen__muted {
  color: var(--c-term-muted);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project__inner:hover .cover-gen__window {
    transform: translateY(-4px) rotate(-0.6deg);
  }
}

.project__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  padding: clamp(1.25rem, 1rem + 1.2vw, 2rem);
}

.project__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.project__title {
  font-size: var(--fs-xl);
  letter-spacing: -0.025em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge__dot {
  position: relative;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.badge--prod {
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.badge--demo {
  border-color: var(--c-border-strong);
  color: var(--c-text-muted);
}

.badge--demo .badge__dot {
  background: transparent;
  border: 1.5px solid currentColor;
}

.badge--tool {
  border-color: var(--c-border-strong);
  color: var(--c-text);
}

.badge--tool .badge__dot {
  border-radius: 2px;
  rotate: 45deg;
  background: var(--c-accent);
}

.project__desc {
  color: var(--c-text);
}

.project__meta {
  display: grid;
  gap: var(--space-3);
  padding-block: var(--space-4);
  border-block: 1px dashed var(--c-border);
}

.project__meta dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-muted);
}

.project__meta dd {
  margin-top: 0.15rem;
  font-size: var(--fs-sm);
}

.project__deploy {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--c-text-muted);
}

.project__deploy .icon {
  margin-top: 0.1em;
  color: var(--c-accent);
}

.project__deploy strong {
  font-weight: 500;
  color: var(--c-text);
}

.project__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
}

@media (min-width: 768px) {
  .projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Primer proyecto destacado; si el último queda solo en su fila, también ocupa todo el ancho */
  .project:first-child,
  .project:last-child:nth-child(even) {
    grid-column: 1 / -1;
  }
}

@container project (min-width: 40rem) {
  .project__inner {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  }

  .project__cover {
    aspect-ratio: auto;
    min-height: 100%;
    border-bottom: 0;
    border-right: 1px solid var(--c-border);
  }
}

@container project (min-width: 56rem) {
  .project__meta {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
  }
}


/* 12. CONTACTO
   ========================================================================== */
.contact {
  display: grid;
  gap: var(--space-6);
}

.contact__links {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur) ease;
}

.contact-card:hover {
  border-color: var(--c-border-strong);
}

.contact-card__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.contact-card__text {
  display: grid;
  min-width: 0;
  flex: 1;
}

.contact-card__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.contact-card__value {
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-card__value:hover {
  text-decoration: underline;
  text-decoration-color: var(--c-accent);
}

.contact-card__copy .icon--check,
.contact-card__copy.is-copied .icon--copy {
  display: none;
}

.contact-card__copy.is-copied .icon--check {
  display: block;
  color: var(--c-accent);
}

/* Formulario */
.form {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
  padding: clamp(1.25rem, 1rem + 1.5vw, 2rem);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
}

.field {
  display: grid;
  gap: var(--space-2);
}

/* Campo trampa para bots: fuera de la vista, pero presente en el formulario */
.form__hp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.field label {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 2.875rem;
  padding: 0.7rem 0.9rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur) ease;
}

.field textarea {
  min-height: 8.5rem;
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline-offset: 1px;
  border-color: var(--c-accent);
}

.field input:user-invalid,
.field textarea:user-invalid {
  border-color: var(--c-danger);
}

.form__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
}

.form__status {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.form__status[data-tone="ok"] {
  color: var(--c-text);
}

.form__status[data-tone="error"] {
  color: var(--c-danger);
}

@media (min-width: 1024px) {
  .contact {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: var(--space-7);
    align-items: start;
  }
}


/* 13. FOOTER
   ========================================================================== */
.site-footer {
  padding-block: var(--space-7);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-5);
}

.site-footer__made {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.site-footer__links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: var(--radius);
  color: var(--c-text);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--c-accent);
}

.site-footer__top {
  padding-inline: var(--space-3);
  border: 1px solid var(--c-border);
}

@media (min-width: 768px) {
  .site-footer__inner {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}


/* 14. VISOR DE DEMOS
   Móvil: pantalla completa. Desde 768px: ventana flotante con selector de ancho.
   ========================================================================== */
.viewer {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--c-bg);
  color: var(--c-text);
  overflow: hidden;
}

.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer::backdrop {
  background: rgb(8 8 10 / 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.viewer__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title actions"
    "url   url";
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.viewer__title {
  grid-area: title;
  min-width: 0;
  overflow: hidden;
  font-size: 1rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.viewer__url {
  grid-area: url;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 0.4rem 0.8rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--c-text-muted);
}

.viewer__url .icon {
  width: 1rem;
  height: 1rem;
}

.viewer__url-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.viewer__devices {
  grid-area: devices;
  display: none;
}

.viewer__actions {
  grid-area: actions;
  display: flex;
  gap: var(--space-2);
}

/* Control segmentado Desktop / Tablet / Móvil */
.segmented {
  padding: 3px;
  gap: 2px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.25rem;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--c-text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.segmented button:hover {
  color: var(--c-text);
}

.segmented button[aria-pressed="true"] {
  background: var(--c-surface);
  color: var(--c-accent);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--c-border);
}

.viewer__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  background-color: var(--c-surface-2);
  background-image: radial-gradient(var(--c-dot) 1px, transparent 1.4px);
  background-size: 20px 20px;
}

.viewer__frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  transition: max-width 350ms var(--ease-out);
}

.viewer__frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.viewer__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--c-surface);
  text-align: center;
}

.viewer__overlay[hidden] {
  display: none;
}

.viewer__loading {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.viewer__host:not(:empty)::before {
  content: " · ";
}

.viewer__fallback {
  max-width: none;
}

.viewer__fallback h3 {
  font-size: var(--fs-xl);
}

.viewer__fallback p:not(.viewer__fallback-code) {
  max-width: 28rem;
  color: var(--c-text-muted);
}

.viewer__fallback-code {
  padding: 0.25rem 0.7rem;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.viewer__hint {
  padding: var(--space-2) var(--space-4);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  font-size: 0.8125rem;
  color: var(--c-text-muted);
}

.viewer__hint a {
  color: var(--c-text);
  font-weight: 600;
}

/* Spinner sobre <progress> indeterminado (semántica nativa) */
.spinner {
  --size: 2.5rem;
  --thickness: 3px;
  width: var(--size);
  height: var(--size);
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: conic-gradient(from 90deg, var(--c-accent) 0 28%, transparent 0) var(--c-border);
  -webkit-mask-image: radial-gradient(farthest-side, transparent calc(100% - var(--thickness)), #000 calc(100% - var(--thickness)));
  mask-image: radial-gradient(farthest-side, transparent calc(100% - var(--thickness)), #000 calc(100% - var(--thickness)));
  animation: spin 0.9s linear infinite;
}

.spinner::-webkit-progress-bar,
.spinner::-webkit-progress-value {
  background: none;
}

.spinner::-moz-progress-bar {
  background: none;
}

@keyframes spin {
  to {
    rotate: 1turn;
  }
}

@media (min-width: 768px) {
  .viewer {
    width: min(100% - 3rem, 92rem);
    height: min(100% - 3rem, 62rem);
    margin: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .viewer__bar {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "title url devices actions";
    padding: var(--space-3) var(--space-4);
  }

  .viewer__title {
    max-width: 14rem;
  }

  .viewer__devices {
    display: inline-flex;
  }

  .viewer__stage {
    padding: var(--space-4);
  }

  .viewer__frame {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
  }

  .viewer__frame[data-device="desktop"] {
    max-width: 100%;
  }

  .viewer__frame[data-device="tablet"] {
    max-width: 768px;
  }

  .viewer__frame[data-device="mobile"] {
    max-width: 390px;
  }
}

/* Entre 768 y 1023px el selector muestra solo íconos */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .segmented__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (min-width: 1024px) {
  .viewer__title {
    max-width: 20rem;
  }
}


/* 15. ANIMACIONES Y MOVIMIENTO REDUCIDO
   Todo lo que se mueve vive dentro de "no-preference": con reduced motion, el sitio queda estático.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  /* Aparición al hacer scroll (la clase .is-visible la pone main.js) */
  .js .reveal {
    opacity: 0;
    translate: 0 18px;
    transition:
      opacity 600ms ease-out,
      translate 700ms var(--ease-out);
    transition-delay: calc(var(--i, 0) * 90ms);
  }

  .js .reveal.is-visible {
    opacity: 1;
    translate: 0 0;
  }

  .hero__cursor,
  .t-cursor::after {
    animation: blink 1.1s steps(1, end) infinite;
  }

  .pulse-dot::after,
  .badge--prod .badge__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: ping 2s var(--ease-out) infinite;
  }

  .js .nav__panel.is-open {
    animation: menu-in 220ms var(--ease-out);
  }

  .viewer[open] {
    animation: viewer-in 260ms var(--ease-out);
  }

  .viewer[open]::backdrop {
    animation: fade-in 260ms ease-out;
  }

  .project__inner:hover {
    transform: translateY(-2px);
  }

  /* Terminal: exit, echo y rm -rf / */
  .hero__console.is-closing .terminal {
    animation: term-close 280ms ease-in forwards;
  }

  .stray {
    animation:
      stray-in 240ms steps(3) both,
      stray-glitch 2.4s steps(1) 240ms infinite;
  }

  .stray.is-leaving {
    opacity: 1;
    animation: stray-out 600ms steps(4) forwards;
  }

  .is-nuking body {
    animation: quake 140ms steps(2) infinite;
  }

  .is-nuked .site-header,
  .is-nuked main > section,
  .is-nuked .site-footer {
    animation: collapse 1s cubic-bezier(0.55, 0, 0.9, 0.45) forwards;
    animation-delay: calc(var(--n, 0) * 60ms);
  }

  /* sudo rm -rf <sección>: se cae sola. main recorta la caída para que no estire la página. */
  .is-shredding main {
    overflow: clip;
  }

  .is-falling {
    position: relative;
    z-index: 1;
    animation: collapse 0.9s cubic-bezier(0.55, 0, 0.9, 0.45) forwards;
  }
}

/* Con reduced motion el spinner no se detiene (indica actividad), solo gira mucho más lento */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 4s;
  }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  70%, 100% { transform: scale(2.6); opacity: 0; }
}

@keyframes menu-in {
  from { opacity: 0; translate: 0 -8px; }
}

@keyframes viewer-in {
  from { opacity: 0; scale: 0.98; }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes term-close {
  to { opacity: 0; scale: 0.94; translate: 0 10px; }
}

@keyframes stray-in {
  from { opacity: 0; clip-path: inset(0 0 100% 0); }
}

/* Cortes horizontales breves cada tanto (sin destellos de brillo) */
@keyframes stray-glitch {
  0%, 12%, 57%, 100% { clip-path: none; translate: 0 0; }
  8% { clip-path: inset(15% 0 55% 0); translate: -6px 0; }
  10% { clip-path: inset(60% 0 10% 0); translate: 5px 0; }
  55% { clip-path: inset(40% 0 35% 0); translate: 4px 0; }
}

@keyframes stray-out {
  to { opacity: 0; clip-path: inset(50% 0 50% 0); }
}

@keyframes quake {
  0% { translate: -3px 1px; }
  50% { translate: 3px -2px; }
  100% { translate: 0 0; }
}

@keyframes collapse {
  to { translate: 0 110vh; rotate: var(--r, 6deg); opacity: 0; }
}
