/* ═══════════════════════════════════════════════════════════════════
   hybridlabs terminal theme — v1
   A shared TUI/terminal aesthetic for hybridlabs.dev apps.
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
  /* palette */
  --green:        #33ff33;
  --green-dim:    #1f9e1f;
  --amber:        #ffb000;
  --red:          #ff4444;
  --blue:         #66aaff;
  --dim:          #aaaaaa;
  --muted:        #666666;

  /* structure */
  --border:       #333333;
  --border-bright:#555555;
  --bg:           #0d0d0d;
  --bg-raise:     #141414;
  --bg-sunken:    #0a0a0a;

  /* desktop chrome */
  --desktop-light:#c8c8c8;
  --desktop-dark: #1a1a1a;
  --titlebar:     #2d2d2d;
  --title-text:   #888888;

  /* typography */
  --font-mono:    'Courier New', Courier, monospace;
}

html, body { min-height: 100vh; }
body {
  font-family: var(--font-mono);
  color: var(--dim);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: var(--desktop-light);
}
@media (prefers-color-scheme: dark) {
  body { background: var(--desktop-dark); }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── terminal window ──────────────────────────────────────────────── */
.terminal {
  width: min(90vw, 860px);
  height: min(82vh, 560px);
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.25s ease, height 0.25s ease, border-radius 0.25s ease;
  transform-origin: center;
}
/* wide variant for apps that need more space */
.terminal.wide {
  width: min(96vw, 1200px);
  height: auto;
  min-height: min(90vh, 820px);
}
.terminal.minimized {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 260px;
  height: auto;
  min-height: 0;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.terminal.minimized .terminal-body { display: none; }
.terminal.minimized .terminal-title {
  position: static;
  flex: 1;
  text-align: left;
  padding-left: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.terminal.fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
}
body.fullscreen { padding: 0; }

.terminal-titlebar {
  background: var(--titlebar);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.terminal-dots { display: flex; gap: 7px; position: relative; z-index: 1; }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: filter 0.15s;
}
.dot:hover { filter: brightness(1.3); }
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }
.terminal-title {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--title-text);
  pointer-events: none;
  font-family: var(--font-mono);
}

.terminal-body {
  background: var(--bg);
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* scanline overlay */
.terminal-body::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}
.terminal-body.no-scanlines::after { display: none; }

/* ── screens (for multi-screen apps like grub) ────────────────────── */
.screen {
  width: 100%;
  height: 100%;
  padding: 28px;
  display: none;
  flex-direction: column;
  justify-content: center;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.55;
  outline: none;
  overflow: hidden;
}
.screen.active { display: flex; }

/* flicker animation on screen change */
@keyframes flicker {
  0%   { opacity: 1; }
  10%  { opacity: 0.3; }
  12%  { opacity: 1; }
  20%  { opacity: 0.7; }
  22%  { opacity: 1; }
  80%  { opacity: 1; }
  90%  { opacity: 0.5; }
  92%  { opacity: 1; }
  100% { opacity: 1; }
}
.flicker { animation: flicker 0.25s ease-in-out; }

@keyframes fadeIn { to { opacity: 1; } }
.fade-in { opacity: 0; animation: fadeIn 0.06s forwards; }

/* ── typography helpers ───────────────────────────────────────────── */
.t-green { color: var(--green); }
.t-amber { color: var(--amber); }
.t-red   { color: var(--red); }
.t-blue  { color: var(--blue); }
.t-dim   { color: var(--dim); }
.t-muted { color: var(--muted); }

.log-ok   { color: var(--green); }
.log-warn { color: var(--amber); }
.log-fail { color: var(--red); }
.log-dim  { color: var(--dim); }

/* ── boxes (border + optional title header) ───────────────────────── */
.tbox {
  border: 1px solid var(--border-bright);
  background: var(--bg);
}
.tbox-title {
  text-align: center;
  color: #ccc;
  font-size: 13px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.tbox-body { padding: 12px 16px; }

/* ── bracketed TUI buttons ────────────────────────────────────────── */
.abtn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border-bright);
  border-radius: 2px;
  background: var(--bg);
  color: var(--dim);
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.abtn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--bg-sunken);
}
.abtn:not(select)::before { content: '[ '; color: var(--muted); }
.abtn:not(select)::after  { content: ' ]'; color: var(--muted); }
.abtn:not(select):hover::before,
.abtn:not(select):hover::after { color: var(--green); }

select.abtn {
  appearance: auto;
  background-color: var(--bg);
  color: var(--green);
}
select.abtn option { background: var(--bg); color: var(--green); }

.abtn.amber {
  border-color: var(--amber);
  color: var(--amber);
}
.abtn.amber:hover { background: rgba(255,176,0,0.1); border-color: var(--amber); color: var(--amber); }
.abtn.amber::before, .abtn.amber::after { color: var(--amber); }

.abtn.red {
  color: var(--red);
}
.abtn.red:hover { border-color: var(--red); background: rgba(255,68,68,0.08); color: var(--red); }
.abtn.red::before, .abtn.red::after { color: var(--muted); }
.abtn.red:hover::before, .abtn.red:hover::after { color: var(--red); }

/* minimal (no brackets) */
.abtn.plain::before, .abtn.plain::after { content: none; }

/* ── toggle group (segmented control) ─────────────────────────────── */
.tog-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}
.tog-group button {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 12px;
  border: none;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background 0.12s, color 0.12s;
}
.tog-group button:hover {
  background: var(--desktop-dark);
  color: var(--green);
}
.tog-group button.active {
  background: var(--green);
  color: #000;
  font-weight: bold;
}

/* vertical separator between inline controls */
.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── form inputs ──────────────────────────────────────────────────── */
.tinput,
input[type="text"].tinput,
input[type="number"].tinput,
input[type="search"].tinput,
input[type="email"].tinput,
input[type="password"].tinput,
textarea.tinput {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 2px;
  color: var(--green);
  outline: none;
  caret-color: var(--green);
}
.tinput:focus { border-color: var(--green); }
.tinput::placeholder { color: var(--muted); }

/* ── prompt line (custom> ...) ────────────────────────────────────── */
.prompt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.prompt-line .prompt {
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}
.prompt-line .mul { color: var(--muted); font-size: 12px; }

/* ── bare command prompt (no box) ─────────────────────────────────── */
.cmd-prompt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.cmd-prompt .prompt { color: var(--green); white-space: nowrap; }
.cmd-prompt input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 13px;
  flex: 1;
  caret-color: var(--green);
}

/* ── section label (// furniture, >> group) ───────────────────────── */
.section-label {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
}
.section-label.amber {
  color: var(--amber);
  font-size: 11px;
  text-transform: lowercase;
}
.section-label.amber::before { content: '>> '; color: var(--muted); }

/* ── tip / callout box ────────────────────────────────────────────── */
.tip {
  font-size: 12px;
  color: var(--dim);
  padding: 10px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--amber);
  border-radius: 3px;
  line-height: 1.7;
}
.tip strong { color: var(--green); font-weight: normal; }
.tip em     { color: var(--amber); font-style: normal; }
.tip .tip-tag { color: var(--amber); margin-right: 6px; }
.tip.red    { border-color: var(--red); }
.tip.red .tip-tag { color: var(--red); }
.tip.green  { border-color: var(--green); }
.tip.green .tip-tag { color: var(--green); }

/* ── progress bar ─────────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 6px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress > .fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 0.12s ease;
}
.progress-label { font-size: 12px; color: var(--dim); margin-bottom: 4px; }

/* ── table (UEFI-style rows with selectable highlight) ────────────── */
.ttable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ttable tr { border-bottom: 1px solid #222; }
.ttable td { padding: 6px 8px; color: var(--dim); }
.ttable td.val { color: var(--amber); }
.ttable tr.sel td { background: var(--amber); color: #000; }
.ttable tr.sel td.val { color: #000; }
.ttable.selectable tr { cursor: pointer; }
/* bordered header/footer strip (like BIOS UI) */
.tstrip {
  background: var(--dim);
  color: #000;
  padding: 5px 14px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.tstrip.footer {
  background: transparent;
  color: var(--muted);
  border-top: 1px solid var(--border-bright);
  padding: 8px 14px;
  font-size: 11px;
  text-align: center;
  justify-content: center;
}

/* ── list entries (grub menu style) ───────────────────────────────── */
.entry-list { display: flex; flex-direction: column; }
.entry {
  padding: 4px 16px;
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  -webkit-user-select: none;
}
.entry.sel { background: var(--dim); color: #000; }

/* ── reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .flicker, .fade-in { opacity: 1 !important; }
}
