/* Panic Recovered — main.css */

:root {
  --bg: #0b0c0e;
  --bg-2: #111317;
  --bg-3: #16191e;
  --line: #1d2026;
  --fg: #f2f3f5;
  --muted: #8a8f98;
  --dim: #7d828b;      /* ≥4.5:1 on --bg and --bg-3 */
  --green: #00c98a;
  --green-soft: rgb(0 201 138 / 0.14);
  --red: #ff5f5f;
  --amber: #e5b567;
  --blue: #7cb7ff;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --mx: 50vw;
  --my: 40vh;
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  overflow-x: hidden;
}

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

a {
  color: var(--fg);
  text-decoration: none;
  background-image: linear-gradient(var(--green), var(--green));
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.35s var(--ease), color 0.2s;
}
a:hover,
a:focus-visible { background-size: 100% 1px; color: var(--green); }

:focus-visible { outline: 1px dashed var(--green); outline-offset: 4px; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
code, kbd, pre { font-family: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  padding: 0.4rem 0.8rem; background: var(--green); color: var(--bg);
}
.skip:focus { top: 1rem; }

.shell-open:focus-visible {
  position: fixed; left: 50%; bottom: 1.5rem; translate: -50% 0; z-index: 30;
  width: auto; height: auto; margin: 0; clip: auto; overflow: visible;
  padding: 0.4rem 0.9rem; font: inherit; font-size: 0.8rem;
  color: var(--bg); background: var(--green); border: 0; border-radius: 4px;
}

/* ── background: dot grid + cursor spotlight + vignette ─────────────── */

.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px circle at var(--mx) var(--my), rgb(0 201 138 / 0.07), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgb(0 201 138 / 0.06), transparent 55%);
}
.bg::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgb(242 243 245 / 0.09) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
}
.bg__dots { position: absolute; inset: 0; width: 100%; height: 100%; }
.dots-live .bg::before { display: none; } /* canvas replaces the CSS grid */

.bg::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / 0.18) 2px 3px);
  opacity: 0.35;
  mix-blend-mode: multiply;
}

/* ── top bar ────────────────────────────────────────────────────────── */

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(1rem, 3vw, 2rem) clamp(1.25rem, 4vw, 3rem);
}
.top__mark { background: none; display: inline-flex; }
.top__mark svg { width: 34px; height: 34px; }
.top__mark path { fill: none; stroke: var(--fg); stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.3s; }
.top__mark circle { fill: var(--green); }
.top__mark:hover path { stroke: var(--green); }

/* ── main ───────────────────────────────────────────────────────────── */

.main {
  width: min(760px, 100% - 2.5rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 6vh, 5rem) 0 3rem;
  display: flex; flex-direction: column; gap: clamp(1.75rem, 4vh, 2.75rem);
}
/* Homepage has no top bar: give the hero the room the bar used to take. */
.main--home { padding-top: clamp(3.5rem, 15vh, 9rem); }

/* Capped and centred so the wordmark does not outweigh the copy on wide
   screens; the glow below is sized from .hero, so it stays on the dot. */
.hero { margin: 0 auto; line-height: 0; position: relative; width: min(100%, 580px); }
.hero::before {
  content: ""; position: absolute; z-index: -1;
  left: 43%; top: 50%; width: 46%; aspect-ratio: 1;
  translate: -50% -50%;
  background: radial-gradient(circle, rgb(0 201 138 / 0.16), transparent 62%);
  filter: blur(12px);
  animation: breathe 6s ease-in-out infinite;
}
.logo { width: 100%; height: auto; display: block; overflow: visible; }
.logo__hit { cursor: default; }
.logo__dot {
  transform-box: fill-box; transform-origin: center;
  animation: beat 2.4s var(--ease) infinite;
  filter: drop-shadow(0 0 10px rgb(0 201 138 / 0.65));
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  8% { transform: scale(1.18); }
  16% { transform: scale(0.96); }
  24% { transform: scale(1.06); }
  40% { transform: scale(1); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.7; scale: 1; }
  50% { opacity: 1; scale: 1.12; }
}

.lede {
  margin: 0; font-size: clamp(1rem, 2.2vw, 1.2rem); line-height: 1.5;
  letter-spacing: -0.01em;
}

/* code window */
.code {
  margin: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(180deg, rgb(22 25 30 / 0.85), rgb(17 19 23 / 0.85));
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 30px 80px -40px rgb(0 0 0 / 0.9), inset 0 1px 0 rgb(255 255 255 / 0.03);
  overflow: hidden;
}
.code__bar,
.term__bar {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line);
  font-size: 0.75rem; color: var(--dim);
}
.code__bar > span,
.term__bar > span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.code__bar em,
.term__bar em { font-style: normal; margin-left: 0.5rem; }
.code pre {
  margin: 0; padding: 1.1rem 1.25rem 1.3rem;
  font-size: clamp(0.72rem, 1.9vw, 0.86rem); line-height: 1.7;
  overflow-x: auto; tab-size: 4; color: #c9ccd1;
}
.code .k { color: var(--green); }
.code .t { color: var(--blue); }
.code .f { color: var(--fg); font-weight: 600; }
.code .c { color: var(--dim); font-style: italic; }
.code .s { color: var(--amber); }

.cursor {
  display: inline-block; width: 0.55em; height: 1.1em; margin-left: 2px;
  vertical-align: text-bottom; background: var(--green);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* facts */
.facts {
  margin: 0; display: grid; gap: 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.facts > div {
  display: grid; grid-template-columns: 9rem 1fr; gap: 1rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--line);
}
.facts dt { color: var(--dim); }
.facts dt::before { content: "$ "; color: var(--green); opacity: 0.6; }
.facts dd { margin: 0; }
.facts code { font-size: 1em; }
.beer__state { font-weight: 500; color: var(--muted); }
.beer__state.is-true { color: var(--green); }

.hint { margin: 0; font-size: 0.75rem; color: var(--dim); text-align: center; }
kbd {
  display: inline-block; min-width: 1.4em; padding: 0 0.35em; text-align: center;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  color: var(--muted); background: var(--bg-2);
}

/* staged reveal */
/* Failsafe: if main.js never runs, show the page anyway (boot.js already hid it). */
.js:not(.ready) .main > *,
.js:not(.ready) .top { animation: failsafe-show 0.6s 2s forwards; }
@keyframes failsafe-show { to { opacity: 1; translate: 0 0; } }

.js .main > *,
.js .top { opacity: 0; translate: 0 8px; }
.ready .main > *,
.ready .top {
  opacity: 1; translate: 0 0;
  transition: opacity 0.9s var(--ease), translate 0.9s var(--ease);
}
.ready .main > :nth-child(1) { transition-delay: 0.05s; }
.ready .main > :nth-child(2) { transition-delay: 0.25s; }
.ready .main > :nth-child(3) { transition-delay: 0.4s; }
.ready .main > :nth-child(4) { transition-delay: 0.55s; }
.ready .main > :nth-child(5) { transition-delay: 0.8s; }

/* ── intro: the panic ───────────────────────────────────────────────── */

.intro {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  padding: clamp(1.25rem, 5vw, 4rem);
  overflow: hidden;
}
.intro-active .intro { display: block; }
.intro.is-leaving { animation: crt-off 0.55s var(--ease) forwards; }

.intro__log {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-size: clamp(0.7rem, 1.6vw, 0.9rem); line-height: 1.65; color: var(--muted);
}
.intro__log .prompt { color: var(--green); }
.intro__log .cmd { color: var(--fg); }
.intro__log .err { color: var(--red); }
.intro__log .fn { color: var(--fg); }
.intro__log .ok { color: var(--green); }
.intro__log .glitch { animation: jitter 0.12s steps(2) infinite; display: inline-block; }

.intro__skip {
  position: absolute; right: 1.25rem; bottom: 1.25rem;
  font: inherit; font-size: 0.72rem; color: var(--dim);
  background: none; border: 1px solid var(--line); border-radius: 4px;
  padding: 0.25rem 0.6rem; cursor: pointer;
}
.intro__skip:hover { color: var(--fg); border-color: var(--dim); }

@keyframes jitter {
  0% { transform: translate(0, 0); text-shadow: 2px 0 rgb(255 95 95 / 0.6), -2px 0 rgb(0 201 138 / 0.6); }
  50% { transform: translate(-1px, 1px); text-shadow: -2px 0 rgb(255 95 95 / 0.6), 2px 0 rgb(0 201 138 / 0.6); }
}
@keyframes crt-off {
  0% { opacity: 1; transform: scale(1, 1); filter: brightness(1); }
  45% { opacity: 1; transform: scale(1, 0.006); filter: brightness(3); }
  100% { opacity: 0; transform: scale(0, 0.006); filter: brightness(5); }
}

/* panic command: page-wide glitch */
.panicking .main,
.panicking .top { animation: shake 0.09s steps(2) 8; }
@keyframes shake {
  0% { transform: translate(2px, -1px); filter: hue-rotate(90deg) saturate(3); }
  50% { transform: translate(-3px, 2px); filter: invert(0.08); }
  100% { transform: translate(0, 0); }
}

/* ── terminal easter egg ────────────────────────────────────────────── */

.term {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: end center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgb(5 6 7 / 0.55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.term[hidden] { display: none; }
.term__win {
  width: min(760px, 100%); height: min(460px, 70vh);
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgb(11 12 14 / 0.96);
  box-shadow: 0 40px 120px -30px rgb(0 0 0 / 1), 0 0 0 1px rgb(0 201 138 / 0.06);
  animation: rise 0.35s var(--ease);
}
@keyframes rise { from { opacity: 0; translate: 0 16px; } }
.term__close {
  margin-left: auto; font: inherit; font-size: 0.7rem; color: var(--dim);
  background: none; border: 1px solid var(--line); border-radius: 4px; padding: 0 0.45rem; cursor: pointer;
}
.term__close:hover { color: var(--fg); }
.term__out {
  flex: 1; overflow-y: auto; padding: 0.9rem 1rem 0.25rem;
  font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: #c9ccd1;
}
.term__out .in { color: var(--fg); }
.term__out .in::before { content: "guest@panic:~$ "; color: var(--green); }
.term__out .err { color: var(--red); }
.term__out .ok { color: var(--green); }
.term__out .dim { color: var(--dim); }
.term__line {
  display: flex; align-items: center; gap: 0.6ch;
  padding: 0.5rem 1rem 0.9rem; font-size: 0.82rem;
}
.term__ps1 { color: var(--green); white-space: nowrap; }
.term__line input {
  flex: 1; min-width: 0; font: inherit; color: var(--fg); caret-color: var(--green);
  background: none; border: 0; outline: 0; padding: 0;
}

/* ── 404 ────────────────────────────────────────────────────────────── */

.trace {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-size: clamp(0.72rem, 1.8vw, 0.88rem); line-height: 1.7; color: var(--muted);
}
.trace .err { color: var(--red); }
.trace .fn { color: var(--fg); }
.trace .ok { color: var(--green); }

/* ── responsive / a11y ──────────────────────────────────────────────── */

@media (max-width: 560px) {
  .facts > div { grid-template-columns: 1fr; gap: 0.1rem; }
}

.hint__touch { display: none; }
@media (hover: none) {
  .hint__kbd { display: none; }
  .hint__touch { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }
}
