/* retro.sh — egy teljes képernyős terminál, semmi sallang. */
:root {
  color-scheme: dark;
  --bg-deep: #050709;
  --bg-soft: #0e1217;
  --fg: #d8d4ce;
  --fg-dim: #6b7585;
  --fg-faint: #3a4250;
  --border: #1d2530;
  --accent: #ffb86c;
  --accent-bright: #ffd09b;
  --green: #4ade80;
  --cyan: #67e8f9;
  --red: #f87171;
  --yellow: #facc15;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, ui-monospace, monospace;
  font-size: 14px;
  font-synthesis: none;
}
:root[data-theme="zöld"] { --accent: #a3e635; --accent-bright: #d4f881; }
:root[data-theme="cián"] { --accent: #67e8f9; --accent-bright: #a5f3fc; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--fg);
  line-height: 1.55;
  background:
    radial-gradient(ellipse 80% 50% at top, rgba(255, 184, 108, 0.05), transparent 70%),
    var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
a { color: var(--cyan); text-underline-offset: 3px; }
:focus-visible { outline: 1px dashed var(--accent); outline-offset: 2px; }
::selection { background: rgba(255, 184, 108, 0.3); color: var(--accent-bright); }
[hidden] { display: none !important; }
.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; }

/* Színek */
.dim { color: var(--fg-dim); }
.accent { color: var(--accent); }
.success { color: var(--green); }
.error { color: var(--red); }
.warn { color: var(--yellow); }
.cyan { color: var(--cyan); }
.strong { font-weight: 600; }

/* CRT: pásztázóvonalak és enyhe sötétedés a szélein */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.18) 3px 4px),
    radial-gradient(ellipse 110% 100% at center, transparent 50%, rgba(0, 0, 0, 0.5) 100%);
}
:root[data-crt="off"] .crt-overlay { display: none; }

/* Állapotsor */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg-dim);
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}
.status-group { display: flex; align-items: center; gap: 16px; min-width: 0; }
.status-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.status-item b { color: var(--accent); font-weight: 500; }
button.status-item:hover { color: var(--fg); }
.status-dot { width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }

/* Terminál */
.terminal {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 10px;
}
.output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.output::-webkit-scrollbar { width: 6px; }
.output::-webkit-scrollbar-thumb { background: var(--border); }

.boot-line { color: var(--fg-dim); white-space: pre-wrap; }
.boot-line .ok { color: var(--green); }

.motd {
  width: fit-content;
  max-width: 100%;
  margin: 12px 0 4px;
  padding: 14px 20px;
  border: 1px solid var(--border);
}
.motd-title { margin-bottom: 10px; }
.motd-grid { display: grid; grid-template-columns: max-content 1fr; gap: 2px 3ch; }
.motd-hint { margin-top: 10px; font-size: 0.9em; }

.entry { margin-top: 12px; }
.echo { overflow-wrap: anywhere; }
.result { overflow-wrap: anywhere; }
.result > p { margin: 2px 0; }

/* Kattintható parancsok: szövegnek látszanak */
.cmd { color: var(--green); }
.cmd.accent { color: var(--accent); }
.cmd.cyan { color: var(--cyan); }
.cmd.dim { color: var(--fg-dim); }
.cmd.plain { color: var(--fg); }
.cmd:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Prompt */
.prompt-user { color: var(--green); }
.path { color: var(--cyan); }
.prompt-symbol { color: var(--fg); }
.prompt-mail { color: #f472b6; }

.prompt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--bg-soft);
  flex-shrink: 0;
}
.prompt { flex-shrink: 0; white-space: nowrap; user-select: none; }
.input-area { position: relative; flex: 1; min-width: 0; height: 22px; overflow: hidden; }
.input-display, #cmdInput { font-size: 14px; line-height: 22px; }
.input-display { white-space: pre; pointer-events: none; height: 22px; }
#cmdInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}
#cmdInput::selection { color: transparent; background: rgba(255, 184, 108, 0.3); }
.ghost-text { color: var(--fg-dim); opacity: 0.6; }
.just-completed { animation: ghost-flicker 160ms steps(1, end); }
@keyframes ghost-flicker {
  0% { color: var(--fg-dim); opacity: 0.4; }
  35% { color: var(--fg-dim); opacity: 0.9; }
  70% { color: var(--fg-dim); opacity: 0.5; }
  100% { color: inherit; opacity: 1; }
}
.block-cursor {
  position: absolute;
  top: 3px;
  left: calc(var(--caret-ch, 0) * 1ch);
  width: 1ch;
  height: 16px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0.85;
  pointer-events: none;
  animation: blink 1.06s steps(1, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.input-area:not(.input-focused) .block-cursor { background: transparent; box-shadow: none; outline: 1px solid var(--accent); outline-offset: -1px; animation: none; }
.input-area.has-selection .block-cursor { display: none; }

/* Tab-kiegészítés javaslatai */
.completion-list { display: flex; flex-wrap: wrap; gap: 0 22px; padding: 4px 0; color: var(--fg-dim); flex-shrink: 0; }
.completion-item.completion-active { color: var(--accent); }
.completion-item:hover { color: var(--fg); }

/* Listázás */
.ls-inline { display: flex; flex-wrap: wrap; gap: 2px 22px; }
.ls-title { margin-top: 10px; }
.ls-row { display: grid; grid-template-columns: 12ch minmax(0, max-content) 1fr; gap: 0 2ch; }
.ls-row > :last-child { min-width: 0; }
.tree, .history-list, .neofetch, .man-page { white-space: pre; overflow-x: auto; }
.neofetch { line-height: 1.35; }

/* Kézikönyv (súgó) */
.man-page {
  max-width: calc(82ch + 30px);
  margin: 4px 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: rgba(255, 184, 108, 0.02);
  white-space: pre-wrap;
}
.man-page h3 { display: inline; font: inherit; color: var(--accent); }
/* Ha egy sor nem fér ki, a folytatás beljebb kezdődik, mint egy igazi man-oldalon. */
.man-page > div { padding-left: 8ch; text-indent: -8ch; }

/* Markdown-fájlok */
.file-header { margin: 4px 0 2px; padding: 4px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); color: var(--fg-dim); }
.file-header .name { color: var(--accent); }
.markdown { max-width: 80ch; }
.markdown h2, .markdown h3, .markdown h4, .markdown h5 { margin: 16px 0 6px; color: var(--accent); font-size: 1em; font-weight: 600; line-height: 1.35; }
.markdown h2 { font-size: 1.4em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.15em; }
.markdown h4 { color: var(--accent-bright); }
.markdown p { margin: 8px 0; }
.markdown strong { color: var(--accent-bright); font-weight: 600; }
.markdown em { opacity: 0.85; }
.markdown ul, .markdown ol { margin: 8px 0; padding-left: 3ch; }
.markdown li { margin: 2px 0; }
.markdown li::marker { color: var(--accent); }
.markdown code { color: var(--green); }
.markdown pre { margin: 10px 0; padding: 10px 12px; overflow-x: auto; background: var(--bg-soft); border: 1px solid var(--border); }
.markdown pre code { color: var(--fg); }
.markdown blockquote { margin: 10px 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent); color: var(--fg-dim); font-style: italic; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.file-tags { margin-top: 10px; }

/* Levélíró */
.mail-box { max-width: 74ch; margin: 4px 0; padding: 6px 12px; border: 1px dashed var(--border); }
.mail-summary { max-width: 74ch; margin: 8px 0 4px; padding: 8px 12px; border-left: 2px solid var(--green); }

.noscript { position: fixed; left: 16px; right: 16px; bottom: 60px; padding: 12px; border: 1px solid var(--accent); background: var(--bg-soft); z-index: 20; }

/* Mobil */
@media (max-width: 640px) {
  :root { font-size: 13px; }
  .status-bar { padding: 4px 10px; font-size: 10px; }
  .status-item.optional { display: none; }
  .terminal { padding: 10px 12px 8px; }
  .motd { padding: 10px 12px; }
  .ls-row { grid-template-columns: minmax(0, max-content) 1fr; }
  .ls-row > :first-child { display: none; }
  .ls-row > :last-child { grid-column: 1 / -1; padding-left: 2ch; }
  .prompt-line .prompt-user { display: none; }
  /* 16 px alatt az iOS ráközelít a beviteli mezőre */
  .input-area { height: 24px; }
  .input-display, #cmdInput { font-size: 16px; line-height: 24px; height: 24px; }
  .block-cursor { top: 4px; height: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  #cmdInput { color: CanvasText; caret-color: CanvasText; }
  .input-display { visibility: hidden; }
  .crt-overlay { display: none; }
}
