@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0a0a0a;
  --panel: #131313;
  --panel2: #0e0e0e;
  --text: #f5f5f5;
  --muted: #9c9690;
  --accent-rgb: 245, 225, 0;
  --accent: rgb(var(--accent-rgb));
  --accent-ink: #0a0a08;
  --line: rgba(245,245,245,0.12);
  --line2: rgba(245,245,245,0.07);
  --gutter: 64px;
}
@media (max-width: 900px) { :root { --gutter: 32px; } }
@media (max-width: 560px) { :root { --gutter: 20px; } }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:hover { color: inherit; }

.page { position: relative; }
.container { max-width: 1600px; margin: 0 auto; position: relative; }

.grain {
  position: absolute; inset: 0; opacity: 0.05; mix-blend-mode: overlay; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#bg-field { position: absolute; inset: 0; pointer-events: none; display: block; }

/* Hero balloon field. pointer-events:none keeps the hero CTAs clickable —
   the balloons track the cursor from a window listener instead. */
#balloon-field { position: absolute; inset: 0; pointer-events: none; display: block; }

.nav-link { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 4px; border-bottom: 1px solid transparent; transition: color .15s ease, border-color .15s ease; }
.nav-link:hover { color: var(--text); border-color: var(--line); }
.nav-link.active { color: var(--text); border-bottom: 1px solid var(--accent); }

.chip { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; }
.tag:hover { border-color: rgba(245,245,245,0.4); color: var(--text); }

.btn-fill { display: inline-flex; align-items: center; gap: 10px; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 999px; padding: 14px 24px; font-weight: 600; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.btn-fill:hover { transform: translateY(-2px); }

.btn-outline { display: inline-flex; align-items: center; gap: 10px; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 14px 24px; color: var(--text); cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.btn-outline:hover { background: var(--text); color: #0a0a0a; border-color: var(--text); }

.btn-outline:focus-visible, .btn-fill:focus-visible, .social-card:focus-visible, .nav-link:focus-visible, .gtile:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

.social-card { display: flex; flex-direction: column; gap: 34px; border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: var(--panel2); transition: border-color .15s ease, transform .15s ease, background .15s ease; }
.social-card:hover { transform: translateY(-3px); background: var(--panel); }

.plus-tick { position: absolute; width: 14px; height: 14px; opacity: 0.35; }

/* Hero glitch title (Home only) */
.glitch-title { position: relative; display: inline-block; cursor: default; }
.glitch-title::before, .glitch-title::after {
  content: attr(data-text);
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
}
.glitch-title:hover { animation: glitch-jitter 0.4s steps(2, end) infinite; }
.glitch-title:hover::before, .glitch-title:hover::after { opacity: 1; }
.glitch-title:hover::before {
  color: #3df3ff;
  mix-blend-mode: screen;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  animation: glitch-slice-a 0.5s steps(2, end) infinite;
}
.glitch-title:hover::after {
  color: #ff2e63;
  mix-blend-mode: screen;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  animation: glitch-slice-b 0.5s steps(2, end) infinite;
}
@keyframes glitch-jitter {
  0% { transform: translate(0,0) skewX(0deg); }
  20% { transform: translate(-1px,1px) skewX(-1deg); }
  40% { transform: translate(1px,-1px) skewX(1deg); }
  60% { transform: translate(-1px,0) skewX(0deg); }
  80% { transform: translate(1px,1px) skewX(0.5deg); }
  100% { transform: translate(0,0) skewX(0deg); }
}
@keyframes glitch-slice-a {
  0% { transform: translate(0,0); }
  20% { transform: translate(-4px,-1px); }
  40% { transform: translate(4px,1px); }
  60% { transform: translate(-3px,1px); }
  80% { transform: translate(3px,-1px); }
  100% { transform: translate(0,0); }
}
@keyframes glitch-slice-b {
  0% { transform: translate(0,0); }
  20% { transform: translate(4px,1px); }
  40% { transform: translate(-4px,-1px); }
  60% { transform: translate(3px,-1px); }
  80% { transform: translate(-3px,1px); }
  100% { transform: translate(0,0); }
}

/* Keepalive-specific */
.pill-opt { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; color: var(--muted); background: transparent; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.pill-opt.active { background: var(--accent); color: #0a0a0a; border-color: var(--accent); }
.log-entry { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line2); font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }
.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--muted); flex-shrink: 0; }
.log-entry.ping .log-msg { color: var(--accent); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 999px; background: var(--line); accent-color: var(--accent); }
select { accent-color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; }
.dot-live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Gallery-specific */
.gtile { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: border-color .15s ease, transform .15s ease; }
.gtile:hover { border-color: rgba(245,245,245,0.4); transform: translateY(-3px); }
.gtile:hover .gtile-expand { opacity: 1; }
.gtile-expand { position: absolute; top: 12px; right: 12px; opacity: 0.55; transition: opacity .15s ease; z-index: 3; }
.gtile img.gtile-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.gtile .gtile-cap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 34px 14px 12px; display: flex; flex-direction: column; gap: 4px; background: linear-gradient(180deg, rgba(5,5,5,0) 0%, rgba(5,5,5,0.85) 100%); }

/* Shared grid shapes (kept out of inline style so media queries below can win) */
.grid-label-280 { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 64px; }
.grid-label-240 { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 56px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 48px; }
.music-row { display: grid; grid-template-columns: 280px minmax(0,1fr) 260px; gap: 64px; align-items: center; }

/* An odd card count leaves a hole in the last row; stretch the final card
   across it so the row reads as deliberate instead of unfinished. */
.fill-last > :last-child { grid-column: span 2; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .glitch-title:hover, .glitch-title:hover::before, .glitch-title:hover::after { animation: none !important; }
  .dot-live { animation: none !important; }
}

@media (max-width: 900px) {
  .grid-label-280, .grid-label-240, .music-row, .grid-2 { grid-template-columns: 1fr !important; }
  .grid-3 { grid-template-columns: 1fr !important; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .grid-5 { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
  .music-row > *:last-child { justify-self: start !important; }

  /* Nav wraps onto its own full-width row instead of disappearing.
     Hiding it stranded keepalive.html with no reachable link on phones. */
  .nav-links {
    order: 3;
    width: 100%;
    gap: 10px !important;
    flex-wrap: nowrap;
    justify-content: space-between;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line2);
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 2px;
    font-size: 11px;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr !important; }
  .grid-5 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .fill-last > :last-child { grid-column: auto; }
}
