:root {
  /* Dracula theme (default) */
  --bg:        #282a36;
  --bg-2:      #21222c;
  --surface:   #343746;
  --current:   #44475a;
  --text:      #f8f8f2;
  --muted:     #6272a4;
  --line:      #44475a;
  --accent:      #bd93f9;
  --accent-rgb:  189, 147, 249;
  --accent-2:    #ff79c6;
  --focus-ring:  #8be9fd;

  --scanline-alpha:      0.2;
  --scanline-line-width: 1px;
  --scanline-pitch:      3px;
  --scanline-opacity:    0.55;
  --scanline-flicker:    0.06;
  --vignette-alpha:      0.55;

  --display: 'Space Grotesk', system-ui, sans-serif;
  --body:    'IBM Plex Sans', system-ui, sans-serif;
  --mono:    'IBM Plex Mono', ui-monospace, monospace;
}

/* Fallout: New Vegas amber HUD theme */
:root[data-theme='fallout'] {
  --bg:        #100b00;
  --bg-2:      #0a0700;
  --surface:   #1e1500;
  --current:   #2e2000;
  --text:      #ffb000;
  --muted:     #8a6300;
  --line:      #3a2900;
  --accent:      #ffb000;
  --accent-rgb:  255, 176, 0;
  --accent-2:    #ff7b00;
  --focus-ring:  #ffdd66;

  --scanline-alpha:      0.35;
  --scanline-line-width: 2px;
  --scanline-pitch:      4px;
  --scanline-opacity:    0.75;
  --scanline-flicker:    0.16;
  --vignette-alpha:      0.7;

  --display: 'IBM Plex Mono', ui-monospace, monospace;
}

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

html, body { height: 100%; }

body {
  position: relative;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(60% 55% at 32% 30%, rgba(var(--accent-rgb), 0.14) 0%, transparent 70%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem) 5rem;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* CRT scanlines + vignette — purely decorative, sits above everything but
   never intercepts clicks. Intensity is theme-driven via custom properties. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--scanline-alpha)) 0px,
    rgba(0, 0, 0, var(--scanline-alpha)) var(--scanline-line-width),
    transparent var(--scanline-line-width),
    transparent var(--scanline-pitch)
  );
  mix-blend-mode: multiply;
  opacity: var(--scanline-opacity);
  animation: crtFlicker 5s ease-in-out infinite;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, var(--vignette-alpha)) 100%);
}

.card {
  position: relative;
  z-index: 1;
  margin: auto;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

/* theme switch */
.theme-switch {
  position: fixed;
  top: clamp(1rem, 3vh, 1.75rem);
  right: clamp(1rem, 3vw, 1.75rem);
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem;
}
.theme-btn {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.theme-btn:hover { color: var(--text); }
.theme-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--accent);
}
.theme-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* hero */
.hero {
  text-align: center;
  animation: rise 0.6s ease both;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 0.6rem;
}
.hero-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  letter-spacing: -0.02em;
  text-shadow: 0 0 36px rgba(var(--accent-rgb), 0.35);
}
.hero-accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.hero-cursor {
  display: inline-block;
  width: 0.55rem;
  height: 0.72em;
  margin-left: 0.4rem;
  background: var(--accent);
  vertical-align: -0.05em;
  animation: blink-hard 1s steps(1) infinite;
}

.search-wrap {
  position: relative;
  animation: rise 0.6s ease 0.1s both;
}

/* search bar */
.search {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14), 0 0 28px rgba(var(--accent-rgb), 0.22);
}
.search-prompt {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.55);
  animation: blink 1.4s ease-in-out infinite;
  flex: none;
}
.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 1.3rem;
  color: var(--text);
  caret-color: var(--accent);
}
.search-input::placeholder { color: var(--muted); }

.search-hint {
  margin-top: 0.65rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.search-hint kbd {
  font-family: var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  color: var(--text);
  background: var(--bg-2);
}

/* suggestions dropdown */
.suggestions {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 0;
  right: 0;
  z-index: 10;
  list-style: none;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}
.suggestions[hidden] { display: none; }
.suggestion {
  padding: 0.75rem 1.15rem;
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
}
.suggestion + .suggestion { border-top: 1px solid var(--line); }
.suggestion.is-bookmark { color: var(--accent-2); }
.suggestion.is-active { background: var(--current); }

/* weather widget — docked as a fixed HUD element, mirroring .theme-switch,
   so it never pushes the bookmarks grid down */
.weather {
  position: fixed;
  top: clamp(1rem, 3vh, 1.75rem);
  left: clamp(1rem, 3vw, 1.75rem);
  z-index: 2;
  width: clamp(160px, 18vw, 200px);
  animation: rise 0.6s ease 0.15s both;
}
.weather-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.weather-widget:hover, .weather-widget:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.18);
}
.weather-widget:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.weather-temp {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.5);
  flex: none;
}
.weather-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.6;
}
.weather-location { color: var(--text); }

@media (max-width: 720px) {
  .weather {
    position: static;
    width: auto;
    top: auto;
    left: auto;
  }
}

/* quick-links grid, rendered from bookmarks.js */
.bookmarks {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: rise 0.6s ease 0.25s both;
}
.bookmark-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.bookmark-category {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  animation: categoryPulse 3.2s ease-in-out infinite;
}
.bookmark-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.bookmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.88rem;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.bookmark:hover, .bookmark:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.18);
}
.bookmark:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.bookmark-icon-wrap {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
  isolation: isolate;
  flex: none;
}
.bookmark-icon {
  width: 100%;
  height: 100%;
  display: block;
  filter: grayscale(1) contrast(1.15) brightness(1.05);
}
.bookmark-icon-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  mix-blend-mode: color;
}

/* signature: self-hosted status line, pinned to the bottom of the viewport */
.status {
  position: fixed;
  left: 50%;
  bottom: clamp(1.25rem, 4vh, 2.5rem);
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.status .clock {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5);
  animation: pulse 2.4s ease-in-out infinite;
  flex: none;
}
.status .muted2 { color: var(--current); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  70%  { box-shadow: 0 0 0 11px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

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

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

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes categoryPulse {
  0%, 100% { opacity: 0.78; }
  50%      { opacity: 1; }
}

@keyframes crtFlicker {
  0%, 100% { opacity: var(--scanline-opacity); }
  50%      { opacity: calc(var(--scanline-opacity) - var(--scanline-flicker)); }
}

@media (prefers-reduced-motion: reduce) {
  .dot,
  .search-prompt,
  .hero-cursor,
  .bookmark-category,
  body::before {
    animation: none;
  }
  .hero,
  .search-wrap,
  .weather,
  .bookmarks {
    animation: none;
  }
}
