/* atoth.dev — green phosphor CRT, palette taken from the old h4x0r "green-on-black" theme */

:root {
  --bg: #000000;
  --fg: #00ff00;
  --fg-soft: #00cc00;
  --accent: #ff9500;
  --dim: #7f7f7f;
  --glow: 0 0 2px rgba(0, 255, 0, .9), 0 0 8px rgba(0, 255, 0, .45);
  --glow-accent: 0 0 2px rgba(255, 149, 0, .9), 0 0 8px rgba(255, 149, 0, .45);
  --mono: Menlo, Consolas, Monaco, "Liberation Mono", "Lucida Console", monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #031a03 0%, #000 70%) fixed, var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: clamp(1rem, 0.867rem + 0.5674vw, 1.25rem);
  line-height: 2;
  text-shadow: var(--glow);
  padding: 0 1ch;
}

/* ---------- CRT overlay: scanlines, vignette, flicker ---------- */

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

body::before {
  background:
    repeating-linear-gradient(to bottom,
      rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, .28) 3px, rgba(0, 0, 0, .28) 4px),
    linear-gradient(90deg, rgba(255, 0, 0, .03), rgba(0, 255, 0, .015), rgba(0, 0, 255, .03));
  background-size: 100% 4px, 3px 100%;
  animation: flicker 6s infinite steps(1);
}

body::after {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .75) 100%);
}

@keyframes flicker {
  0%   { opacity: .92; }
  7%   { opacity: .85; }
  8%   { opacity: .95; }
  42%  { opacity: .9; }
  43%  { opacity: .8; }
  44%  { opacity: .93; }
  77%  { opacity: .88; }
  100% { opacity: .92; }
}

.crt {
  max-width: 65ch;
  margin: 0 auto;
  padding-block: 2rem 3rem;
  animation: turn-on .6s ease-out both;
}

@keyframes turn-on {
  0%   { transform: scale(1, .004); filter: brightness(4); opacity: 0; }
  40%  { transform: scale(1, .004); filter: brightness(4); opacity: 1; }
  70%  { transform: scale(1, 1);    filter: brightness(2); }
  100% { transform: scale(1, 1);    filter: brightness(1); }
}

/* ---------- typography & layout ---------- */

a { color: var(--fg); text-decoration: none; }
a:hover, a:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }

h1, h2 { font-size: 1.25em; font-weight: 700; margin: 1.5em 0 .5em; }

p { margin: 0 0 .25em; }

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .5em 1.5em;
  border-bottom: 1px dashed var(--fg-soft);
  padding-bottom: .5em;
}

.logo { font-weight: 700; font-size: 1.15em; }
.prompt { color: var(--dim); text-shadow: none; }
.logo:hover .prompt { color: inherit; }

.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.blink-slow { color: var(--accent); text-shadow: var(--glow-accent); animation: blink 2s steps(1) infinite; }

nav { display: flex; gap: 1ch; flex-wrap: wrap; }

.boot {
  margin: 1em 0 0;
  font: inherit;
  font-size: .8em;
  line-height: 1.6;
  color: var(--fg-soft);
  white-space: pre-wrap;
  min-height: 0;
}

.site-footer { margin-top: 3em; border-top: 1px dashed var(--fg-soft); padding-top: .5em; font-size: .8em; }

/* ---------- game ---------- */

.screen {
  border: 2px solid var(--fg-soft);
  border-radius: 14px;
  padding: .75em;
  background: #000;
  box-shadow: 0 0 18px rgba(0, 255, 0, .25), inset 0 0 40px rgba(0, 255, 0, .08);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1.5ch;
  font-size: .8em;
}
.hud b { color: var(--accent); text-shadow: var(--glow-accent); font-weight: 700; }

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: .25em auto;
  aspect-ratio: 1 / 1;
}

#frogger-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 6px;
  filter: drop-shadow(0 0 3px rgba(0, 255, 0, .55));
  outline: none;
  touch-action: none;
}
#frogger-canvas:focus-visible { box-shadow: 0 0 0 2px var(--accent); }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .5em;
  background: rgba(0, 0, 0, .72);
  border-radius: 6px;
  cursor: pointer;
  padding: 1em;
}
.overlay-title { font-size: 1.8em; font-weight: 700; letter-spacing: .15em; color: var(--accent); text-shadow: var(--glow-accent); }
.overlay p:last-child { animation: blink 1.2s steps(1) infinite; font-size: .85em; }

.timer { height: 8px; border: 1px solid var(--fg-soft); max-width: 520px; margin: .25em auto 0; }
.timer-bar { height: 100%; width: 100%; background: var(--fg); box-shadow: var(--glow); transform-origin: left; }
.timer-bar.low { background: var(--accent); box-shadow: var(--glow-accent); }

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
  max-width: 520px;
  margin: .75em auto 0;
}

button {
  font: inherit;
  font-size: .85em;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg-soft);
  border-radius: 4px;
  padding: .1em .8ch;
  cursor: pointer;
  text-shadow: var(--glow);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:hover, button:focus-visible, button:active { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }

.buttons { display: flex; gap: 1ch; flex-wrap: wrap; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 2.6em);
  grid-template-rows: repeat(3, 2.6em);
  gap: .2em;
}
.dpad button { padding: 0; font-size: 1em; }
.dpad [data-dir="up"]    { grid-area: 1 / 2; }
.dpad [data-dir="left"]  { grid-area: 2 / 1; }
.dpad [data-dir="right"] { grid-area: 2 / 3; }
.dpad [data-dir="down"]  { grid-area: 3 / 2; }

/* hide the d-pad on devices with a real pointer + keyboard */
@media (hover: hover) and (pointer: fine) {
  .dpad { display: none; }
}

.help { font-size: .75em; margin-top: .5em; }

@media (max-width: 420px) {
  .screen { padding: .5em; border-radius: 10px; }
  .hud { font-size: .7em; }
}

@media (prefers-reduced-motion: reduce) {
  body::before, .crt, .cursor, .blink-slow, .overlay p:last-child { animation: none; }
}
