/* =========================================================================
   Startup OS — Global Styles
   Base reset, typography, shared primitives. Module-specific styles live
   alongside their modules under src/modules/*.
   ========================================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  scroll-behavior: smooth;
  background: var(--ink-900);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  background-image: var(--grad-aurora);
  background-attachment: fixed;
}

::selection { background: var(--teal-core); color: var(--text-inverse); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); font-weight: 500; }

p { margin: 0; }

a {
  color: var(--ocean);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out);
}
a:hover { color: var(--cyan-bright); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

:focus-visible {
  outline: 2px solid var(--teal-core);
  outline-offset: 2px;
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 4px rgba(46, 232, 192, 0.18);
}

code, pre, .mono { font-family: var(--font-mono); font-feature-settings: 'zero', 'ss02'; }

.serif { font-family: var(--font-display); }
.italic { font-style: italic; }

/* Utility visibility */
[hidden] { display: none !important; }

/* ----------- Pre-boot black frame (prevents FOUC) ----------- */
#preboot {
  position: fixed;
  inset: 0;
  background: var(--ink-900);
  z-index: var(--z-intro);
  pointer-events: none;
  transition: opacity var(--dur-deliberate) var(--ease-out);
}
body.app-ready #preboot { opacity: 0; pointer-events: none; }

/* ----------- App shell ----------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "rail topbar"
    "rail main";
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell[data-rail-collapsed="true"] { grid-template-columns: var(--rail-collapsed) 1fr; }

.nav-rail { grid-area: rail; border-right: 1px solid var(--ink-400); background: rgba(6, 11, 16, 0.6); backdrop-filter: blur(12px); }
.topbar { grid-area: topbar; border-bottom: 1px solid var(--ink-400); background: rgba(6, 11, 16, 0.75); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: var(--z-nav); }
.main-pane { grid-area: main; min-width: 0; padding: var(--space-6) var(--space-8); overflow-y: auto; }

/* Mobile: rail collapses, drawer slides in */
@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .nav-rail {
    position: fixed;
    inset: var(--topbar-height) auto 0 0;
    width: 80%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
    z-index: var(--z-drawer);
  }
  .nav-rail[data-open="true"] { transform: translateX(0); }
  .main-pane { padding: var(--space-4); }
  .topbar-hamburger { display: inline-flex !important; }
}

/* ----------- Cards ----------- */
.card {
  background: var(--ink-500);
  border: 1px solid var(--ink-400);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.card--hoverable:hover {
  border-color: var(--ink-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card--feature {
  background: linear-gradient(180deg, var(--ink-500) 0%, var(--ink-600) 100%);
  border-color: rgba(46, 232, 192, 0.18);
}

/* ----------- Buttons ----------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-md);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.005em;
  transition: background-color var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--teal-core);
  color: var(--text-inverse);
  font-weight: 600;
}
.btn--primary:hover { background: var(--teal-glow); box-shadow: var(--shadow-glow-teal); }

.btn--secondary {
  background: var(--ink-500);
  color: var(--text-primary);
  border-color: var(--ink-400);
}
.btn--secondary:hover { border-color: var(--teal-core); color: var(--teal-core); }

.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { color: var(--text-primary); background: var(--ink-600); }

.btn--danger { background: var(--danger); color: white; }
.btn--danger:hover { filter: brightness(1.1); }

.btn--lg { padding: var(--space-4) var(--space-6); font-size: var(--text-base); }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn--icon { padding: var(--space-2); width: 36px; height: 36px; }

/* ----------- Inputs ----------- */
.input, .textarea, .select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--ink-600);
  border: 1px solid var(--ink-400);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--teal-core);
  box-shadow: 0 0 0 4px rgba(46, 232, 192, 0.15);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.textarea--hero { min-height: 200px; font-size: var(--text-md); padding: var(--space-5); }

/* ----------- Chips / Tags ----------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--ink-600);
  border: 1px solid var(--ink-400);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}
.chip--teal { background: rgba(46, 232, 192, 0.12); border-color: rgba(46, 232, 192, 0.3); color: var(--teal-glow); }
.chip--amber { background: rgba(245, 169, 58, 0.12); border-color: rgba(245, 169, 58, 0.3); color: var(--amber-glow); }
.chip--danger { background: rgba(255, 85, 119, 0.12); border-color: rgba(255, 85, 119, 0.3); color: var(--danger); }
.chip--ocean { background: rgba(77, 226, 255, 0.1); border-color: rgba(77, 226, 255, 0.3); color: var(--cyan-bright); }

/* ----------- Dividers ----------- */
.divider { height: 1px; background: var(--ink-400); margin: var(--space-6) 0; }
.divider--vertical { width: 1px; height: auto; align-self: stretch; background: var(--ink-400); }

/* ----------- Grids ----------- */
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 920px) {
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; justify-content: center; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ----------- Text helpers ----------- */
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-teal { color: var(--teal-core); }
.text-amber { color: var(--amber-core); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-ember { color: var(--text-ember); }

.text-xxs { font-size: var(--text-xxs); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }

/* ----------- Intro stage ----------- */
.intro-stage {
  position: fixed;
  inset: 0;
  background: var(--ink-900);
  z-index: var(--z-intro);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
}
.intro-stage.is-done { pointer-events: none; opacity: 0; transition: opacity var(--dur-deliberate) var(--ease-out); }
.intro-noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
  pointer-events: none;
}
.intro-bloom {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 120vmin;
  height: 120vmin;
  background: radial-gradient(circle at center, rgba(46, 232, 192, 0.15), transparent 55%);
  pointer-events: none;
  opacity: 0;
  animation: intro-bloom-in 2s var(--ease-out) 0.3s forwards;
}
@keyframes intro-bloom-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.intro-logo {
  position: relative;
  width: 168px;
  height: 168px;
  z-index: 2;
}
.intro-tagline {
  margin-top: var(--space-6);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-xl);
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(8px);
  animation: intro-tagline-in var(--dur-cinematic) var(--ease-out) 3.2s forwards;
  text-align: center;
  max-width: 600px;
}
@keyframes intro-tagline-in {
  to { opacity: 1; transform: translateY(0); }
}
.intro-skip {
  position: absolute;
  bottom: var(--space-6);
  right: var(--space-6);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ----------- Cinematic thinking state (Ember / standup / Funding scorer) ----------- */
.aurora-thinking {
  position: relative;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-8);
  background: var(--grad-aurora);
  background-size: 200% 200%;
  animation: aurora-drift 14s ease-in-out infinite;
  border-radius: var(--r-xl);
  overflow: hidden;
}
@keyframes aurora-drift {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}
.aurora-thinking .status-line {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  text-align: center;
  max-width: 480px;
  opacity: 0;
  animation: fade-rotate 3s var(--ease-in-out) infinite;
}
@keyframes fade-rotate {
  0%, 100% { opacity: 0; transform: translateY(4px); }
  20%, 80% { opacity: 1; transform: translateY(0); }
}

/* ----------- Toasts ----------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  background: var(--ink-500);
  border: 1px solid var(--ink-400);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-overshoot);
  max-width: 420px;
}
.toast--success { border-left: 3px solid var(--success); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--danger { border-left: 3px solid var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----------- Utility ----------- */
.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;
}

.skeleton {
  background: linear-gradient(90deg, var(--ink-500) 0%, var(--ink-400) 50%, var(--ink-500) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--r-md);
}
@keyframes skeleton-pulse {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
