/* =========================================================================
   El Observatorio — Rubén Peña (Arzuparreta)
   Terminal mono-minimal · fósforo verde sobre negro · sin dependencias
   ========================================================================= */

:root {
  --bg:        #0a0a0a;
  --bg-soft:   #101311;
  --fg:        #e8e8e8;
  --dim:       #707a74;
  --dimmer:    #444b47;
  --accent:    #00ff9c;
  --accent-2:  #00d27f;
  --accent-dim: rgba(0, 255, 156, 0.42);
  --accent-ghost: rgba(0, 255, 156, 0.08);
  --panel-border: rgba(0, 255, 156, 0.16);
  --panel-border-hover: rgba(0, 255, 156, 0.40);
  --panel-bg:  rgba(255, 255, 255, 0.014);
  --warn:      #ffcf5c;
  --bad:       #ff6b6b;

  --mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo,
          Consolas, "Liberation Mono", monospace;
  --r: 4px;
  --glow: 0 0 8px var(--accent-dim);
  --type-scale: 1.4;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: calc(14px * var(--type-scale));
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

b { font-weight: 700; color: var(--fg); }
.accent { color: var(--accent); text-shadow: var(--glow); }
.dim { color: var(--dim); }

/* ---- ambient layers ------------------------------------------------------ */
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.55;
  pointer-events: none;
}

#crt {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background:
    radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px,
                              rgba(0,0,0,0.16) 3px, rgba(0,0,0,0) 4px);
  mix-blend-mode: multiply;
}
#crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0.012;
  animation: flicker 6s steps(60) infinite;
}
@keyframes flicker { 0%,100% { opacity: 0.012; } 50% { opacity: 0.022; } }

/* ---- boot ---------------------------------------------------------------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(20px, 6vw, 80px);
  transition: opacity 0.5s ease;
}
.boot.hidden { opacity: 0; pointer-events: none; }
.boot-log {
  font-family: var(--mono);
  font-size: clamp(calc(12px * var(--type-scale)), calc(1.6vw * var(--type-scale)), calc(15px * var(--type-scale)));
  color: var(--fg);
  white-space: pre-wrap;
  max-width: 720px;
}
.boot-log .ok { color: var(--accent); text-shadow: var(--glow); }
.boot-log .who { color: var(--accent); text-shadow: var(--glow); font-weight: 500; }
.boot-hint {
  margin-top: 24px;
  color: var(--dimmer);
  font-size: calc(12px * var(--type-scale));
  letter-spacing: 0.08em;
}

/* ---- app shell ----------------------------------------------------------- */
.app {
  position: relative;
  z-index: 10;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 2.4vw, 26px);
  gap: clamp(12px, 1.8vw, 20px);
  opacity: 0;
  transition: opacity 0.6s ease 0.1s;
  overflow: hidden;
}
.app.ready { opacity: 1; }

/* ---- topbar -------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
  font-size: calc(13px * var(--type-scale));
}
.topbar-spacer { flex: 1; }
.host { letter-spacing: 0.02em; }
.host .path, .clock { color: var(--fg); }
.clock { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.status {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--dim); text-transform: lowercase;
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
.status.offline { color: var(--bad); }
.status.offline .dot { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- grid ---------------------------------------------------------------- */
.grid {
  display: grid;
  flex: 1.5;
  min-height: 0;
  gap: clamp(12px, 1.4vw, 18px);
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "github transparencia nowplaying"
    "system escenas       escenas";
}
.panel--github       { grid-area: github; }
.panel--transparencia{ grid-area: transparencia; }
.panel--nowplaying   { grid-area: nowplaying; }
.panel--system       { grid-area: system; }
.panel--escenas      { grid-area: escenas; }

/* ---- panel --------------------------------------------------------------- */
.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r);
  padding: 16px 18px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 9px; height: 9px;
  border: 1px solid var(--accent-dim);
  opacity: 0.5;
  transition: opacity 0.3s ease;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.panel:hover {
  border-color: var(--panel-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px -18px var(--accent);
}
.panel:hover::before, .panel:hover::after { opacity: 1; }
.panel--link { cursor: pointer; }
.panel.flash { animation: flash 0.7s ease; }
@keyframes flash {
  0% { box-shadow: inset 0 0 0 1px var(--accent), 0 0 24px -8px var(--accent); }
  100% { box-shadow: none; }
}

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title {
  color: var(--accent);
  text-shadow: var(--glow);
  font-size: calc(11px * var(--type-scale));
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.panel-title::before { content: "▌"; margin-right: 6px; opacity: 0.7; }
.panel-tag { font-size: calc(10px * var(--type-scale)); letter-spacing: 0.1em; color: var(--dimmer); }
.panel-tag.live { color: var(--accent); }
.panel-tag.live::before { content: "● "; }
.panel-tag.sim::before { content: "○ "; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- github -------------------------------------------------------------- */
.spark {
  display: flex; align-items: flex-end; gap: 2px;
  height: 30px; margin-bottom: 12px;
}
.spark i {
  flex: 1;
  min-width: 2px;
  background: var(--accent);
  opacity: 0.85;
  border-radius: 1px;
  box-shadow: 0 0 6px var(--accent-dim);
  transition: height 0.4s ease;
}
.gh-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: calc(13px * var(--type-scale)); margin-bottom: 10px; }
.gh-stats b { color: var(--accent); text-shadow: var(--glow); }
.gh-langs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.lang-chip {
  font-size: calc(11px * var(--type-scale)); padding: 2px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 999px; color: var(--dim);
}
.gh-latest { font-size: calc(12px * var(--type-scale)); margin-top: auto; }
.gh-latest .repo { color: var(--fg); }

/* ---- transparencia ------------------------------------------------------- */
.counter {
  font-size: clamp(calc(30px * var(--type-scale)), calc(4.2vw * var(--type-scale)), calc(46px * var(--type-scale)));
  font-weight: 700;
  line-height: 1.05;
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.counter-label { font-size: calc(12px * var(--type-scale)); color: var(--dim); margin-top: 2px; }
.counter-label .up { color: var(--accent); }
.tr-sub { font-size: calc(12px * var(--type-scale)); margin-top: 8px; }
.tr-ticker {
  margin-top: auto;
  font-size: calc(11.5px * var(--type-scale));
  color: var(--dim);
  border-top: 1px dashed var(--dimmer);
  padding-top: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tr-ticker b { color: var(--fg); }

/* ---- now playing --------------------------------------------------------- */
.np-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.np-art {
  position: relative; flex: 0 0 auto;
  width: 54px; height: 54px; border-radius: 4px; overflow: hidden;
  background: var(--accent-ghost); border: 1px solid var(--panel-border);
  display: grid; place-items: center;
}
.np-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.np-art.has-cover .np-cover { display: block; }
.np-art-glyph { color: var(--accent-dim); font-size: calc(22px * var(--type-scale)); display: none; }
.np-art.idle:not(.has-cover) .np-art-glyph { display: block; }
.np-art.idle:not(.has-cover) .eq { display: none; }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 30px; flex: 0 0 auto; }
.np-art .eq {
  position: absolute; left: 4px; bottom: 4px; height: 14px; gap: 2px;
  padding: 2px 3px; border-radius: 3px;
}
.np-art.has-cover .eq { background: rgba(0, 0, 0, 0.5); }
.np-art .eq i { width: 3px; }
.eq i {
  width: 4px; background: var(--accent); border-radius: 1px;
  box-shadow: 0 0 6px var(--accent-dim);
  height: 30%;
  animation: eq 1s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: .15s; }
.eq i:nth-child(3) { animation-delay: .30s; }
.eq i:nth-child(4) { animation-delay: .45s; }
.eq i:nth-child(5) { animation-delay: .60s; }
.eq.paused i { animation-play-state: paused; height: 18%; }
@keyframes eq { 0%,100% { height: 22%; } 50% { height: 95%; } }
.np-meta { min-width: 0; }
.np-title { font-size: calc(15px * var(--type-scale)); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: calc(12px * var(--type-scale)); }
.np-progress { margin-top: auto; }
.bar { position: relative; height: 4px; background: var(--accent-ghost); border-radius: 999px; overflow: hidden; }
.bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent-dim);
  border-radius: 999px; transition: width 0.9s linear;
}
.np-times { display: flex; justify-content: space-between; font-size: calc(11px * var(--type-scale)); margin-top: 6px; font-variant-numeric: tabular-nums; }
.np-album { font-size: calc(11px * var(--type-scale)); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- system -------------------------------------------------------------- */
.sys-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: calc(13px * var(--type-scale)); margin-bottom: 9px; }
.sys-row b { color: var(--accent); text-shadow: var(--glow); font-variant-numeric: tabular-nums; }
.bar--sm { flex: 1; max-width: 120px; height: 6px; }
.sys-services { display: flex; gap: 12px; flex-wrap: wrap; margin-top: auto; font-size: calc(11px * var(--type-scale)); color: var(--dim); }
.svc { display: inline-flex; align-items: center; gap: 6px; }
.svc .led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.svc.down .led { background: var(--bad); box-shadow: 0 0 6px var(--bad); }

/* ---- escenas ------------------------------------------------------------- */
.esc-body { flex-direction: row; gap: 16px; align-items: flex-start; }
.esc-thumb {
  position: relative; flex: 0 0 auto;
  width: clamp(120px, 22vw, 168px); aspect-ratio: 16 / 9;
  border-radius: 4px; overflow: hidden; display: block;
  border: 1px solid var(--panel-border); background: var(--accent-ghost);
}
.esc-img { width: 100%; height: 100%; object-fit: cover; display: none; }
.esc-thumb.has-img .esc-img { display: block; }
.esc-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(24px * var(--type-scale)); color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.18); transition: background 0.2s ease;
}
.esc-thumb:hover .esc-play { background: rgba(0, 0, 0, 0.04); }
.esc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 6px; }
.esc-quote {
  font-size: clamp(calc(15px * var(--type-scale)), calc(1.9vw * var(--type-scale)), calc(20px * var(--type-scale))); line-height: 1.35; color: var(--fg); font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.esc-film { font-size: calc(12px * var(--type-scale)); }
.esc-more { color: var(--accent); text-decoration: none; font-size: calc(12px * var(--type-scale)); margin-top: auto; }
.esc-more:hover { text-shadow: var(--glow); text-decoration: underline; }

/* ---- console / terminal -------------------------------------------------- */
.console {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--panel-border);
  border-radius: var(--r);
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scrollback {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: calc(13px * var(--type-scale));
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: var(--dimmer) transparent;
}
.scrollback:empty { display: none; }
.scrollback .line { white-space: pre-wrap; word-break: break-word; }
.scrollback .cmd-echo .accent { color: var(--accent); }
.scrollback .out { color: var(--fg); }
.scrollback .out-dim { color: var(--dim); }
.scrollback .out-accent { color: var(--accent); text-shadow: var(--glow); }
.scrollback .out-warn { color: var(--warn); }
.scrollback a { color: var(--accent); }

.prompt-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6ch;
  font-size: calc(14px * var(--type-scale));
  overflow: hidden;
  cursor: text;
}
.prompt-ps1 { white-space: nowrap; }
.prompt-ps1 .path { color: var(--accent-2); }
.prompt-mirror { white-space: pre; color: var(--fg); }
.cursor {
  color: var(--accent);
  text-shadow: var(--glow);
  animation: blink 1.05s steps(1) infinite;
  margin-left: -0.2ch;
}
.prompt-line.typing .cursor { animation: none; }
@keyframes blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }
.cmdline {
  position: absolute;
  inset: 0;
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  letter-spacing: inherit;
  z-index: 2;
}
.console-hint { font-size: calc(11px * var(--type-scale)); letter-spacing: 0.04em; }
.console-hint b { color: var(--accent); }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 880px) {
  .app {
    height: auto;
    overflow: visible;
  }
  .grid {
    flex: none;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "transparencia"
      "nowplaying"
      "github"
      "system"
      "escenas";
  }
  .panel { min-height: 138px; }
  .console { flex: none; }
  .scrollback { flex: none; max-height: 160px; }
  body { font-size: calc(13.5px * var(--type-scale)); }
}
@media (max-width: 560px) {
  .topbar { font-size: calc(12px * var(--type-scale)); gap: 10px; }
  .topbar .host { font-size: calc(12px * var(--type-scale)); }
}

/* ---- motion / a11y ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  #crt::after { display: none; }
  .eq i { height: 50%; }
  .status .dot { opacity: 1; }
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
::selection { background: var(--accent); color: var(--bg); }
