/* ── Phosphor: green-CRT terminal portfolio ─────────────────────── */

:root {
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Phosphor themes */
:root[data-theme="green"] {
  --bg: #050805;
  --screen: #071007;
  --fg: #33ff66;
  --fg-dim: #1d9c44;
  --fg-bright: #aaffc3;
  --accent: #66ffaa;
  --glow: rgba(51, 255, 102, 0.55);
  --selection: rgba(51, 255, 102, 0.25);
}
:root[data-theme="amber"] {
  --bg: #080604;
  --screen: #100b05;
  --fg: #ffb000;
  --fg-dim: #a06e10;
  --fg-bright: #ffe0a3;
  --accent: #ffcf5c;
  --glow: rgba(255, 176, 0, 0.5);
  --selection: rgba(255, 176, 0, 0.25);
}
:root[data-theme="ice"] {
  --bg: #04060a;
  --screen: #060b12;
  --fg: #9fd8ff;
  --fg-dim: #4d7fa6;
  --fg-bright: #e4f4ff;
  --accent: #c2e7ff;
  --glow: rgba(159, 216, 255, 0.5);
  --selection: rgba(159, 216, 255, 0.25);
}

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

::selection { background: var(--selection); color: var(--fg-bright); }

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  font-family: var(--font);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Bezel / CRT frame ─────────────────────────────────────────── */

.bezel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(8px, 2vmin, 24px);
  min-height: 0;
}

.crt {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--screen);
  border-radius: clamp(6px, 1.5vmin, 18px);
  box-shadow:
    inset 0 0 120px rgba(0, 0, 0, 0.85),
    0 0 40px rgba(0, 0, 0, 0.9),
    0 0 22px var(--glow);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: clamp(14px, 3vmin, 34px);
  font-size: clamp(13px, 1.9vmin, 16px);
  line-height: 1.55;
  text-shadow: 0 0 6px var(--glow), 0 0 1px var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) transparent;
}
.screen::-webkit-scrollbar { width: 6px; }
.screen::-webkit-scrollbar-thumb { background: var(--fg-dim); border-radius: 3px; }

/* ── Overlays ──────────────────────────────────────────────────── */

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.22) 3px,
    transparent 4px
  );
  mix-blend-mode: multiply;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.flicker {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--fg);
  opacity: 0;
  animation: flicker 8s infinite;
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 0; }
  96.5% { opacity: 0.012; }
  97% { opacity: 0; }
  98% { opacity: 0.02; }
  98.4% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .flicker { animation: none; }
  .crt { animation: none !important; }
}

/* ── fx off: plain phosphor ────────────────────────────────────── */

:root.no-fx .scanlines,
:root.no-fx .flicker,
:root.no-fx .vignette { display: none; }
:root.no-fx .screen { text-shadow: none; }
:root.no-fx .crt {
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 0, 0, 0.8);
}

/* ── CRT power & degauss ───────────────────────────────────────── */

@keyframes crt-on {
  0%   { transform: scaleY(0.004) scaleX(0.55); filter: brightness(6); }
  50%  { transform: scaleY(0.004) scaleX(1); filter: brightness(4); }
  100% { transform: none; filter: none; }
}
.crt.crt-on { animation: crt-on 0.55s ease-out; }

@keyframes crt-off {
  0%   { transform: none; filter: brightness(1); }
  55%  { transform: scaleY(0.004) scaleX(1); filter: brightness(5); }
  100% { transform: scaleY(0.004) scaleX(0.002); filter: brightness(0.1); }
}
.crt.crt-off { animation: crt-off 0.5s ease-in forwards; }

@keyframes degauss {
  0%   { transform: none; filter: none; }
  20%  { transform: skewX(1.6deg) scale(1.012, 0.99); filter: hue-rotate(20deg) brightness(1.3); }
  45%  { transform: skewX(-1.1deg) scale(0.995, 1.008); filter: hue-rotate(-14deg); }
  70%  { transform: skewX(0.4deg); filter: hue-rotate(6deg); }
  100% { transform: none; filter: none; }
}
.crt.degauss { animation: degauss 0.75s ease-out; }

/* ── Output lines ──────────────────────────────────────────────── */

.line { white-space: pre-wrap; word-break: break-word; min-height: 1.55em; }
.line.dim { color: var(--fg-dim); text-shadow: none; }
.line.bright { color: var(--fg-bright); }
.line.err { color: var(--fg-bright); }
.line.err::before { content: "! "; color: var(--fg); }

.ascii {
  font-size: min(1em, 2.05vw);
  line-height: 1.05;
  font-weight: 700;
  color: var(--fg-bright);
  white-space: pre;
  overflow-x: hidden;
}

.line a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.line a:hover { color: var(--fg-bright); }

.line .cmd-echo { color: var(--fg-bright); }
.line .k { color: var(--fg-bright); }

/* ── Input line ────────────────────────────────────────────────── */

.input-line { display: flex; align-items: baseline; gap: 0.6ch; }

.prompt { color: var(--fg-dim); text-shadow: none; flex: none; }

.prompt.root {
  color: #ff7b72;
  text-shadow: 0 0 6px rgba(255, 90, 80, 0.55);
}

.input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 4ch;
}

#cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font: inherit;
  color: var(--fg-bright);
  text-shadow: inherit;
  caret-color: var(--fg-bright);
  min-width: 4ch;
  position: relative;
  z-index: 1;
}

.ghost {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--fg-dim);
  opacity: 0.65;
  text-shadow: none;
  white-space: pre;
  pointer-events: none;
}

.measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  pointer-events: none;
}

/* ── Quick-command chips ───────────────────────────────────────── */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  padding-top: clamp(8px, 1.5vmin, 14px);
}

.chips button {
  font: inherit;
  font-size: 12px;
  font-family: var(--font);
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--fg-dim);
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.chips button:hover, .chips button:focus-visible {
  color: var(--fg-bright);
  border-color: var(--fg);
  box-shadow: 0 0 10px var(--glow);
  outline: none;
}

/* ── Noscript ──────────────────────────────────────────────────── */

.noscript { padding: 2rem; max-width: 60ch; }
.noscript a { color: var(--accent); }
.noscript h1 { font-size: 1.2rem; margin-bottom: 1rem; }
.noscript p { margin-bottom: 0.75rem; }

@media (max-width: 600px) and (orientation: portrait) {
  .line .sep { display: none; }
  .line .role2 { display: block; }
}

@media (max-width: 600px) {
  .screen { font-size: 13px; }
  .ascii { font-size: min(0.85em, 2.6vw); }
  .chips { gap: 6px; }
  .chips button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 5px 2px;
    font-size: 11px;
    text-align: center;
  }
}
