/* DevAlbert terminal UI */

:root {
  --bg: #050805;
  --term-bg: #0a100a;
  --fg: #33ff66;
  --fg-dim: #1d9c44;
  --fg-bright: #aaffc3;
  --accent: #ffd75f;
  --err: #ff5f5f;
  --link: #5fd7ff;
  --chrome: #161c16;
  --chrome-border: #233223;
  --selection: rgba(51, 255, 102, 0.25);
}

[data-theme="amber"] {
  --bg: #080502;
  --term-bg: #110b04;
  --fg: #ffb000;
  --fg-dim: #a86f00;
  --fg-bright: #ffe0a3;
  --accent: #5fd7ff;
  --link: #5fd7ff;
  --chrome: #1c1408;
  --chrome-border: #33260f;
  --selection: rgba(255, 176, 0, 0.25);
}

[data-theme="blue"] {
  --bg: #020508;
  --term-bg: #050b12;
  --fg: #7fd4ff;
  --fg-dim: #3a7ca3;
  --fg-bright: #d2efff;
  --accent: #ffd75f;
  --link: #aaffc3;
  --chrome: #0a141c;
  --chrome-border: #15293a;
  --selection: rgba(127, 212, 255, 0.25);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 15px;
  line-height: 1.45;
}

::selection { background: var(--selection); }

a { color: var(--link); }

/* CRT effects */
.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  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
  );
}

.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 51;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 60%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

@media (prefers-reduced-motion: no-preference) {
  .crt .terminal { animation: flicker 4s infinite; }
  @keyframes flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.96; }
    94% { opacity: 1; }
  }
}

/* Terminal window */
.terminal {
  max-width: 920px;
  margin: 4vh auto;
  background: var(--term-bg);
  border: 1px solid var(--chrome-border);
  border-radius: 8px;
  box-shadow:
    0 0 60px rgba(0, 0, 0, 0.8),
    0 0 24px color-mix(in srgb, var(--fg) 12%, transparent);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 90vh;
}

.term-titlebar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
  user-select: none;
}

.term-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #444;
}
.term-dot.red { background: #ff5f57; }
.term-dot.yellow { background: #febc2e; }
.term-dot.green { background: #28c840; }

.term-title {
  flex: 1;
  text-align: center;
  color: var(--fg-dim);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
  cursor: text;
  text-shadow: 0 0 6px color-mix(in srgb, var(--fg) 35%, transparent);
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) transparent;
}

/* Output */
.line {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.45em;
}

.line.dim { color: var(--fg-dim); text-shadow: none; }
.line.bright { color: var(--fg-bright); }
.line.accent { color: var(--accent); }
.line.err { color: var(--err); }
.line.title {
  color: var(--fg-bright);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.ascii {
  margin: 0;
  color: var(--fg-bright);
  font-size: clamp(8px, 2vw, 15px);
  line-height: 1.3;
  white-space: pre;
  overflow-x: auto;
  text-shadow: 0 0 4px color-mix(in srgb, var(--fg) 40%, transparent);
}

.prompt-user { color: var(--fg-bright); font-weight: 700; }
.prompt-path { color: var(--accent); }
.echo-cmd { color: var(--fg-bright); }

/* Clickable command "links" */
.cmd-link {
  font: inherit;
  display: inline;
  padding: 0 2px;
  margin: 0;
  border: none;
  background: none;
  color: var(--link);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cmd-link::before { content: "["; color: var(--fg-dim); }
.cmd-link::after { content: "]"; color: var(--fg-dim); }
.cmd-link:hover, .cmd-link:focus {
  color: var(--fg-bright);
  background: var(--selection);
  outline: none;
}

/* Input line */
.input-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  position: relative;
}

.input-line .prompt { white-space: pre; }

#mirror { white-space: pre-wrap; word-break: break-all; }

#caret {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  vertical-align: text-bottom;
  background: var(--fg);
  animation: blink 1.06s steps(1) infinite;
}
.input-line.unfocused #caret { animation: none; background: var(--fg-dim); }

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#cmd-input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px; /* prevents iOS focus zoom */
  border: none;
  padding: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

/* Static / redirect / error pages reuse the shell */
.static-page .terminal { height: auto; min-height: 0; }
.static-page .term-body { padding-bottom: 40px; }

.noscript-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px;
}
.noscript-content h1, .noscript-content h2 { color: var(--fg-bright); }

@media (max-width: 640px) {
  .terminal {
    margin: 0;
    height: 100dvh;
    border: none;
    border-radius: 0;
  }
  body { font-size: 14px; }
}
