/* ============================================================
   shell.css — shared shell used by index.html and build.html
   (variables, reset, background, top bar, auth gate, status bar,
   shared fade-in utilities). Page-specific rules live on each page.
   ============================================================ */

:root {
  --bg: #050505;
  --bg-1: #0b0b0b;
  --bg-2: #131313;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.18);
  --fg: #f4f4f4;
  --fg-dim: rgba(244,244,244,0.6);
  --fg-faint: rgba(244,244,244,0.34);
  --fg-ghost: rgba(244,244,244,0.16);
  --paper: #e9e6df;
  --paper-shadow: rgba(0,0,0,0.65);
  --green: #6ee7a8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* === Background ============================================ */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 35%, black 25%, transparent 92%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 35%, black 25%, transparent 92%);
}
.glow {
  position: fixed; inset: -20% -10% auto -10%; height: 80vh; z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(255,255,255,0.08), transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 0%, rgba(255,255,255,0.04), transparent 70%);
}
#ascii-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: 0.7;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 70% 60% at 50% 50%, transparent 45%, rgba(0,0,0,0.7) 100%);
}
/* SVG noise for paper grain */
.grain {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* === Top bar ================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  color: var(--fg-dim);
}
.topbar::after {
  content: "";
  position: absolute; left: 28px; right: 28px; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; letter-spacing: 0.02em;
  color: var(--fg);
  min-height: 32px;
}
.brand .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
  animation: pulse 2.4s ease-in-out infinite;
}
.brand-text,
.brand-sep,
.brand-sub {
  display: inline-block;
  transition: opacity 0.22s ease, transform 0.22s ease, max-width 0.28s ease;
  white-space: nowrap;
}
body.build-active .topbar .brand {
  opacity: 0;
  pointer-events: none;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.topbar .right { display: flex; align-items: center; gap: 22px; }
.topbar .right a {
  color: var(--fg-dim); text-decoration: none;
  transition: color 0.15s ease;
}
.topbar .right a:hover { color: var(--fg); }

.topbar .right button {
  border: 0;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s ease;
}
.topbar .right button:hover { color: var(--fg); }
body:not(.create-view):not(.has-game):not(.build-active).app-locked .topbar,
body:not(.create-view):not(.has-game):not(.build-active):not(.app-locked) .topbar,
body.replay-view-active .topbar {
  display: none;
}

/* === Demo auth ============================================== */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(255,255,255,0.08), transparent 70%),
    rgba(5,5,5,0.86);
  backdrop-filter: blur(12px);
}
body.app-locked .auth-screen { display: grid; }
body.app-locked .catalog-app,
body.app-locked .stage,
body.app-locked .statusbar { pointer-events: none; filter: blur(10px); opacity: 0.22; }
body.app-locked .topbar .right { display: none; }
.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
  box-shadow: 0 28px 90px rgba(0,0,0,0.72), 0 1px 0 rgba(255,255,255,0.08) inset;
  padding: 22px;
}
.auth-mark {
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  color: var(--fg);
  margin-bottom: 22px;
  white-space: normal;
  line-height: 1.1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255,255,255,0.22);
}
.auth-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-copy {
  margin: 0 0 18px;
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.5;
}
.auth-form {
  display: grid;
  gap: 10px;
}
.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--fg-faint);
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,0.38);
  color: var(--fg);
  font: 15px "Inter", sans-serif;
  padding: 12px 13px;
  outline: none;
}
.auth-form input:focus { border-color: rgba(255,255,255,0.42); }
.auth-form button {
  margin-top: 4px;
  border: 1px solid #fff;
  border-radius: 10px;
  background: #fff;
  color: #000;
  font: 700 13px "Inter", sans-serif;
  padding: 12px 14px;
  cursor: pointer;
}
.auth-error {
  min-height: 18px;
  margin: 0;
  color: rgba(255,255,255,0.72);
  font: 12px "Geist Mono", monospace;
}

/* === Status bar ============================================= */
.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 28px;
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  color: var(--fg-faint);
}
.statusbar::before {
  content: "";
  position: absolute; left: 28px; right: 28px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent);
}
.statusbar .left, .statusbar .right { display: flex; gap: 18px; align-items: center; }
.statusbar .ok { color: var(--fg); }

/* === Shared fade-in utilities ============================== */
.fadein { opacity: 0; animation: fadein 0.6s ease-out forwards; }
.fadein.d1 { animation-delay: 0.05s; }
.fadein.d2 { animation-delay: 0.15s; }
.fadein.d3 { animation-delay: 0.25s; }
.fadein.d4 { animation-delay: 0.40s; }
.fadein.d5 { animation-delay: 0.55s; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
