/* tail.herrmontag.de — amber/green CRT terminal + world map */

:root {
  --bg: #05060a;
  --bg-deep: #030407;
  --accent: #ffb02e;
  --accent-2: #ff7d1a;
  --accent-rgb: 255, 176, 46;
  --bright: #ffe9c7;
  --text: #f0cfa0;
  --dim: #9c7439;
  --faint: rgba(255, 176, 46, .12);
  --line: rgba(255, 176, 46, .16);
  --line-strong: rgba(255, 176, 46, .34);
  --panel: rgba(5, 7, 10, .82);
  --bad: #ff4b3e;
  --warn: #ff8a2b;
  --ok: #6cffb0;
  --mono: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", ui-monospace,
          Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="green"] {
  --accent: #3dffa0;
  --accent-2: #00d97a;
  --accent-rgb: 61, 255, 160;
  --bright: #e3fff0;
  --text: #b6f5d2;
  --dim: #3f9469;
  --faint: rgba(61, 255, 160, .10);
  --line: rgba(61, 255, 160, .14);
  --line-strong: rgba(61, 255, 160, .30);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  min-height: 100svh;
  overflow: hidden;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .012em;
  text-shadow: 0 0 14px rgba(var(--accent-rgb), .16);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

.dim { color: var(--dim); }

/* --- Karte & Effekte ------------------------------------------------------ */

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 6; }

/* Die Vignette muss HINTER Kopf-/Fusszeile liegen, sonst dunkelt sie die
   Beschriftung mit ab. Scanlines und Korn duerfen obenauf bleiben. */
.fx-vignette { z-index: 1; }

.fx-grain {
  opacity: .035;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(3) infinite;
}

.fx-scan {
  opacity: .16;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0 2px,
    rgba(0, 0, 0, .55) 2px 3px
  );
}

.fx-vignette {
  background:
    radial-gradient(120% 90% at 50% 38%, transparent 40%, rgba(0, 0, 0, .55) 100%),
    linear-gradient(to bottom, rgba(3, 4, 7, .82) 0%, transparent 16%, transparent 74%, rgba(3, 4, 7, .9) 100%);
}

/* --- Kopfzeile ------------------------------------------------------------ */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 24px 12px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: linear-gradient(to bottom, rgba(3, 4, 7, .9), rgba(3, 4, 7, 0));
}

.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; }

.brand-cursor {
  width: 8px;
  height: 13px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .8);
  animation: blink 1.15s steps(1) infinite;
}

.brand-main { font-size: 12px; letter-spacing: .2em; color: var(--text); }
.brand-sep { color: var(--dim); opacity: .7; }
.brand-sub { color: var(--dim); letter-spacing: .18em; }

.badge {
  border: 1px solid var(--accent);
  padding: 1px 6px;
  color: var(--accent);
  font-size: 8px;
  letter-spacing: .22em;
  box-shadow: 0 0 14px rgba(var(--accent-rgb), .25) inset;
}

.top-right { display: flex; align-items: center; gap: 16px; color: var(--dim); }

.rec { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); }
.rec i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
.rec.off { color: var(--bad); }
.rec.off i { background: var(--bad); box-shadow: 0 0 10px var(--bad); animation: none; }

.clock { font-variant-numeric: tabular-nums; letter-spacing: .12em; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 3px 8px;
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.ghost-btn:hover, .ghost-btn:focus-visible {
  color: var(--accent);
  border-color: var(--line-strong);
  background: var(--faint);
  outline: none;
}
.ghost-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* --- Terminal ------------------------------------------------------------- */

main {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.terminal {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  width: min(1000px, calc(100vw - 40px));
  height: min(62svh, 720px);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background:
    linear-gradient(180deg, rgba(9, 12, 17, .86), rgba(4, 6, 9, .94));
  border: 1px solid var(--line-strong);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .5),
    0 40px 120px -40px rgba(0, 0, 0, .95),
    0 0 90px -35px rgba(var(--accent-rgb), .35),
    inset 0 0 70px rgba(var(--accent-rgb), .035);
  backdrop-filter: blur(11px) saturate(1.15);
}

.terminal::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(var(--accent-rgb), .06) 50%, transparent 100%);
  opacity: 0;
  transition: opacity .35s ease-out;
}
.terminal.hit::before { opacity: 1; transition-duration: .05s; }

.terminal::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 16px;
  height: 16px;
  border-top: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
  opacity: .7;
  pointer-events: none;
}

.term-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
  background: rgba(var(--accent-rgb), .025);
}

.term-path { color: var(--text); }
.term-cmd { flex: 1; text-align: center; opacity: .7; }

.term-state { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.term-state::before { content: "●"; color: var(--ok); font-size: 8px; }
.term-state.wait::before { color: var(--warn); animation: pulse 1.2s infinite; }
.term-state.err::before { color: var(--bad); }

.log {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 14px 16px 6px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  font-size: 12.5px;
  line-height: 1.62;
  mask-image: linear-gradient(to bottom, transparent 0, #000 26px, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 26px, #000 100%);
}
.log::-webkit-scrollbar { display: none; }

.line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
  padding: 1px 6px 1px 8px;
  border-left: 2px solid transparent;
  animation: line-in .26s ease-out both;
}

.line:hover { background: rgba(var(--accent-rgb), .045); }

.line .ts {
  flex: 0 0 auto;
  color: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

.line .msg {
  flex: 1 1 320px;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.line .geo {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
  border: 1px solid var(--line);
  padding: 0 5px;
  color: var(--dim);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: .9;
}

.line .geo .cc { color: var(--accent); }

.line .user { color: var(--accent); font-weight: 600; }
.line .ip {
  color: var(--bright);
  background: rgba(var(--accent-rgb), .09);
  padding: 0 3px;
  font-weight: 600;
}

.line.invalid { border-left-color: rgba(var(--accent-rgb), .28); }
.line.failed { border-left-color: rgba(var(--accent-rgb), .6); }
.line.probe { border-left-color: var(--line); opacity: .5; }

.line.maxauth { border-left-color: var(--warn); }
.line.maxauth .msg { color: #ffc79a; }
.line.maxauth .ip { color: #ffd9bd; background: rgba(255, 122, 47, .12); }

.line.accepted {
  border-left-color: var(--bad);
  background: linear-gradient(90deg, rgba(255, 75, 62, .18), rgba(255, 75, 62, .02) 70%);
  animation: line-in .26s ease-out both, alarm 1.1s ease-out 2;
}
.line.accepted .msg { color: #ffd2ce; }
.line.accepted .ip { color: #fff; background: rgba(255, 75, 62, .25); }
.line.accepted .geo { border-color: rgba(255, 75, 62, .5); color: #ff9d95; }

.line .flag { color: var(--bad); font-weight: 700; margin-right: 6px; }
.line.boot { opacity: .45; }
.line.summary {
  opacity: .55;
  font-size: 11px;
  border-left-color: var(--line);
  color: var(--dim);
  padding-left: 8px;
}

.term-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: .08em;
}
.prompt { color: var(--accent); }
.tail-line { color: var(--dim); }
.blink { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
.paused-note { margin-left: auto; color: var(--accent); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; }

/* --- Fußzeile ------------------------------------------------------------- */

.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 24px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(3, 4, 7, .92), rgba(3, 4, 7, 0));
}

.stats { display: flex; align-items: flex-end; gap: 26px; flex-wrap: wrap; }

.stat { display: flex; flex-direction: column; gap: 1px; }
.stat b {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat b.bump { animation: bump .4s ease-out; }
.stat span {
  font-size: 8.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
}

.foot-right { display: flex; align-items: center; gap: 14px; }
.note { font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); opacity: .8; }

#spark { display: block; width: 140px; height: 26px; opacity: .85; }

/* --- Seitenleisten -------------------------------------------------------- */

.rail {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 158px;
  font-size: 10px;
  pointer-events: none;
  opacity: .8;
}
.rail-left { left: 22px; }
.rail-right { right: 22px; }
.rail-right .bars li { grid-template-columns: 70px 1fr 28px; }

.rail-title {
  font-size: 8.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.bars { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.bars li { display: grid; grid-template-columns: 24px 1fr 34px; gap: 8px; align-items: center; }
.bars .cc { color: var(--text); letter-spacing: .08em; }
.bars .name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 3px; background: rgba(var(--accent-rgb), .1); position: relative; overflow: hidden; }
.bars .bar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .5), var(--accent));
  box-shadow: 0 0 9px rgba(var(--accent-rgb), .55);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.bars .n { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }

/* --- Toast / Sonstiges ---------------------------------------------------- */

.toast {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  max-width: min(92vw, 640px);
  border: 1px solid var(--bad);
  background: rgba(28, 6, 5, .94);
  color: #ffd7d3;
  padding: 9px 15px;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  box-shadow: 0 0 50px rgba(255, 60, 50, .3);
  animation: toast-in .28s ease-out both;
}
.toast b { color: #fff; }

.noscript {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* --- Animationen ---------------------------------------------------------- */

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes line-in {
  from { opacity: 0; transform: translateY(4px); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes bump {
  0% { transform: scale(1); color: var(--text); }
  35% { transform: scale(1.14); color: var(--accent); text-shadow: 0 0 18px rgba(var(--accent-rgb), .7); }
  100% { transform: scale(1); color: var(--text); }
}
@keyframes alarm {
  0%, 100% { background-color: transparent; }
  20% { background-color: rgba(255, 75, 62, .22); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1%); }
  66% { transform: translate(1%, -2%); }
  100% { transform: translate(0, 0); }
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1360px) {
  .rail { display: none; }
}

@media (max-width: 900px) {
  body { font-size: 12px; }
  .top { padding: max(12px, env(safe-area-inset-top)) 14px 8px; gap: 10px; }
  .brand-sub, .brand-sep { display: none; }
  .brand-main { font-size: 11px; }
  .top-right { gap: 10px; }
  .clock { display: none; }

  .terminal {
    width: calc(100vw - 18px);
    bottom: 80px;
    height: calc(67svh - 80px);
    backdrop-filter: blur(7px);
  }
  .term-top { padding: 8px 12px; gap: 8px; }
  .term-cmd { display: none; }
  .term-state { margin-left: auto; }
  .log { padding: 10px 10px 4px; font-size: 11.5px; line-height: 1.58; }
  .line { column-gap: 8px; padding-left: 6px; }
  .line .ts { font-size: 10px; }
  .line .geo { font-size: 8.5px; padding: 0 4px; }
  .term-bottom { padding: 7px 12px; }

  .bottom { padding: 8px 14px max(10px, env(safe-area-inset-bottom)); gap: 10px; }
  .stats { gap: 16px; }
  .stat b { font-size: 13px; }
  .stat span { font-size: 7.5px; letter-spacing: .12em; }
  .opt-hide { display: none; }
  .note { display: none; }
  #spark { width: 90px; height: 20px; }
}

@media (max-width: 420px) {
  .brand-main { font-size: 10px; letter-spacing: .14em; }
  .rec span { display: none; }
  .stats { gap: 13px; }
  .stat b { font-size: 12px; }
  .stat span { font-size: 7px; }
  #spark { display: none; }
  .line .geo { display: none; }
}

@media (max-height: 620px) and (min-width: 901px) {
  .terminal { height: calc(100svh - 150px); bottom: 70px; }
  .top { padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .fx-grain { display: none; }
  .terminal::before { display: none; }
}
