/* ══════════════════════════════════════════
   Dhun Design System — Global Styles
   Source of truth: stitch-design-light.md
   ══════════════════════════════════════════ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── CSS Custom Properties (Design Tokens) ── */
:root {
  /* Primary */
  --primary: #6f5900;
  --primary-dim: #614e00;
  --primary-container: #fecf00;
  --primary-fixed: #fecf00;
  --primary-fixed-dim: #eec200;
  --on-primary: #fff2d2;
  --on-primary-fixed: #433500;
  --on-primary-container: #594700;

  /* Secondary */
  --secondary: #665c00;
  --secondary-container: #f8e54e;
  --on-secondary-container: #5b5200;

  /* Surfaces */
  --background: #f6f6f6;
  --surface: #f6f6f6;
  --surface-dim: #d3d5d5;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f0f1f1;
  --surface-container: #e7e8e8;
  --surface-container-high: #e1e3e3;
  --surface-container-highest: #dbdddd;

  /* Text */
  --on-surface: #2d2f2f;
  --on-surface-variant: #5a5c5c;
  --on-background: #2d2f2f;

  /* Outline */
  --outline: #767777;
  --outline-variant: #acadad;

  /* Error */
  --error: #b02500;
  --error-container: #f95630;
  --on-error: #ffefec;

  /* Inverse */
  --inverse-surface: #0c0f0f;
  --inverse-primary: #fecf00;

  /* Spacing */
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-10: 2.5rem;
  --spacing-12: 3rem;
  --spacing-16: 4rem;
  --spacing-20: 5rem;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows (tonal, not heavy) */
  --shadow-sm: 0 1px 2px rgba(45, 47, 47, 0.04);
  --shadow-md: 0 8px 24px rgba(45, 47, 47, 0.04);
  --shadow-lg: 0 24px 48px rgba(45, 47, 47, 0.06);
  --shadow-xl: 0 32px 64px rgba(45, 47, 47, 0.08);

  /* Ghost border */
  --ghost-border: 1px solid rgba(172, 173, 173, 0.15);
}

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--on-surface);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  color: var(--on-surface);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p {
  color: var(--on-surface-variant);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dim);
}

/* ── Buttons ── */
.btn {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.25s ease;
  display: inline-block;
  border: none;
  cursor: pointer;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
}

.btn-primary:hover {
  background: var(--primary-fixed-dim);
  transform: scale(1.02);
}

.btn-secondary {
  background: var(--surface-container-highest);
  color: var(--on-surface);
}

.btn-secondary:hover {
  background: var(--surface-container-high);
}

.btn-outline {
  background: transparent;
  color: var(--on-surface);
  box-shadow: inset 0 0 0 2px rgba(172, 173, 173, 0.4);
}

.btn-outline:hover {
  background: var(--surface-container-lowest);
  box-shadow: inset 0 0 0 2px rgba(172, 173, 173, 0.6);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Inputs ── */
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--on-surface);
  background: var(--surface-container-low);
  border: var(--ghost-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: all 0.3s;
  width: 100%;
}

input::placeholder, textarea::placeholder {
  color: var(--outline-variant);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  background: var(--surface-container);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ── Cards ── */
.card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-xl);
  padding: var(--spacing-6);
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ── Status Badges ── */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.badge-error {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

/* ── Messages ── */
.msg-success {
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
  border-left: 4px solid #059669;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.msg-error {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border-left: 4px solid #dc2626;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.msg-info {
  background: rgba(111, 89, 0, 0.06);
  color: var(--primary);
  border-left: 4px solid var(--primary);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

/* ── Gradient Headline ── */
.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-container) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Glass Effect ── */
.glass {
  background: rgba(246, 246, 246, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ── Utility ── */
.text-primary { color: var(--primary); }
.text-muted { color: var(--on-surface-variant); }
.text-faint { color: var(--outline-variant); }
.bg-surface { background: var(--surface); }
.bg-surface-low { background: var(--surface-container-low); }
.bg-surface-container { background: var(--surface-container); }
.bg-white { background: var(--surface-container-lowest); }

/* ══════════════════════════════════════════
   Dark Theme
   ══════════════════════════════════════════ */
[data-theme="dark"] {
  /* Primary (stays vibrant on dark) */
  --primary: #fecf00;
  --primary-dim: #eec200;
  --primary-container: #6f5900;
  --primary-fixed: #fecf00;
  --primary-fixed-dim: #eec200;
  --on-primary: #14213d;
  --on-primary-fixed: #14213d;
  --on-primary-container: #fecf00;

  /* Secondary */
  --secondary: #f8e54e;
  --secondary-container: #665c00;
  --on-secondary-container: #f8e54e;

  /* Surfaces */
  --background: #14213d;
  --surface: #14213d;
  --surface-dim: #0e1729;
  --surface-container-lowest: #0b1225;
  --surface-container-low: #1a2d50;
  --surface-container: #1f3461;
  --surface-container-high: #253b6a;
  --surface-container-highest: #2c4373;

  /* Text */
  --on-surface: #e5e5e5;
  --on-surface-variant: #b0b3b8;
  --on-background: #e5e5e5;

  /* Outline */
  --outline: #8a8d93;
  --outline-variant: #4a5568;

  /* Error */
  --error: #ff6b4a;
  --error-container: #7a1a00;
  --on-error: #fff0ed;

  /* Inverse */
  --inverse-surface: #e5e5e5;
  --inverse-primary: #6f5900;

  /* Shadows (lighter glow on dark) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 32px 64px rgba(0, 0, 0, 0.3);

  /* Ghost border */
  --ghost-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Dark glass nav */
[data-theme="dark"] .glass {
  background: rgba(20, 33, 61, 0.8);
}

/* Dark mode link colors */
[data-theme="dark"] a {
  color: var(--primary);
}

[data-theme="dark"] a:hover {
  color: var(--primary-dim);
}

/* Dark mode gradient text */
[data-theme="dark"] .gradient-text,
[data-theme="dark"] .accent,
[data-theme="dark"] [class*="accent"],
[data-theme="dark"] h1 .accent {
  background: linear-gradient(135deg, #fecf00 0%, #ffe066 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

/* Dark mode buttons - ensure visibility */
[data-theme="dark"] .btn-primary {
  background: var(--primary-fixed);
  color: #14213d;
}

[data-theme="dark"] .btn-outline {
  color: var(--on-surface);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .btn-secondary {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

/* Dark mode input adjustments */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  color: var(--on-surface);
  background: var(--surface-container-low);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  background: var(--surface-container);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--outline-variant);
}

/* Dark mode badges */
[data-theme="dark"] .badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

[data-theme="dark"] .badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  background: var(--surface-container);
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-full);
  color: var(--on-surface-variant);
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

/* Dark mode CTA card */
[data-theme="dark"] .cta-card {
  background: linear-gradient(135deg, #fecf00 0%, #6f5900 100%);
}

[data-theme="dark"] .cta-card h2,
[data-theme="dark"] .cta-card p {
  color: #14213d;
}

[data-theme="dark"] .cta-card .btn {
  background: #14213d;
  color: #fecf00;
}

/* Dark mode header sections with colored backgrounds */
[data-theme="dark"] .header-colored {
  background: var(--primary-fixed);
  color: #14213d;
}

[data-theme="dark"] .header-colored h1,
[data-theme="dark"] .header-colored p {
  color: #14213d;
}

/* Dark mode: override common inline color hardcodes */
[data-theme="dark"] [style*="color: #2d2f2f"],
[data-theme="dark"] [style*="color: #14213d"],
[data-theme="dark"] [style*="color: #000"],
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#2d2f2f"],
[data-theme="dark"] [style*="color:#14213d"],
[data-theme="dark"] [style*="color:#000"] {
  color: var(--on-surface) !important;
}

[data-theme="dark"] [style*="color: #5a5c5c"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color: #555"],
[data-theme="dark"] [style*="color:#5a5c5c"],
[data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color:#555"] {
  color: var(--on-surface-variant) !important;
}

[data-theme="dark"] [style*="color: #acadad"],
[data-theme="dark"] [style*="color: #999"],
[data-theme="dark"] [style*="color:#acadad"],
[data-theme="dark"] [style*="color:#999"] {
  color: var(--outline-variant) !important;
}

[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background-color: #fff"],
[data-theme="dark"] [style*="background-color: white"] {
  background: var(--surface-container-lowest) !important;
}

[data-theme="dark"] [style*="background: #f0f1f1"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background:#f0f1f1"] {
  background: var(--surface-container-low) !important;
}

[data-theme="dark"] [style*="border: 1px solid #e"],
[data-theme="dark"] [style*="border: 2px solid #e"],
[data-theme="dark"] [style*="border-bottom: 1px solid #e"],
[data-theme="dark"] [style*="border-top: 1px solid #e"] {
  border-color: rgba(255, 255, 255, 0.1) !important;
}
