/* Dark theme is the default; light overrides it. theme.js sets data-theme. */
:root {
  --frame: #0f1115;
  --bg: #2b4b9b;
  --text: #fff;
  --muted: #d5ddf1;
  --faint: #a9b8e0;
  --ok: #7ee2a8;
  --glow: radial-gradient(ellipse at 50% 30%, rgb(255 255 255 / .09), transparent 60%);
  --circuit: url(circuit.svg);
  --pulses: url(pulses.svg);
  color-scheme: dark;
}

[data-theme="light"] {
  --frame: #d9dfeb;
  --bg: #f5f7fc;
  --text: #16244d;
  --muted: #3c4b75;
  --faint: #66749a;
  --ok: #1e9e5a;
  --glow: radial-gradient(ellipse at 50% 30%, rgb(43 75 155 / .07), transparent 60%);
  --circuit: url(circuit-light.svg);
  --pulses: url(pulses-light.svg);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

/* The blue panel sits inside a thin dark frame, like the reference. */
body {
  margin: 12px;
  min-height: calc(100vh - 24px);
  min-height: calc(100dvh - 24px);
  display: grid;
  place-content: center;
  padding: clamp(24px, 6vh, 48px) 16px;
  border-radius: 20px;
  background:
    var(--glow),
    var(--pulses) center / cover no-repeat,
    var(--circuit) center / cover no-repeat,
    var(--bg);
  color: var(--text);
  font: 400 clamp(1rem, .95rem + .25vw, 1.1875rem)/1.5 "JetBrains Mono", ui-monospace, monospace;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--text); color: var(--bg); }

h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 1.3rem + 1vw, 2.125rem); font-weight: 500; letter-spacing: -.01em; }
p { margin: 0; }
.tagline { font-size: clamp(.8125rem, .78rem + .2vw, .9375rem); font-style: italic; color: var(--muted); }

nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1.8vh, 16px);
  margin: clamp(24px, 8vh, 72px) 0 clamp(28px, 10vh, 88px);
}

a {
  color: inherit;
  text-decoration: none;
  /* Padding makes each link a comfortable tap target (44px+ on phones). */
  --pad: clamp(10px, 1.4vh, 12px);
  padding: var(--pad) 6px;
  /* Underline drawn as a background so it can grow from the center. */
  background: linear-gradient(currentColor, currentColor) center calc(100% - var(--pad) + 3px) / 0 1px no-repeat;
  transition: background-size .25s ease;
}
a:hover, a:focus-visible { background-size: 100% 1px; }
a:focus-visible { outline: 2px solid var(--text); outline-offset: 6px; border-radius: 2px; }

.theme-toggle {
  position: fixed;
  right: calc(28px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--text) 25%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  transition: border-color .25s ease, transform .25s ease;
}
.theme-toggle:hover { border-color: var(--text); transform: rotate(-15deg); }
.theme-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.theme-toggle svg { width: 18px; height: 18px; }
/* Show the icon of the theme you would switch to. */
[data-theme="light"] .icon-sun, :root:not([data-theme="light"]) .icon-moon { display: none; }

/* The theme switch is animated in theme.js; turn off the default crossfade. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
/* Start the new theme hidden, so no frame shows it before the wave begins. */
::view-transition-new(root) { clip-path: circle(0); }

footer { font-size: clamp(.75rem, .7rem + .3vw, .8125rem); color: var(--faint); }
footer::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  vertical-align: 1px;
}

/* Gentle staggered fade-in on load. */
main > *, nav a, footer { animation: rise .6s ease both; }
nav a:nth-child(1) { animation-delay: .10s; }
nav a:nth-child(2) { animation-delay: .15s; }
nav a:nth-child(3) { animation-delay: .20s; }
nav a:nth-child(4) { animation-delay: .25s; }
nav a:nth-child(5) { animation-delay: .30s; }
nav a:nth-child(6) { animation-delay: .35s; }
footer { animation-delay: .45s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
  /* Keep the circuit but drop the moving pulses layer. */
  body { background-image: var(--glow), none, var(--circuit); }
}

/* Phones: drop the frame and use the whole screen. */
@media (max-width: 600px), (max-height: 500px) {
  html { background: var(--bg); }
  .theme-toggle { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  body { margin: 0; min-height: 100vh; min-height: 100dvh; border-radius: 0; }
}

/* Very short screens: tighten spacing so nothing scrolls. */
@media (max-height: 520px) {
  body { padding-block: 16px; }
  nav { margin: 20px 0 24px; }
}

/* Short landscape screens: links in a row so everything fits without scrolling. */
@media (max-height: 500px) and (min-width: 560px) {
  nav { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 20px; margin: 24px 0 28px; }
}
