/* styles.css — terminal portfolio. Theme values live in CSS custom properties,
   set by themes.js (defaults below mirror the `briosso` palette for first paint). */

:root {
  --t-bg: #0e1014;
  --t-panel: #161922;
  --t-panelAlt: #1b1f2a;
  --t-fg: #d9d6cd;
  --t-dim: #8a8579;
  --t-muted: #7a7870;
  --t-comment: #6b6e78;
  --t-border: #23262f;
  --t-accent: #d4915d;
  --t-accent2: #6cb6ff;
  --t-green: #8fbf73;
  --t-red: #e06c75;
  --t-yellow: #e3b341;
  --t-magenta: #c67dd6;
  --t-cyan: #56b6c2;
}

* { box-sizing: border-box; }

/* visually hidden, but present in the DOM for crawlers, AI search, and screen readers */
.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;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--t-bg);
  color: var(--t-fg);
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
  /* faint dot grid behind the window */
  background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
}
body[data-theme="paper"] {
  background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
}

::selection { background: rgba(212, 145, 93, 0.28); }
body[data-theme="paper"] ::selection { background: rgba(176, 74, 47, 0.20); }

/* ── semantic color classes (used by commands.js + terminal.js) ── */
.t-fg   { color: var(--t-fg); }
.t-dim  { color: var(--t-dim); }
.t-mut  { color: var(--t-muted); }
.t-cmt  { color: var(--t-comment); }
.t-acc  { color: var(--t-accent); }
.t-acc2 { color: var(--t-accent2); }
.t-green   { color: var(--t-green); }
.t-red     { color: var(--t-red); }
.t-yel     { color: var(--t-yellow); }
.t-mag     { color: var(--t-magenta); }
.t-cy      { color: var(--t-cyan); }
.b { font-weight: 600; }
.i { font-style: italic; }

/* ── window frame ── */
.mb-frame {
  position: relative;
  width: 100%;
  max-width: 1240px;
  height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--t-bg);
  border: 1px solid var(--t-border);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.02);
}

/* CRT scanlines + vignette — opacity driven by theme (phosphor only) */
.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0) 4px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
  mix-blend-mode: multiply;
}
body[data-theme="phosphor"] .crt-overlay {
  opacity: 0.55;
  animation: crt-flicker 4s steps(8, end) infinite;
}
body[data-theme="phosphor"] .scrollback,
body[data-theme="phosphor"] .inputline {
  text-shadow: 0 0 6px rgba(127, 210, 139, 0.45);
}
@keyframes crt-flicker {
  0%, 92%, 96%, 100% { filter: none; }
  94% { filter: brightness(1.08); }
  95% { filter: brightness(0.92); }
}

/* ── tmux-style title bar ── */
.titlebar {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
  background: var(--t-panel);
  border-bottom: 1px solid var(--t-border);
  padding: 7px 14px;
  font-size: 12px;
  color: var(--t-dim);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.titlebar .sep { margin: 0 10px; }
.titlebar .tb-mid { overflow: hidden; text-overflow: ellipsis; }
.titlebar .tb-right { margin-left: auto; padding-left: 12px; }

/* ── two-pane body ── */
.panes {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* shared pane header */
.pane-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--t-comment);
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--t-border);
  margin-bottom: 12px;
  white-space: nowrap;
}

/* left: identity pane */
.identity {
  width: 320px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 16px 12px;
  border-right: 1px dashed var(--t-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent);
}

.portrait-wrap {
  position: relative;
  align-self: center;
  width: 100%;
  max-width: 264px;
  margin-top: 4px;
}
.portrait-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--t-border);
  filter: grayscale(1) contrast(1.08) brightness(0.97);
}
body[data-theme="paper"] .portrait-img { filter: grayscale(1) contrast(1.05) brightness(1.02); }
.portrait-cap {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 9.5px;
  color: var(--t-dim);
  letter-spacing: 0.4px;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 2px;
}

.id-card { margin-top: 14px; font-size: 12.5px; line-height: 1.7; }
.id-name { color: var(--t-fg); font-weight: 600; font-size: 16px; letter-spacing: -0.2px; }
.id-role { color: var(--t-accent); font-size: 12px; margin-bottom: 10px; }
.id-meta {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 2px 8px;
  color: var(--t-dim);
}

.id-links {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--t-border);
  font-size: 11.5px;
  line-height: 1.7;
}
.id-links-label { margin-bottom: 4px; }
.id-links-grid {
  display: grid;
  grid-template-columns: 60px 1fr;
  column-gap: 8px;
  color: var(--t-dim);
}

/* right: REPL pane */
.repl {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 24px 0;
}

.scrollback {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--t-border) transparent;
}
.scrollback::-webkit-scrollbar { width: 8px; }
.scrollback::-webkit-scrollbar-thumb { background: var(--t-border); border-radius: 8px; }
.scrollback::-webkit-scrollbar-track { background: transparent; }

.line { margin: 0; word-break: break-word; }
.line.output { margin: 4px 0 10px; }
.line.echo { margin-top: 6px; }
.line.boot { color: var(--t-comment); }
.blk { margin: 2px 0; }

/* shared inline structures from commands.js */
.row { display: flex; gap: 16px; align-items: baseline; }
.help-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 22px;
  row-gap: 2px;
}

.lnk {
  color: var(--t-accent2);
  text-decoration: none;
  border-bottom: 1px dashed color-mix(in srgb, var(--t-accent2) 40%, transparent);
}
.lnk:hover { border-bottom-style: solid; }
.lnk:focus-visible, .copy-btn:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.copy-btn {
  margin-left: 10px;
  background: transparent;
  color: var(--t-dim);
  border: 1px solid var(--t-border);
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  padding: 1px 6px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--t-accent); border-color: var(--t-accent); }

/* ascii portrait (the `art` command — kept as an easter egg) */
.ascii-portrait {
  display: inline-block;
  margin: 6px 0;
  color: var(--t-fg);
  font-family: inherit;
  font-size: clamp(2.5px, calc((100vw - 72px) / 230), 5px);
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  overflow-x: auto;
}

/* boot fade-in */
.fade-in { animation: fadein 0.25s ease both; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: none; }
}

/* ── input line ── */
.inputline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 0 10px;
  flex: 0 0 auto;
}
.promptstr, #prompt { white-space: nowrap; }
.inputwrap {
  position: relative;
  flex: 1 1 auto;
  display: inline-block;
  min-width: 0;
}
.cmdline {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  margin: 0;
  padding: 0;
  color: var(--t-fg);
  font: inherit;
  caret-color: transparent;
}
.mirror {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
  font: inherit;
  pointer-events: none;
}
.caret {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.6em;
  height: 1.1em;
  transform: translateY(2px);
  background: var(--t-accent);
  box-shadow: 0 0 8px var(--t-accent);
  pointer-events: none;
  animation: blink 1.05s steps(1) infinite;
}
.caret.hidden { display: none; }
body[data-theme="phosphor"] .caret { box-shadow: 0 0 12px var(--t-accent), 0 0 4px var(--t-accent); }
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── suggestion chips ── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 14px;
  flex: 0 0 auto;
}
.chip {
  background: transparent;
  border: 1px solid var(--t-border);
  border-radius: 4px;
  color: var(--t-dim);
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.chip:hover, .chip:focus-visible {
  color: var(--t-accent);
  border-color: color-mix(in srgb, var(--t-accent) 66%, transparent);
  outline: none;
}

/* ── tmux-style status bar ── */
.statusbar {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  padding: 4px 12px;
  background: var(--t-panel);
  border-top: 1px solid var(--t-border);
  font-size: 12px;
  color: var(--t-dim);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.sb-tag {
  background: var(--t-accent);
  color: var(--t-bg);
  font-weight: 700;
  padding: 2px 10px;
  margin-right: 8px;
}
.sb-win { color: var(--t-fg); }
.sb-win.dim { color: var(--t-dim); margin-left: 14px; }
.sb-right { margin-left: auto; display: flex; align-items: center; min-width: 0; overflow: hidden; }
.sb-right .sb-seg { padding: 0 10px; overflow: hidden; text-overflow: ellipsis; }
.sb-pipe { color: var(--t-comment); }

/* ── toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--t-panelAlt);
  color: var(--t-fg);
  border: 1px solid var(--t-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── bottom-right hint ── */
.hint {
  position: fixed;
  bottom: 12px;
  right: 18px;
  font-size: 11px;
  color: var(--t-muted);
  user-select: none;
  letter-spacing: 0.4px;
}
.hint kbd {
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--t-fg);
  margin: 0 2px;
}

/* ── responsive ── */
@media (max-width: 860px) {
  body { padding: 0; }
  .mb-frame {
    height: 100vh;
    height: 100dvh;
    max-width: none;
    border-radius: 0;
    border: 0;
  }
  .identity { display: none; }
  .titlebar .tb-mid, .titlebar .tb-right { display: none; }
  .hint { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  .repl { padding: 14px 16px 0; }
  .statusbar { padding: 4px 10px; font-size: 11px; }
  .sb-win.dim { display: none; }
  .sb-right .sb-loc { display: none; }
  .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 10px; }
  .chip { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
  .fade-in { animation: none; }
  .crt-overlay { animation: none; }
  body { transition: none; }
}
