/* ==========================================================================
   Mission — design tokens and base components
   Shared by every page. The cinematic horizon lives only on the login page;
   everything else borrows its palette, type and restraint.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces: deep black → charcoal → navy-tinted layers */
  --bg:            #05060a;   /* page */
  --bg-raised:     #0a0c12;   /* sidebars, headers */
  --surface:       #0f1219;   /* cards, panels */
  --surface-2:     #151924;   /* hover, inputs, nested panels */
  --surface-3:     #1c2130;   /* pressed, selected */

  /* Lines */
  --border:        rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  /* Text */
  --text:          #eceef3;   /* primary: soft white, never pure */
  --text-2:        #a3a8b5;   /* secondary */
  --text-3:        #6c7180;   /* tertiary, captions, placeholders */

  /* Light — used sparingly, like the horizon glow */
  --glow:          #f4e9d8;   /* warm starlight: highlights, progress, focus */
  --glow-soft:     rgba(244, 233, 216, 0.12);
  --accent:        #b9c6ff;   /* cool accent: links, active states */
  --accent-soft:   rgba(185, 198, 255, 0.12);

  /* Status (muted, never neon) */
  --success:       #7fd1a8;
  --warning:       #e8c27a;
  --danger:        #ef8a8a;

  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 0.75rem;   --fs-sm: 0.875rem;  --fs-md: 1rem;
  --fs-lg: 1.125rem;  --fs-xl: 1.375rem;  --fs-2xl: 1.75rem;  --fs-3xl: 2.25rem;
  --tracking-tight: -0.015em;

  /* Spacing (4px base) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  /* Shape — rounded, never bubbly */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-xl: 20px;

  /* Motion — calm and short */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out-slow: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms;  --t-med: 240ms;  --t-slow: 600ms;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.35);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(244, 233, 216, 0.55);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { letter-spacing: var(--tracking-tight); line-height: 1.2; font-weight: 600; margin: 0; }
::selection { background: rgba(244, 233, 216, 0.25); }

[hidden] { display: none !important; }

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

/* ---------- Buttons ---------- */
.btn {
  --h: 52px;
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: var(--h); padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--r-lg);
  font: 500 0.9375rem/1 var(--font); letter-spacing: -0.005em;
  cursor: pointer; text-decoration: none; user-select: none;
  transition:
    background-color var(--t-med) var(--ease),
    border-color var(--t-med) var(--ease),
    color var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    transform var(--t-fast) var(--ease);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:active { transform: scale(0.985); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Light: primary actions */
.btn-light .spark { background: #0b0d12; }
.btn-light { background: #f3f4f7; color: #0b0d12; }
.btn-light:hover { background: #ffffff; box-shadow: 0 0 0 1px rgba(255,255,255,0.4), 0 10px 30px -12px rgba(244,233,216,0.35); }

/* Quiet: secondary actions on dark */
.btn-quiet { background: rgba(255, 255, 255, 0.055); color: var(--text); border-color: var(--border); }
.btn-quiet:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--border-strong); }

/* Text-only */
.btn-text { width: auto; height: auto; padding: var(--s2); background: none; color: var(--text-2); }
.btn-text:hover { color: var(--text); }

.btn[disabled] { opacity: 0.6; cursor: default; pointer-events: none; }

/* Loading: the button keeps its label; a soft grey sheen sweeps across it */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn[aria-busy="true"] { cursor: progress; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(100deg,
    transparent 15%, var(--sheen, rgba(20, 24, 34, 0.16)) 50%, transparent 85%);
  transform: translateX(-100%);
  animation: sheen 1.3s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.btn-light[aria-busy="true"] { background: #eceef2; color: #3d414b; box-shadow: none; }
.btn-quiet[aria-busy="true"] { --sheen: rgba(255, 255, 255, 0.16); color: var(--text-2); }
@keyframes sheen { to { transform: translateX(100%); } }

/* ---------- Inputs ---------- */
.field { display: grid; gap: var(--s2); }
.field label { font-size: var(--fs-sm); color: var(--text-2); }
.input {
  height: 52px; width: 100%; padding: 0 var(--s4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  color: var(--text); font: 400 var(--fs-md) var(--font);
  transition: border-color var(--t-med) var(--ease), background-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: rgba(255, 255, 255, 0.2); }
.input:focus { outline: none; background: rgba(255,255,255,0.06); border-color: rgba(244, 233, 216, 0.45); box-shadow: 0 0 0 4px rgba(244, 233, 216, 0.08); }
.input[aria-invalid="true"] { border-color: rgba(239, 138, 138, 0.6); }

/* ---------- Panels (for app pages) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s6);
  box-shadow: var(--shadow-1);
}
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }

/* ---------- Motion ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::after { animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
