/*
 * Dowellio / JARVIS — Shared Design System CSS  (v1.0)
 * Uses CSS custom properties driven by window.THEMES in jarvis-shared.js.
 * setTheme() updates :root vars so light/dark just works.
 */

/* ═══════════════════════════════════════════
   CSS CUSTOM PROPERTIES — set by JS setTheme()
   ═══════════════════════════════════════════ */
:root {
  /* Dark theme defaults (overridden by JS on load) */
  --bg0: #0f0f12;
  --bg1: #16161c;
  --bg2: #1e1e26;
  --bg3: #262630;
  --border: #2a2a36;
  --text: #e4e2df;
  --text2: #9a9aaa;
  --text3: #5e5e6e;
  --accent: #c9956b;
  --blue: #6ea8db;
  --green: #5ec96e;
  --yellow: #d4a94e;
  --red: #d46a6a;
  --purple: #9d8abf;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Radii */
  --radius-card: 14px;
  --radius-pill: 20px;
  --radius-sm: 8px;
}

/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

::selection { background: rgba(201, 149, 107, 0.25); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════
   SCROLLBARS
   ═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg0); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg0); }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--bg3);
  color: var(--text2);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg0);
  border-color: var(--accent);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg2); }

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */
.card {
  background: var(--bg1);
  border: 1px solid color-mix(in srgb, var(--border) 27%, transparent);
  border-radius: var(--radius-card);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* ═══════════════════════════════════════════
   FORM INPUTS
   ═══════════════════════════════════════════ */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg0);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  border-radius: var(--radius-card);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
.input::placeholder { color: var(--text3); }

/* ═══════════════════════════════════════════
   BADGES / CHIPS
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 4px var(--gc, var(--accent)); }
  50% { box-shadow: 0 0 10px var(--gc, var(--accent)); }
}
.fade-in  { animation: fadeIn 0.2s ease-out; }
.slide-in { animation: slideIn 0.2s ease-out; }
.spin     { animation: spin 1s linear infinite; }

/* ═══════════════════════════════════════════
   SETUP WIZARD — Directional Transitions
   ═══════════════════════════════════════════ */
@keyframes slideInFromRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInFromLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes successPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-6px); }
  30%  { transform: translateX(5px); }
  45%  { transform: translateX(-4px); }
  60%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
}
@keyframes checkDraw {
  from { stroke-dashoffset: 20; }
  to   { stroke-dashoffset: 0; }
}
@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.4; }
  100% { transform: scale(2.5); opacity: 0; }
}
@keyframes progressFill {
  from { width: 0%; }
}
@keyframes dropBounce {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.step-slide-right { animation: slideInFromRight 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.step-slide-left  { animation: slideInFromLeft 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.step-scale-in    { animation: scaleIn 0.25s ease-out; }
.success-pop      { animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.shake            { animation: shake 0.4s ease-out; }
.drop-bounce      { animation: dropBounce 0.3s ease; }

/* Drag-drop active zone */
.drop-zone-active {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg2)) !important;
  transform: scale(1.01);
  transition: all 0.2s ease;
}
.drop-zone-idle {
  transition: all 0.2s ease;
}

/* Stepper connector animation */
@keyframes connectorFill {
  from { background: var(--border); }
  to   { background: var(--green); }
}

/* Step completion checkmark */
.step-check-animated {
  animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Input focus glow */
.input-focus-glow:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Button ripple container */
.btn-ripple {
  position: relative;
  overflow: hidden;
}
.btn-ripple .ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  animation: ripple 0.5s ease-out forwards;
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   SKIP NAVIGATION (Accessibility)
   ═══════════════════════════════════════════ */
.skip-nav {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.skip-nav:focus {
  position: fixed;
  top: 8px; left: 8px;
  width: auto; height: auto;
  padding: 12px 24px;
  margin: 0;
  overflow: visible;
  clip: auto;
  z-index: 100000;
  background: var(--accent);
  color: var(--bg0);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  text-decoration: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

/* Tablet breakpoint */
@media (max-width: 1024px) {
  .jarvis-sidebar { display: none !important; }
  .jarvis-main { padding: 10px !important; }
  .grid-3 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  .jarvis-hide-sm { display: none !important; }
  .jarvis-header-actions { flex-wrap: wrap; gap: 4px !important; }
  .jarvis-header-actions .btn { font-size: 9px; padding: 4px 8px; }
  .grid-3 { grid-template-columns: 1fr !important; }
  .grid-2 { grid-template-columns: 1fr !important; }

  /* Welcome page nav links collapse via hamburger (handled in welcome.html) */
  .welcome-nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(15,15,18,.97);
    border: 1px solid rgba(42,42,54,.66);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
  }
  .welcome-nav-links.open { display: flex; }
  .welcome-nav-links a {
    padding: 10px 20px !important;
    font-size: 13px !important;
    border-radius: 0 !important;
  }
  .welcome-nav-links a:hover { background: rgba(42,42,54,.5); }
  .hamburger-btn { display: flex !important; }

  /* Hero heading scales down */
  .welcome-hero-title { font-size: 28px !important; }

  /* Dashboard preview SVG constrained */
  .hero-img svg { width: 100% !important; height: auto !important; }

  /* Two-column layouts stack */
  .welcome-how-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
}

/* Small mobile breakpoint */
@media (max-width: 480px) {
  .jarvis-hide-xs { display: none !important; }
  body { font-size: 13px; }

  /* Further reduce hero heading */
  .welcome-hero-title { font-size: 22px !important; }

  /* Cards get less padding */
  .card { padding: 20px 16px; }

  /* Section padding reduced */
  .section { padding: 40px 0; }

  /* Container padding tighter */
  .container { padding: 0 16px; }

  /* Buttons stack if needed */
  .welcome-cta-row { flex-direction: column; align-items: center; }

  /* Quick-link grid in help stacks */
  .help-quick-links { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════
   REDUCED MOTION (Accessibility)
   ═══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════ */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .btn, .jarvis-sidebar, footer, nav, .iron-scanline { display: none !important; }
  .card { border: 1px solid #ccc !important; background: #fff !important; box-shadow: none !important; }
  a { color: #000 !important; text-decoration: underline !important; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
}

/* ═══════════════════════════════════════════
   IRON MAN MODE (dark terminal scanline)
   ═══════════════════════════════════════════ */
.iron-scanline {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(0,255,65,0.08) 50%, transparent 100%);
  z-index: 9999;
  pointer-events: none;
  animation: scanline 4s linear infinite;
}
@keyframes scanline {
  0%   { top: 0; opacity: 0.3; }
  50%  { top: 100%; opacity: 0.1; }
  100% { top: 0; opacity: 0.3; }
}
