/* AA-0 Bordkonsole – Retro (C64/Atari ST) trifft Tron */

@font-face {
  font-family: "VT323";
  src: url("../fonts/vt323.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/press-start-2p.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #000;
  --bg-panel: rgba(2, 14, 7, 0.72);
  --bg-dialog: rgba(1, 10, 5, 0.94);
  --green: #33ff66;
  --green-dim: #1f9e44;
  --green-faint: rgba(51, 255, 102, 0.18);
  --cyan: #00e5ff;
  --amber: #ffb000;
  --glow: 0 0 6px rgba(51, 255, 102, 0.55);
  --glow-cyan: 0 0 8px rgba(0, 229, 255, 0.6);
  --font: "VT323", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-head: "Press Start 2P", "VT323", ui-monospace, monospace;
  --gutter: 16px;
}

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

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

body {
  background: var(--bg);
  color: var(--green);
  font-family: var(--font);
  font-size: clamp(20px, 1.6vw + 12px, 24px);
  line-height: 1.3;
  text-shadow: var(--glow);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: var(--cyan); text-shadow: var(--glow-cyan); text-underline-offset: 3px; }
a:hover { color: #fff; }
b { color: #b6ffcb; font-weight: normal; }
.dim { color: var(--green-dim); }
.accent { color: var(--cyan); text-shadow: var(--glow-cyan); }

:focus-visible { outline: 2px dashed var(--cyan); outline-offset: 3px; }

/* ---------- Hintergrund ---------- */

#matrix, #octa {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
#matrix { z-index: 0; opacity: 0.55; }
#octa { z-index: 1; }

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.28) 3px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.65) 100%);
}

/* ---------- Konsole ---------- */

.console {
  position: relative;
  z-index: 3;
  max-width: 1040px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
           max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 5vh, 56px);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 6px 12px;
  border: 1px solid var(--green-faint);
  border-left: 3px solid var(--cyan);
  background: var(--bg-panel);
  font-size: 0.9em;
  letter-spacing: 0.06em;
}
.hud-status { color: var(--green); }
.hud-clock { color: var(--cyan); text-shadow: var(--glow-cyan); font-variant-numeric: tabular-nums; }
.led {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 8px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}

main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: clamp(28px, 6vh, 64px); }

.hero h1 {
  font-family: var(--font-head);
  font-weight: normal;
  font-size: clamp(1.5rem, 6.5vw, 3.6rem);
  line-height: 1.25;
  margin: 0.35em 0 0.5em;
  color: var(--green);
  text-shadow: 0 0 4px var(--green), 0 0 18px rgba(51, 255, 102, 0.45), 3px 3px 0 rgba(0, 229, 255, 0.35);
}
.prompt { font-size: 1.1em; }
.tagline { font-size: 1.15em; max-width: 34em; }

.cursor { animation: blink 1s steps(1) infinite; }

/* ---------- Tasten ---------- */

.keys {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.key {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "code label" "code desc";
  align-items: center;
  column-gap: 14px;
  min-height: 72px;
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  color: var(--green);
  text-shadow: inherit;
  text-decoration: none;
  background: var(--bg-panel);
  border: 1px solid var(--green-dim);
  cursor: pointer;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}
/* Eckwinkel */
.key::before, .key::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  border-color: var(--cyan);
  border-style: solid;
  transition: width 0.2s, height 0.2s;
}
.key::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.key::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.key:hover, .key:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35), inset 0 0 18px rgba(0, 229, 255, 0.08);
  outline: none;
}
.key:hover::before, .key:hover::after, .key:focus-visible::before, .key:focus-visible::after { width: 22px; height: 22px; }
.key:active { transform: translateY(1px) scale(0.99); }

.key-code {
  grid-area: code;
  font-family: var(--font-head);
  font-size: 0.55em;
  padding: 8px 6px;
  color: #000;
  background: var(--green);
  text-shadow: none;
  box-shadow: 0 0 10px rgba(51, 255, 102, 0.6);
}
.key:hover .key-code, .key:focus-visible .key-code { background: var(--cyan); box-shadow: var(--glow-cyan); }
.key-label { grid-area: label; font-family: var(--font-head); font-size: 0.62em; letter-spacing: 0.04em; line-height: 1.6; }
.key-desc { grid-area: desc; color: var(--green-dim); font-size: 0.9em; }

.key-inline { display: inline-grid; grid-template-areas: "code label"; min-height: 56px; }

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

.footbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-size: 0.9em;
  border-top: 1px solid var(--green-faint);
  padding-top: 8px;
}
.link {
  font: inherit;
  color: var(--green-dim);
  text-shadow: none;
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 44px;
  cursor: pointer;
}
.link:hover { color: var(--cyan); }
.link[aria-pressed="true"] { color: var(--amber); }

/* ---------- Dialoge ---------- */

dialog {
  margin: auto;
  width: min(760px, calc(100% - 2 * var(--gutter)));
  max-height: min(86vh, 900px);
  max-height: min(86dvh, 900px);
  padding: 0;
  color: var(--green);
  background: var(--bg-dialog);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15), 0 0 40px rgba(0, 229, 255, 0.25);
  overflow: hidden;
  font: inherit;
  text-shadow: var(--glow);
}
dialog[open] { display: flex; flex-direction: column; animation: crt-on 0.28s ease-out; }
dialog:focus, dialog:focus-visible { outline: none; }
dialog::backdrop { background: rgba(0, 0, 0, 0.65); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 18px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.4);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.12), transparent 70%);
}
.dlg-head h2 {
  font-family: var(--font-head);
  font-weight: normal;
  font-size: clamp(0.7rem, 2.6vw, 1rem);
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.close {
  font: inherit;
  min-width: 44px;
  min-height: 44px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.close:hover { border-color: var(--cyan); }

.dlg-body { padding: 16px 20px 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.dlg-body > * + * { margin-top: 0.7em; }
.dlg-body h3 { margin-top: 1.3em; font-weight: normal; color: var(--amber); text-shadow: 0 0 6px rgba(255, 176, 0, 0.5); letter-spacing: 0.05em; }
.dlg-body .lead { font-size: 1.1em; }
.dlg-body ul, .dlg-body ol { list-style: none; }
.dlg-body ul li { padding-left: 1.4em; position: relative; }
.dlg-body ul li + li { margin-top: 0.25em; }
.dlg-body ul li::before { content: ">"; position: absolute; left: 0; color: var(--cyan); }

.log li { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; }
.log time { color: var(--cyan); text-shadow: var(--glow-cyan); }

.data { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.data dt { color: var(--green-dim); }

.actions { margin-top: 1.4em !important; }

/* ---------- Smartphone ---------- */

@media (max-width: 600px) {
  .keys { grid-template-columns: 1fr; gap: 10px; }
  .key { min-height: 64px; padding: 12px 14px; }
  .hud-id { flex-basis: 100%; }

  dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border: 0;
    border-top: 2px solid var(--cyan);
  }
  .dlg-head { padding-top: max(10px, env(safe-area-inset-top)); }
  .dlg-body { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* Tablet hochkant: 2 Spalten */
@media (min-width: 601px) and (max-width: 900px) {
  .keys { grid-template-columns: repeat(2, 1fr); }
}

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

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes crt-on {
  0% { opacity: 0; transform: scaleY(0.02) scaleX(0.6); filter: brightness(3); }
  60% { opacity: 1; transform: scaleY(1.02) scaleX(1); filter: brightness(1.4); }
  100% { transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Fotos als Bordmonitor ---------- */

.screen { margin: 0.4em 0 1em; }
.screen-portrait { max-width: 360px; }
.screen-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--green-dim);
  background: #000;
  cursor: pointer;
  overflow: hidden;
}
.screen-btn img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) contrast(1.25) brightness(0.85);
  transition: filter 0.6s ease;
}
/* grüne Phosphor-Tönung und Scanlines */
.screen-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.35) 3px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%),
    var(--green);
  background-blend-mode: normal, normal, normal;
  mix-blend-mode: multiply;
  transition: opacity 0.6s ease;
}
.screen-btn[aria-pressed="true"] img { filter: none; }
.screen-btn[aria-pressed="true"]::after { opacity: 0; }
.screen-btn:hover, .screen-btn:focus-visible { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0, 229, 255, 0.35); }
.screen figcaption { margin-top: 6px; font-size: 0.85em; color: var(--green); }
