/* ════════════════════════════════════════════════════════════════════
   ALIEN AI STUDIO · SHARED STYLES
   ──────────────────────────────────────────────────────────────────
   Loaded by every page in /studio/. Contains the cosmic theme tokens,
   sidebar, page layout, and the most common reusable components
   (cards, buttons, eyebrows, hero, toast, modal).

   Per-page CSS lives inside each page's own <style> block to keep
   this file from ballooning. As more pages migrate over, anything
   that turns out to be truly shared can be promoted here.
   ──────────────────────────────────────────────────────────────────
   First created: May 2026 — Phase 2 split of ai.html monolith.
   ════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand colors — keep in sync with ai.html for visual consistency
     during the migration. Once the cutover is complete we can adjust
     freely without breaking the legacy app. */
  --green:       #22c55e;
  --green-l:     #4ade80;
  --green-d:     #15803d;
  --green-faint: rgba(34,197,94,0.07);
  --green-glow:  rgba(34,197,94,0.18);
  --border:      rgba(255,255,255,0.07);
  --border-g:    rgba(34,197,94,0.2);
  --border-gh:   rgba(34,197,94,0.42);
  --text:        #eef8f2;
  --text-2:      rgba(238,248,242,0.92);
  --text-3:      rgba(238,248,242,0.84);
  --text-4:      rgba(238,248,242,0.55);
  --error:       #f87171;
  --blue:        #60a5fa;
  --cyan:        #22d3ee;
  --pink:        #f472b6;
  --purple:      #a78bfa;
  --gold:        #fde047;

  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  /* ═════════════════════════════════════════════════════════════════
     TITLE GRADIENT — single source of truth for all gradient titles.
     ─────────────────────────────────────────────────────────────────
     Every page title across the studio reads these variables. To
     change the title look site-wide, edit ONLY these four lines.
     The HTML files reference var(--title-grad) and var(--title-glow)
     so this is the only place to update.

     Current scheme: green → blue (brand colors), top to bottom,
     with a soft white glow.
     ═════════════════════════════════════════════════════════════════ */
  --title-grad-top:    #22c55e;   /* green */
  --title-grad-bottom: #06b6d4;   /* cyan-blue */
  --title-grad:        linear-gradient(180deg, var(--title-grad-top), var(--title-grad-bottom));
  --title-glow:        drop-shadow(0 0 14px rgba(255,255,255,0.35));

  /* Sidebar width — referenced by .sidebar and .main flex math. */
  --sw: 228px;
}

html, body { height: 100%; font-family: var(--font); -webkit-font-smoothing: antialiased; }

body {
  background: #00000a;
  color: var(--text);
  display: flex;
  overflow: hidden;
  height: 100vh;
}

/* The animated cosmic background (stars, nebula, planets) is drawn
   by /studio/shared/background.js into its own <canvas> elements.
   They sit at z-index 0 with pointer-events:none. Sidebar and main
   content use z-index 1+ so they layer on top.

   This means: pages no longer ship their own per-page background —
   they all share one canvas system. One place to update, less code
   shipped per page, identical visual across the whole studio. */

/* ════════════════════════════════════════════════════════════════════
   SIDEBAR
   Injected into the page by /studio/shared/sidebar.js so every page
   stays in sync. Markup lives in sidebar.js; styles live here.
   ════════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sw);
  flex-shrink: 0;
  background: rgba(5,5,16,0.98);
  border-right: 1px solid rgba(34,197,94,0.1);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sb-top { padding: 1.1rem 0.875rem 0.4rem; }

.sb-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 1.5rem; padding: 0 2px; text-decoration: none; }
.sb-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sb-mark img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 0 6px rgba(34,197,94,0.5)); }
.sb-brand-name { font-family: 'Orbitron', monospace; font-size: .93rem; letter-spacing: .06em; color: #34d399; }
.sb-brand-sub  { font-family: var(--mono); font-size: .72rem; color: var(--text-3); letter-spacing: 0.09em; margin-top: 1px; }

.nav-lbl {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 8px; margin: 0.9rem 0 4px;
}

/* Sidebar nav buttons. We use <a> tags (not buttons) so middle-click
   opens in a new tab, which non-technical users do constantly. */
.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px;
  font-size: 0.85rem; font-weight: 500; color: var(--text-2);
  cursor: pointer; transition: all 0.15s;
  border: 1px solid transparent;
  background: none;
  width: 100%; text-align: left;
  font-family: var(--font);
  text-decoration: none;
}
.nav-btn:hover { background: rgba(34,197,94,0.05); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(135deg, rgba(34,197,94,0.13), rgba(34,197,94,0.05));
  border-color: rgba(34,197,94,0.22);
  color: var(--green-l);
}
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 0.88rem; }
.nav-chip {
  margin-left: auto;
  font-family: var(--mono); font-size: 0.6rem;
  background: var(--green-faint); color: rgba(34,197,94,0.84);
  border: 1px solid rgba(34,197,94,0.16);
  border-radius: 100px; padding: 1px 6px;
}
/* Lock / unlock indicator for entries with `lockChip: true` in the NAV
   registry. Shows 🔒 when the user is on the free plan, 🔓 when paid.
   Pushed to the right edge of the nav button like .nav-chip. */
.nav-lock {
  margin-left: auto;
  font-size: 0.9rem;
  opacity: 0.55;
  line-height: 1;
  filter: grayscale(0.3);
  transition: all 0.2s ease;
}
.nav-lock.is-unlocked {
  opacity: 0.95;
  filter: grayscale(0);
}
.nav-btn:hover .nav-lock { opacity: 0.85; }

/* Color variants for nav-chip — applied via inline style by sidebar.js
   so we don't need a class per badge type. */

/* ── Sidebar credit block — visible only when signed in ── */
.credits-block {
  margin: 0.5rem 0.875rem;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(8,10,28,0.9), rgba(10,8,25,0.9));
  border: 1px solid rgba(34,197,94,0.18);
  border-radius: 8px;
}
.credits-block.hidden { display: none; }
.credits-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.credits-label { font-size: 0.77rem; color: var(--text-2); font-weight: 500; }
.credits-val { font-family: var(--mono); font-size: 0.93rem; color: var(--green-l); font-weight: 500; }
.credits-bar { height: 3px; background: rgba(255,255,255,0.07); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.credits-fill { height: 100%; background: linear-gradient(90deg, #15803d, #22c55e); border-radius: 2px; transition: width 0.6s; }
.credits-sub { font-size: 0.74rem; color: var(--text-3); }
.credits-sub a { color: var(--green-l); text-decoration: none; }

/* Sidebar foot — user row OR sign-in prompt depending on auth state */
.sb-foot { padding: 0.875rem; border-top: 1px solid rgba(34,197,94,0.08); margin-top: auto; }

/* ── MOUSE FX PANEL (in sidebar) ── */
.fx-panel {
  margin: 0.5rem 0.875rem 0;
  padding: 10px 12px;
  background: rgba(34,197,94,0.04);
  border: 1px solid rgba(34,197,94,0.12);
  border-radius: 8px;
}
.fx-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.fx-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fx-label { font-size: 0.9rem; color: var(--text-2); }

/* Toggle switch */
.toggle-sw { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 100px; cursor: pointer;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.1);
  transition: background 0.2s;
}
.toggle-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,0.5); transition: all 0.2s; }
.toggle-sw input:checked + .toggle-track { background: linear-gradient(135deg, #15803d, #22c55e); border-color: rgba(34,197,94,0.5); }
.toggle-sw input:checked + .toggle-track::after { left: 19px; background: #fff; }

.fx-style-btn {
  width: 100%; padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--border-g); background: rgba(34,197,94,0.05);
  font-family: var(--font); font-size: 0.92rem; font-weight: 500; color: var(--green-l);
  cursor: pointer; transition: all 0.18s;
  display: flex; align-items: center; justify-content: space-between;
}
.fx-style-btn:hover { background: rgba(34,197,94,0.1); border-color: var(--border-gh); }
.fx-style-name { font-size: 0.78rem; color: var(--text-2); }

.sb-foot.hidden { display: none; }
.user-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); }
.user-avi { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #15803d, #22c55e); display: flex; align-items: center; justify-content: center; font-size: 0.77rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-email { font-size: 0.79rem; color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-btn { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 0.77rem; font-family: var(--font); transition: color 0.15s; white-space: nowrap; }
.so-btn:hover { color: var(--error); }
.cta-btn {
  display: block; width: 100%;
  padding: 10px; border-radius: 9px;
  text-align: center;
  background: linear-gradient(135deg, #14532d, #15803d, #22c55e);
  color: #fff;
  font-size: 0.89rem; font-weight: 700;
  border: none; cursor: pointer;
  font-family: var(--font); transition: all 0.2s;
  text-decoration: none; letter-spacing: 0.01em;
  box-shadow: 0 3px 18px rgba(34,197,94,0.28), 0 0 0 1px rgba(34,197,94,0.22) inset;
}
.cta-btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 26px rgba(34,197,94,0.4); }
.cta-sub { font-size: 0.72rem; color: var(--text-3); text-align: center; margin-top: 6px; }

/* ════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ════════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 1;
  background: transparent;
}
.main::-webkit-scrollbar { width: 4px; }
.main::-webkit-scrollbar-thumb { background: rgba(34,197,94,0.18); border-radius: 4px; }

/* Centered content container — used by every page's hero section.
   Capped at 1000px to match ai.html's content-width tier 1. Pages
   with grids (gallery, community, arcade) can override to 1300px. */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.page-wide { max-width: 1300px; }

/* Eyebrow — small label above hero titles. Used everywhere. */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 0.75rem;
}
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }

.hero-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1.75rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--text);
}
.hero-sub {
  font-size: 1.02rem;
  color: var(--text-2);
  max-width: 680px;
  line-height: 1.55;
  margin-bottom: 1.75rem;
}

/* ════════════════════════════════════════════════════════════════════
   COMMON COMPONENTS — buttons, cards, inputs
   ════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px;
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border-g);
  background: rgba(34,197,94,0.05); color: var(--green-l);
  transition: all 0.15s; text-decoration: none;
}
.btn:hover { background: rgba(34,197,94,0.12); border-color: var(--border-gh); }
.btn-primary {
  background: linear-gradient(135deg, #14532d, #22c55e);
  color: #fff; border-color: transparent;
  box-shadow: 0 3px 18px rgba(34,197,94,0.28);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }

.card {
  background: linear-gradient(145deg, rgba(8,6,22,0.95), rgba(5,4,16,0.98));
  border: 1px solid rgba(34,211,238,0.12);
  border-radius: 14px;
  padding: 1.25rem;
}

.f-inp, input[type="text"], input[type="email"], input[type="password"], textarea {
  font-family: var(--font); font-size: 0.99rem;
  color: var(--text); background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 12px 14px;
  width: 100%; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.f-inp:focus, input:focus, textarea:focus { border-color: var(--border-gh); background: rgba(34,197,94,0.04); }
::placeholder { color: var(--text-4); }

/* ════════════════════════════════════════════════════════════════════
   TOAST — bottom-right notifications
   ════════════════════════════════════════════════════════════════════ */
.toast-stack {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9000; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(15,30,20,0.96), rgba(8,18,12,0.98));
  border: 1px solid var(--border-g);
  border-radius: 10px;
  font-size: 0.93rem; color: var(--text);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  max-width: 380px;
  animation: toast-in 0.25s ease;
}
.toast.err { border-color: rgba(248,113,113,0.4); color: #fecaca; }
.toast.fade { opacity: 0; transition: opacity 0.4s; }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ════════════════════════════════════════════════════════════════════
   PAGE-MIGRATION STUB STYLE
   Used by every page that hasn't been migrated yet. Will be deleted
   once each stub is replaced with the real implementation.
   ════════════════════════════════════════════════════════════════════ */
.stub-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; text-align: center; padding: 2rem;
}
.stub-emoji { font-size: 4rem; margin-bottom: 1rem; filter: drop-shadow(0 0 20px rgba(34,197,94,0.5)); }
.stub-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.stub-sub { color: var(--text-2); max-width: 460px; line-height: 1.55; margin-bottom: 1.5rem; }
.stub-link { color: var(--green-l); text-decoration: none; font-weight: 600; }
.stub-link:hover { text-decoration: underline; }

/* ═══ MOBILE — slide-out drawer sidebar ═══
   Below ~720px the sidebar becomes a fixed-position drawer that slides
   in from the left when the user taps the hamburger button at top-left.
   A backdrop overlay covers the page content while it's open.

   On desktop (above 720px) the hamburger + backdrop are display:none
   so users never see them. */
@media (max-width: 720px) {
  body { overflow-x: hidden; }
  .page { padding: 1.5rem 1rem 3rem; }

  /* Sidebar drawer — fixed-position, off-screen by default */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 0 40px rgba(0,0,0,0.75);
    /* keep flex so content lays out correctly when open */
    display: flex;
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Hamburger toggle button — fixed top-left */
  .sb-mobile-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 44px; height: 44px;
    background: rgba(8,8,18,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(192,132,252,0.25);
    border-radius: 10px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: border-color 0.15s ease, background 0.15s ease;
  }
  .sb-mobile-toggle:hover,
  .sb-mobile-toggle:focus-visible {
    border-color: rgba(192,132,252,0.55);
    background: rgba(16,12,30,0.95);
    outline: none;
  }
  /* Three bars that animate into an X when the drawer is open */
  .sb-mobile-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(216,180,254,0.9);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
  .sb-mobile-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .sb-mobile-toggle.is-open span:nth-child(2) {
    opacity: 0;
  }
  .sb-mobile-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Backdrop — dim + blur the page while the drawer is open */
  .sb-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
  }
  .sb-mobile-backdrop.is-open {
    opacity: 1;
    pointer-events: all;
  }
}

/* Desktop — hide the hamburger + backdrop entirely. They get
   re-shown by the mobile media query above. */
@media (min-width: 721px) {
  .sb-mobile-toggle,
  .sb-mobile-backdrop { display: none !important; }
}