/* Groovy Hosting · sitio estático · CSS sin dependencias */

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/vt323-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/vt323-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fallback con métricas parecidas para reducir el salto cuando entra VT323 */
@font-face {
  font-family: "VT323 Fallback";
  src: local("Courier New"), local("Menlo"), local("Consolas"), local("monospace");
  size-adjust: 88%;
  ascent-override: 80%;
  descent-override: 20%;
}

:root {
  --screen: #0b0506;
  --screen-mid: #170a09;
  --red: #ef3e36;
  --red-dim: #8e2822;
  --red-ink: #3a100d;
  --pink: #f9e1e2;
  --pink-dim: #c9a9aa;
  --gray: #9a9a9a;
  --gray-dim: #4d4544;
  --bezel: #1c1715;
  --bezel-hi: #2c2523;
  --font: "VT323", "VT323 Fallback", ui-monospace, "Courier New", monospace;
  --fs: clamp(1.25rem, 1.05rem + 0.6vw, 1.5rem);
  --measure: 72ch;
  --bezel-w: clamp(6px, 1.2vw, 16px);
  --glow-red: 0 0 1px currentColor, 0 0 10px rgb(239 62 54 / 55%), 0 0 28px rgb(239 62 54 / 25%);
  --glow-pink: 0 0 1px rgb(249 225 226 / 60%), 0 0 8px rgb(249 225 226 / 22%);
}

* { box-sizing: border-box; }

html {
  background: var(--bezel);
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
  @media (prefers-reduced-motion: reduce) { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.35;
  color: var(--pink);
  text-shadow: var(--glow-pink);
  background: var(--screen);
  overflow-x: clip;
}
/* Fondo del tubo: capa fija (background-attachment: fixed no es confiable en iOS) */
.fx-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 50% 40%, var(--screen-mid) 0%, var(--screen) 70%, #050202 100%);
}

::selection { background: var(--red); color: var(--screen); text-shadow: none; }

a {
  color: var(--red);
  text-shadow: var(--glow-red);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover, a:focus-visible { background: var(--red); color: var(--screen); text-shadow: none; text-decoration: none; outline: none; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }

code { font: inherit; color: var(--red); text-shadow: var(--glow-red); }

/* ---------- Marco del monitor ---------- */

.bezel {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  border: var(--bezel-w) solid var(--bezel);
  border-radius: clamp(10px, 2vw, 26px);
  box-shadow:
    inset 0 0 0 1px var(--bezel-hi),
    inset 0 0 60px rgb(0 0 0 / 85%),
    inset 0 0 6px rgb(0 0 0 / 90%);
}

/* ---------- Capas CRT ---------- */

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

.fx-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgb(0 0 0 / 0%) 0px,
    rgb(0 0 0 / 0%) 2px,
    rgb(0 0 0 / 28%) 3px,
    rgb(0 0 0 / 28%) 4px
  );
  mix-blend-mode: multiply;
}

.fx-vignette {
  background: radial-gradient(ellipse 85% 80% at 50% 50%, transparent 55%, rgb(0 0 0 / 55%) 100%);
}

/* Banda que recorre la pantalla de arriba a abajo (solo con motion permitido) */
.fx-roll {
  display: none;
  background: linear-gradient(to bottom, transparent 0%, rgb(249 225 226 / 4%) 45%, rgb(249 225 226 / 7%) 50%, rgb(249 225 226 / 4%) 55%, transparent 100%);
  background-size: 100% 22vh;
  background-repeat: no-repeat;
  @media (prefers-reduced-motion: no-preference) {
    display: block;
    animation: roll 9s linear infinite;
  }
}
@keyframes roll {
  from { background-position: 0 -25vh; }
  to   { background-position: 0 125vh; }
}

/* Parpadeo sutil del fósforo. Variación de opacidad < 5 %, muy lejos de un destello. */
.screen {
  @media (prefers-reduced-motion: no-preference) {
    animation: flicker 0.18s infinite;
  }
}
@keyframes flicker {
  0%   { opacity: 1; }
  30%  { opacity: 0.975; }
  55%  { opacity: 0.99; }
  80%  { opacity: 0.965; }
  100% { opacity: 1; }
}

/* Encendido: una línea que se abre hacia arriba y abajo, como un tubo viejo */
.screen.is-powering {
  animation: poweron 0.9s cubic-bezier(.2,.9,.3,1) both;
  transform-origin: 50% 50%;
}
@keyframes poweron {
  0%   { transform: scale(1, 0.003); filter: brightness(14) saturate(0); }
  38%  { transform: scale(1, 0.003); filter: brightness(14) saturate(0); }
  60%  { transform: scale(1, 1);     filter: brightness(3); }
  100% { transform: scale(1, 1);     filter: brightness(1); }
}

/* Con los efectos apagados */
html[data-fx="off"] .fx-scanlines,
html[data-fx="off"] .fx-roll,
html[data-fx="off"] .fx-vignette { display: none; }
html[data-fx="off"] .screen { animation: none; }
html[data-fx="off"] * { text-shadow: none !important; }

/* ---------- Arranque ---------- */

.boot {
  position: fixed; inset: 0; z-index: 25;
  background: var(--screen);
  padding: calc(var(--bezel-w) + 1.5rem);
  color: var(--pink-dim);
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  transition: opacity 0.35s ease;
}
.boot[hidden] { display: none; }
.boot.is-done { opacity: 0; }
.boot-log { margin: 0; white-space: pre-wrap; font: inherit; }
.boot-log .ok { color: var(--red); }

/* ---------- Pantalla / layout ---------- */

.screen {
  position: relative; z-index: 10;
  padding: calc(var(--bezel-w) + 0.75rem) calc(var(--bezel-w) + clamp(0.75rem, 4vw, 2.5rem)) calc(var(--bezel-w) + 2rem);
  max-width: calc(var(--measure) + 2 * var(--bezel-w) + 2 * clamp(0.75rem, 4vw, 2.5rem));
  margin-inline: auto;
}

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 0.5rem; margin-bottom: 1.5rem;
  border-bottom: 2px dashed var(--red-dim);
  color: var(--gray);
}
.topbar p { margin: 0; }
.topbar-id .k { color: var(--red); text-shadow: var(--glow-red); }
.topbar-clock { margin-left: auto; font-variant-numeric: tabular-nums; }
.fx-toggle {
  font: inherit; color: var(--pink); background: transparent;
  border: 2px solid var(--red-dim); padding: 0.1em 0.6em; cursor: pointer;
  text-shadow: inherit;
}
.fx-toggle:hover, .fx-toggle:focus-visible { background: var(--red); color: var(--screen); border-color: var(--red); text-shadow: none; }

.muted { color: var(--gray); text-shadow: none; }

/* Línea de comando que precede a cada sección */
.cmd { margin: 0 0 0.25rem; color: var(--gray); text-shadow: none; }
.cmd .prompt, .prompt { color: var(--red); text-shadow: var(--glow-red); }
.cmd.end { margin-top: 1.5rem; }

h1, h2, h3 { font-weight: 400; line-height: 1.1; margin: 0; color: var(--red); text-shadow: var(--glow-red); }
h2 { font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.6rem); margin-bottom: 0.4rem; }
h2::before { content: "## "; color: var(--red-dim); text-shadow: none; }
h3 { font-size: 1.15em; color: var(--pink); text-shadow: var(--glow-pink); }

section { margin-bottom: clamp(2.5rem, 6vw, 4rem); }
section p { margin: 0 0 0.9rem; max-width: var(--measure); }

/* ---------- Portada ---------- */

.hero .logo { margin: 0.5rem 0 1rem; }
.hero .logo img {
  display: block; width: min(560px, 88vw); height: auto;
  filter: drop-shadow(0 0 6px rgb(239 62 54 / 55%)) drop-shadow(0 0 28px rgb(239 62 54 / 30%));
}
html[data-fx="off"] .hero .logo img { filter: none; }

.tagline {
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem);
  color: var(--red); text-shadow: var(--glow-red);
  margin: 0 0 0.75rem;
}
/* Texto que se escribe solo (CSS puro) y cursor que parpadea.
   VT323 es monoespaciada: 42 caracteres = 42ch, así el cursor queda pegado al texto. */
.typed {
  --chars: 42;
  display: inline-block; vertical-align: bottom;
  border-right: 0.5em solid var(--red);
  @media (prefers-reduced-motion: no-preference) and (min-width: 48rem) {
    white-space: nowrap; overflow: hidden;
    width: 0;
    animation: typing 2.2s steps(var(--chars)) 1.1s forwards, caret 1s steps(1) infinite;
  }
  @media (max-width: 47.99rem) {
    border-right: 0;
    &::after { content: "\2588"; margin-left: 0.15em; }
    @media (prefers-reduced-motion: no-preference) { &::after { animation: blink 1s steps(1) infinite; } }
  }
}
/* +0.2em de holgura: el redondeo de ch cortaba el último carácter */
@keyframes typing { to { width: calc(var(--chars) * 1ch + 0.2em); } }
@keyframes caret { 50% { border-color: transparent; } }

.cursor::after {
  content: "\2588"; color: var(--red); text-shadow: var(--glow-red);
  @media (prefers-reduced-motion: no-preference) { animation: blink 1s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

.lede { font-size: 1.05em; }

.jump { display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; margin-top: 1.25rem; }

/* ---------- Estado ---------- */

.panels {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  margin-top: 1rem;
}
.panel {
  border: 2px solid var(--red-dim);
  padding: 0.75rem 1rem 0.5rem;
  background: rgb(239 62 54 / 4%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 60%);
  container-type: inline-size;
}
.panel-wide { grid-column: span 2; }
@media (max-width: 36rem) { .panel-wide { grid-column: span 1; } }
.panel h3 { margin-bottom: 0.25rem; }
.panel p { margin: 0 0 0.4rem; }
.big {
  font-size: clamp(2.4rem, 2rem + 2.5vw, 3.6rem); line-height: 1;
  color: var(--red); text-shadow: var(--glow-red);
  font-variant-numeric: tabular-nums;
}
.uptime small { font-size: 0.45em; color: var(--pink); text-shadow: var(--glow-pink); }

/* ---------- Servicios ---------- */

.service-list { margin: 1rem 0 0; }
.service { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; gap: 0.25rem 1.5rem; padding: 0.7rem 0; border-top: 1px dashed var(--gray-dim); }
.service:last-child { border-bottom: 1px dashed var(--gray-dim); }
.service dt { color: var(--red); text-shadow: var(--glow-red); font-size: 1.25em; }
.service dt::before { content: "> "; color: var(--red-dim); text-shadow: none; }
.service dd { margin: 0; max-width: 58ch; }
@media (max-width: 40rem) { .service { grid-template-columns: 1fr; } }

/* ---------- Terminal ---------- */

.terminal { border: 2px solid var(--red-dim); padding: 0.75rem 1rem 1rem; background: rgb(0 0 0 / 35%); }
.terminal .cmd { margin-top: 0; }
.term-out { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.7em; max-height: 50vh; overflow-y: auto; margin: 0.5rem 0; }
.term-out .in { color: var(--gray); }
.term-out .in .prompt { color: var(--red); }
.term-out .err { color: var(--red); text-shadow: var(--glow-red); }
.term-form { display: flex; gap: 0.5rem; align-items: baseline; }
.term-form input {
  flex: 1 1 10ch; min-width: 0;
  font: inherit; color: var(--pink); background: transparent; border: 0; outline: none;
  caret-color: var(--red); text-shadow: inherit; padding: 0;
}
.term-form input:focus-visible { outline: none; box-shadow: 0 2px 0 var(--red); }

/* ---------- Pie ---------- */

.foot { margin-top: 3rem; padding-top: 1rem; border-top: 2px dashed var(--red-dim); }
.foot p { margin: 0 0 0.5rem; max-width: var(--measure); }

/* ---------- Utilidades ---------- */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
