/* ============================================================
   Distrolab — phosphor-terminal meets modern glass
   ============================================================ */

:root {
  --bg:        #070a0f;
  --surface:   #0e131c;
  --surface-2: #131a26;
  --surface-3: #182031;
  --border:    #1e2734;
  --border-lit:#2b3646;
  --text:      #d9e2ee;
  --text-dim:  #9aa7b8;
  --text-mut:  #7c8a9c;
  --accent:    #57d977;
  --accent-dk: #2f7a45;
  --accent-gl: rgba(87, 217, 119, 0.16);
  --amber:     #ffb454;
  --danger:    #ff6b6b;
  --radius:    14px;
  --radius-sm: 9px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* -------- background layers -------- */
.bg-grid {
  position: fixed; inset: 0; z-index: -2;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 100% 70% at 50% 0%, #000 40%, transparent 100%);
}
.bg-glow {
  position: fixed; top: -320px; left: 50%; transform: translateX(-50%);
  width: 1100px; height: 700px; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at center, var(--accent-gl), transparent 62%);
  filter: blur(30px);
}

/* -------- shared -------- */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 0.08em 0.4em; border-radius: 5px; color: #cbd5e4;
}
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }

.muted { color: var(--text-mut); }

.btn {
  font: 600 13px/1 var(--sans);
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-lit); border-radius: var(--radius-sm);
  padding: 9px 15px; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: #3a4759; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--accent); color: #06210f; border-color: transparent;
  box-shadow: 0 0 0 1px var(--accent-dk) inset, 0 6px 20px -8px var(--accent);
}
.btn-primary:hover { background: #67e587; }

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

/* -------- topbar -------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(7, 10, 15, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-name {
  font-family: var(--mono); font-weight: 700; font-size: 16px;
  color: var(--text); letter-spacing: -0.01em;
}
.brand-name::after { content: "_"; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.topnav { display: flex; gap: 22px; font-size: 13px; font-weight: 500; }
.topnav a { color: var(--text-dim); }
.topnav a:hover { color: var(--text); text-decoration: none; }

main { max-width: 1140px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 44px;
  align-items: center;
  padding: clamp(48px, 9vw, 96px) 0 clamp(40px, 7vw, 72px);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--text-dim); text-transform: uppercase;
  margin: 0 0 20px;
}
.eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.55;transform:scale(.8)} }

.hero h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.5rem);
  font-weight: 700; letter-spacing: -0.035em;
}
.lede {
  color: var(--text-dim); font-size: 1.02rem; max-width: 46ch;
  margin: 20px 0 30px;
}
.lede code { font-size: 0.82em; }

/* dropzone */
.dropzone {
  border: 1.5px dashed var(--border-lit); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), rgba(14,19,28,0.4));
  padding: 30px 24px; text-align: center; cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
  color: var(--text-dim);
}
.dropzone:hover { border-color: #3d4b5f; color: var(--text); }
.dropzone.is-drag {
  border-color: var(--accent); background: var(--accent-gl);
  color: var(--text); transform: scale(1.012);
}
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-title { margin: 6px 0 0; font-weight: 600; color: var(--text); font-size: 0.98rem; }
.dz-title span { color: var(--text-mut); font-weight: 400; }
.dz-hint { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--text-mut); }

.url-row { display: flex; gap: 8px; margin: 14px 0 22px; }
.url-row input {
  flex: 1; min-width: 0;
  font: 400 13px/1 var(--mono);
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 13px;
}
.url-row input::placeholder { color: var(--text-mut); }
.url-row input:focus { border-color: var(--border-lit); outline: none; }

.hero-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-dim);
}
.hero-meta .sep { color: var(--border-lit); }
.mem-select {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-mut);
}
.mem-select select {
  font: 500 12px/1 var(--mono); text-transform: none; letter-spacing: 0;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px;
}
.net-select {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-mut);
}
.net-select input { accent-color: var(--accent); }

/* hero terminal card */
.hero-terminal {
  background: #05070b; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 30px 80px -40px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.02) inset;
}
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 13px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.term-bar span { width: 10px; height: 10px; border-radius: 50%; background: #2a3342; }
.term-bar span:first-child { background: #ff5f57; }
.term-bar span:nth-child(2) { background: #febc2e; }
.term-bar span:nth-child(3) { background: #28c840; }
.term-bar em {
  margin-left: auto; font-family: var(--mono); font-style: normal;
  font-size: 11px; color: var(--text-mut);
}
.term-body {
  margin: 0; padding: 16px 16px 22px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  color: #9fb0c3; white-space: pre-wrap; min-height: 232px;
}
.term-body .ok { color: var(--accent); }
.term-body .warn { color: var(--amber); }
.term-body .cmd { color: var(--text); }
.term-body .cur {
  display: inline-block; width: 8px; height: 15px; vertical-align: -3px;
  background: var(--accent); animation: blink 1.1s steps(1) infinite;
}

/* ============================================================
   LIBRARY
   ============================================================ */
.library { padding: 30px 0 20px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 14px;
}
.section-head h2, .how h2 { font-size: 1.5rem; }
.filters { display: flex; gap: 6px; }
.chip {
  font: 500 12px/1 var(--sans);
  color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; transition: all .14s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-lit); }
.chip.is-active { color: #06210f; background: var(--accent); border-color: transparent; }

.library-note {
  font-size: 13px; color: var(--text-mut); margin: 12px 0 22px; max-width: 70ch;
}
.library-note code { font-size: 0.85em; }

.distro-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px;
}
.distro-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.distro-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--card-accent, var(--accent)); opacity: .8;
}
.distro-card:hover {
  transform: translateY(-3px); border-color: var(--border-lit);
  box-shadow: 0 24px 50px -30px rgba(0,0,0,0.7);
}
.dc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dc-name { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--text); }
.dc-ver {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mut);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; white-space: nowrap;
}
.dc-blurb { font-size: 13px; color: var(--text-dim); margin: 10px 0 16px; flex: 1; }
.dc-specs {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mut);
  margin-bottom: 14px;
}
.dc-specs b { color: var(--text-dim); font-weight: 500; }
.dc-actions { display: flex; align-items: center; gap: 10px; }
.dc-src { font-size: 11.5px; color: var(--text-mut); margin-left: auto; }
.dc-missing {
  font-family: var(--mono); font-size: 10.5px; color: var(--amber);
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
}
.distro-card.no-image { opacity: .82; }

/* ============================================================
   HOW / FAQ
   ============================================================ */
.how { padding: 56px 0 40px; }
.how-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  margin: 26px 0 34px;
}
.how-grid article {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.how-num {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  letter-spacing: 0.1em;
}
.how-grid h3 { font-size: 1.02rem; margin: 12px 0 8px; }
.how-grid p { font-size: 13.5px; color: var(--text-dim); margin: 0; }

.faq {
  border-top: 1px solid var(--border); padding: 16px 2px;
}
.faq summary {
  cursor: pointer; font-weight: 600; font-size: 14.5px;
  list-style: none; display: flex; align-items: center; gap: 10px;
}
.faq summary::before {
  content: "+"; font-family: var(--mono); color: var(--accent);
  transition: transform .2s var(--ease);
}
.faq[open] summary::before { transform: rotate(45deg); }
.faq p { color: var(--text-dim); font-size: 13.5px; margin: 12px 0 4px 22px; max-width: 74ch; }

/* ============================================================
   MACHINE VIEW
   ============================================================ */
#machine { padding: 26px 0 50px; }
.machine-topline {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.machine-id { display: flex; align-items: center; gap: 10px; }
.machine-id strong { font-family: var(--mono); font-size: 14px; }
.led {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text-mut);
  flex-shrink: 0;
}
.led[data-state="booting"] { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1.1s infinite; }
.led[data-state="running"] { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.led[data-state="paused"]  { background: var(--amber); }
.led[data-state="error"]   { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.machine-stats {
  margin-left: auto; display: flex; align-items: center; gap: 14px;
  font-family: var(--mono); font-size: 12px; color: var(--text-mut);
}
.machine-stats b { color: var(--accent); font-weight: 500; }
#shareBtn { padding: 6px 11px; font-family: var(--mono); font-size: 11px; }

/* queued-command bar */
.cmd-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border-lit); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-dim);
}
.cmd-bar code { font-size: 12px; color: var(--text); background: var(--surface-2); }
.cmd-bar .btn { padding: 6px 12px; }
.cmd-bar .mini { margin-left: auto; font-size: 14px; padding: 2px 8px; }

/* key bar */
.keybar {
  display: flex; gap: 6px; margin-top: 12px; padding-bottom: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.keybar button {
  flex: 0 0 auto;
  font: 500 11px/1 var(--mono);
  color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; cursor: pointer; white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.keybar button:hover { background: var(--surface-3); color: var(--text); }
.keybar button:active { transform: translateY(1px); }
.keybar .kb-gap { flex: 0 0 auto; width: 1px; background: var(--border); margin: 4px 2px; }

.machine-body {
  display: grid; grid-template-columns: 1fr 320px; gap: 16px;
  align-items: start;
}
.screen-wrap {
  position: relative; background: #000;
  border: 1px solid var(--border-lit); border-radius: var(--radius);
  overflow: hidden; min-height: 420px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.02) inset, 0 30px 70px -40px #000;
}
#screen_container {
  color: #e8e8e8; background: #000;
}
#screen_container > .v86-text {
  white-space: pre; font: 14px/1 var(--mono); color: #d7d7d7;
  padding: 8px; display: block;
}
#screen_container > canvas {
  display: block; image-rendering: pixelated;
  max-width: 100%; height: auto;
}
.screen-wrap.crt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.18) 2px 4px
  );
  mix-blend-mode: multiply;
}
.screen-wrap.crt::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,0.35));
}
.screen-wrap:fullscreen { border-radius: 0; }
.screen-wrap:fullscreen #screen_container > canvas { max-height: 100vh; width: auto; }

.boot-progress {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(5,7,11,0.92); font-family: var(--mono); font-size: 12px; color: var(--text-dim);
}
.boot-progress .bar {
  width: 240px; height: 3px; background: var(--surface-3); border-radius: 3px; overflow: hidden;
}
.boot-progress .bar i {
  display: block; height: 100%; width: 30%; background: var(--accent);
  transition: width .3s var(--ease);
}

/* console panel */
.console-panel {
  background: #05070b; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; height: 100%;
  max-height: 560px;
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}
.mini {
  font: 400 10.5px/1 var(--mono); color: var(--text-mut);
  background: none; border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 7px; cursor: pointer;
}
.mini:hover { color: var(--text); }
.serial-out {
  flex: 1; margin: 0; padding: 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  color: #93c9a6; white-space: pre-wrap; word-break: break-word;
  overflow-y: auto; min-height: 300px;
}
.serial-in { border-top: 1px solid var(--border); }
.serial-in input {
  width: 100%; border: 0; background: #080b11;
  font: 400 12px/1 var(--mono); color: var(--text);
  padding: 11px 12px;
}
.serial-in input:focus { outline: none; background: #0b0f16; }

/* toolbar */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.tb-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--sans); color: var(--text-dim); cursor: pointer;
  padding: 0 4px;
}
.tb-toggle input { accent-color: var(--accent); }
.toolbar .btn-ghost { margin-left: auto; }

/* ============================================================
   FOOTER / TOAST
   ============================================================ */
.site-foot {
  max-width: 1140px; margin: 40px auto 0; padding: 26px clamp(16px,4vw,40px) 50px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
}
.site-foot p { margin: 4px 0; }

/* embed mode: ?embed=1 — just the machine, no page chrome */
html.embed .topbar,
html.embed .site-foot { display: none; }
html.embed main { padding: 0; max-width: none; }
html.embed #machine { padding: 10px; }
html.embed .machine-body { min-height: calc(100vh - 160px); }
html.embed .screen-wrap { min-height: calc(100vh - 210px); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--surface-3); border: 1px solid var(--border-lit);
  color: var(--text); font-size: 13px; font-weight: 500;
  padding: 12px 18px; border-radius: 10px; z-index: 100;
  box-shadow: 0 20px 50px -20px #000; opacity: 0;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  max-width: min(90vw, 460px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[data-kind="error"] { border-color: var(--danger); }
.toast[data-kind="ok"] { border-color: var(--accent-dk); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .hero-terminal { order: -1; }
  .machine-body { grid-template-columns: 1fr; }
  .console-panel { max-height: 320px; }
  .how-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topnav { display: none; }
  .machine-stats { margin-left: 0; width: 100%; }
  .toolbar .btn-ghost { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
