/* ==========================================================================
   Your Hub Software — Core Design System & Accessibility Tokens (YHS-UI-001)
   Tagline: Software Built Around You.
   Target: WCAG 2.2 AA (>= 4.5:1 normal text, >= 3:1 large text & UI controls)
   ========================================================================== */

:root,
[data-theme="light"] {
  color-scheme: light;

  /* Surfaces & Neutrals (Clean Commercial Light Mode Default) */
  --yh-bg: #f8fafc;
  --yh-surface: #ffffff;
  --yh-surface-elevated: #f1f5f9;
  --yh-surface-subtle: #f8fafc;
  --yh-surface-hover: #f1f5f9;
  --yh-header-bg: rgba(255, 255, 255, 0.96);
  --yh-input-bg: #ffffff;
  --yh-code-bg: #f1f5f9;

  /* Borders & Dividers (>= 3:1 contrast on interactive controls) */
  --yh-border: #cbd5e1;
  --yh-border-subtle: #e2e8f0;
  --yh-border-strong: #94a3b8;
  --yh-input-border: #64748b;

  /* Typography (Strong Dark Navy Hierarchy — >= 7.5:1 even on muted text) */
  --yh-text: #0f172a;
  --yh-text-secondary: #1e293b;
  --yh-text-muted: #475569;
  --yh-placeholder: #64748b;
  --yh-code-text: #1e3a8a;

  /* Brand & Interactive Accents (#ffffff on #1d4ed8 = 6.70:1) */
  --yh-primary: #1d4ed8;
  --yh-primary-hover: #1e40af;
  --yh-primary-contrast: #ffffff;
  --yh-primary-soft: #eff6ff;
  --yh-primary-border: #93c5fd;
  --yh-link: #1d4ed8;
  --yh-link-hover: #1e3a8a;
  --yh-focus-ring: #1d4ed8;

  /* Semantic Status Palettes — Light Mode (All >= 6.8:1 text contrast) */
  --yh-success-bg: #ecfdf5;
  --yh-success-border: #6ee7b7;
  --yh-success-text: #065f46;

  --yh-info-bg: #eff6ff;
  --yh-info-border: #93c5fd;
  --yh-info-text: #1e40af;

  --yh-warning-bg: #fffbeb;
  --yh-warning-border: #f59e0b;
  --yh-warning-text: #78350f;

  --yh-danger-bg: #fef2f2;
  --yh-danger-border: #f87171;
  --yh-danger-text: #991b1b;

  --yh-purple-bg: #f5f3ff;
  --yh-purple-border: #c4b5fd;
  --yh-purple-text: #5b21b6;

  --yh-neutral-pill-bg: #f1f5f9;
  --yh-neutral-pill-border: #cbd5e1;
  --yh-neutral-pill-text: #334155;

  /* Staging Notice Banner (High-Contrast Amber Safety Strip) */
  --yh-staging-bg: #fffbeb;
  --yh-staging-border: #f59e0b;
  --yh-staging-text: #78350f;
  --yh-staging-badge-bg: #fef3c7;

  /* Shadows & Radii — Apple-Inspired Spacious Elevation */
  --yh-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --yh-shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.04);
  --yh-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --yh-shadow-lg: 0 24px 56px -14px rgba(15, 23, 42, 0.16), 0 8px 20px -6px rgba(15, 23, 42, 0.06);
  --yh-hero-glow: radial-gradient(circle at 72% 32%, rgba(37, 99, 235, 0.12), rgba(14, 165, 233, 0.06) 42%, transparent 72%);

  --yh-radius-xs: 6px;
  --yh-radius-sm: 10px;
  --yh-radius: 14px;
  --yh-radius-lg: 20px;
  --yh-radius-xl: 26px;

  /* Coordinated Nine-Family Visual Identity Accents (Light Mode) */
  --fam-business: #1d4ed8;
  --fam-business-soft: #eff6ff;
  --fam-property: #0f766e;
  --fam-property-soft: #f0fdfa;
  --fam-home: #0284c7;
  --fam-home-soft: #f0f9ff;
  --fam-book: #b45309;
  --fam-book-soft: #fffbeb;
  --fam-church: #2563eb;
  --fam-church-soft: #eff6ff;
  --fam-nonprofit: #059669;
  --fam-nonprofit-soft: #ecfdf5;
  --fam-school: #1e3a8a;
  --fam-school-soft: #eef2ff;
  --fam-family: #047857;
  --fam-family-soft: #ecfdf5;
  --fam-friends: #7c3aed;
  --fam-friends-soft: #f5f3ff;

  /* Spacing & Typography Scale */
  --yh-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --yh-font-mono: 'SFMono-Regular', ui-monospace, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;

  --yh-bg: #0b1120;
  --yh-surface: #111827;
  --yh-surface-elevated: #1e293b;
  --yh-surface-subtle: #0f172a;
  --yh-surface-hover: #1e293b;
  --yh-header-bg: rgba(11, 17, 32, 0.94);
  --yh-input-bg: #0f172a;
  --yh-code-bg: #1e293b;

  --yh-border: #334155;
  --yh-border-subtle: #1e293b;
  --yh-border-strong: #475569;
  --yh-input-border: #64748b;

  --yh-text: #f8fafc;
  --yh-text-secondary: #e2e8f0;
  --yh-text-muted: #cbd5e1;
  --yh-placeholder: #94a3b8;
  --yh-code-text: #bfdbfe;

  /* #ffffff on #2563eb = 5.17:1 (WCAG AA compliant) */
  --yh-primary: #2563eb;
  --yh-primary-hover: #1d4ed8;
  --yh-primary-contrast: #ffffff;
  --yh-primary-soft: rgba(37, 99, 235, 0.2);
  --yh-primary-border: #60a5fa;
  --yh-link: #93c5fd;
  --yh-link-hover: #dbeafe;
  --yh-focus-ring: #60a5fa;

  --yh-success-bg: rgba(6, 95, 70, 0.42);
  --yh-success-border: #34d399;
  --yh-success-text: #d1fae5;

  --yh-info-bg: rgba(30, 64, 175, 0.42);
  --yh-info-border: #60a5fa;
  --yh-info-text: #dbeafe;

  --yh-warning-bg: rgba(146, 64, 14, 0.42);
  --yh-warning-border: #fbbf24;
  --yh-warning-text: #fef3c7;

  --yh-danger-bg: rgba(153, 27, 27, 0.45);
  --yh-danger-border: #f87171;
  --yh-danger-text: #fee2e2;

  --yh-purple-bg: rgba(91, 33, 182, 0.42);
  --yh-purple-border: #c4b5fd;
  --yh-purple-text: #ede9fe;

  --yh-neutral-pill-bg: #1e293b;
  --yh-neutral-pill-border: #475569;
  --yh-neutral-pill-text: #e2e8f0;

  --yh-staging-bg: #1e1b10;
  --yh-staging-border: #d97706;
  --yh-staging-text: #fef3c7;
  --yh-staging-badge-bg: rgba(245, 158, 11, 0.22);

  --yh-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --yh-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.42);
  --yh-shadow: 0 14px 34px -8px rgba(0, 0, 0, 0.58);
  --yh-shadow-lg: 0 28px 60px -14px rgba(0, 0, 0, 0.75);
  --yh-hero-glow: radial-gradient(circle at 72% 32%, rgba(59, 130, 246, 0.2), rgba(20, 184, 166, 0.1) 44%, transparent 74%);

  /* Coordinated Nine-Family Visual Identity Accents (Dark Mode) */
  --fam-business: #60a5fa;
  --fam-business-soft: rgba(37, 99, 235, 0.18);
  --fam-property: #2dd4bf;
  --fam-property-soft: rgba(13, 148, 136, 0.18);
  --fam-home: #38bdf8;
  --fam-home-soft: rgba(2, 132, 199, 0.18);
  --fam-book: #fbbf24;
  --fam-book-soft: rgba(180, 83, 9, 0.22);
  --fam-church: #93c5fd;
  --fam-church-soft: rgba(37, 99, 235, 0.18);
  --fam-nonprofit: #34d399;
  --fam-nonprofit-soft: rgba(5, 150, 105, 0.2);
  --fam-school: #818cf8;
  --fam-school-soft: rgba(79, 70, 229, 0.2);
  --fam-family: #34d399;
  --fam-family-soft: rgba(4, 120, 87, 0.2);
  --fam-friends: #c4b5fd;
  --fam-friends-soft: rgba(124, 58, 237, 0.22);
}

/* Accessibility: Skip Link */
.yh-skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 9999;
  background: var(--yh-primary);
  color: var(--yh-primary-contrast);
  padding: 0.65rem 1.1rem;
  border-radius: var(--yh-radius-sm);
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  box-shadow: var(--yh-shadow);
}

.yh-skip-link:focus {
  left: 0.75rem;
  outline: 3px solid var(--yh-focus-ring);
  outline-offset: 2px;
}

/* Accessibility: High-Visibility Keyboard Focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--yh-focus-ring);
  outline-offset: 2px;
}

/* Segmented 3-Mode Appearance Selector (Light / Dark / System) */
.yh-theme-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--yh-surface-elevated);
  border: 1px solid var(--yh-border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.yh-theme-option {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--yh-text-muted);
  font-family: var(--yh-font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.42rem 0.62rem;
  min-height: 32px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.yh-theme-option:hover {
  color: var(--yh-text);
}

.yh-theme-option[aria-pressed="true"] {
  background: var(--yh-surface);
  color: var(--yh-text);
  border-color: var(--yh-border);
  box-shadow: var(--yh-shadow-xs);
  font-weight: 700;
}

/* Semantic Text & Surface Utilities (Zero Hardcoded Dark-Only Inline Hexes) */
.yh-text-strong {
  color: var(--yh-text) !important;
}

.yh-text-secondary {
  color: var(--yh-text-secondary) !important;
}

.yh-text-muted {
  color: var(--yh-text-muted) !important;
}

.yh-text-link {
  color: var(--yh-link) !important;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.yh-text-link:hover {
  color: var(--yh-link-hover) !important;
}

.yh-text-success {
  color: var(--yh-success-text) !important;
}

.yh-text-warning {
  color: var(--yh-warning-text) !important;
}

.yh-text-danger {
  color: var(--yh-danger-text) !important;
}

.yh-text-info {
  color: var(--yh-info-text) !important;
}

.yh-text-purple {
  color: var(--yh-purple-text) !important;
}

.yh-code-accent {
  font-family: var(--yh-font-mono);
  font-size: 0.8em;
  background: var(--yh-code-bg);
  color: var(--yh-code-text);
  border: 1px solid var(--yh-border-subtle);
  padding: 0.12rem 0.4rem;
  border-radius: 5px;
}

.yh-tabular {
  font-variant-numeric: tabular-nums;
}

.yh-subcard {
  background: var(--yh-surface-subtle);
  border: 1px solid var(--yh-border);
  border-radius: var(--yh-radius-sm);
  padding: 0.9rem 1rem;
  color: var(--yh-text);
}

.yh-callout {
  border-radius: var(--yh-radius-sm);
  padding: 0.85rem 1.05rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid var(--yh-border);
}

.yh-callout-info {
  background: var(--yh-info-bg);
  border-color: var(--yh-info-border);
  color: var(--yh-info-text);
}

.yh-callout-success {
  background: var(--yh-success-bg);
  border-color: var(--yh-success-border);
  color: var(--yh-success-text);
}

.yh-callout-warning {
  background: var(--yh-warning-bg);
  border-color: var(--yh-warning-border);
  color: var(--yh-warning-text);
}

.yh-callout-danger {
  background: var(--yh-danger-bg);
  border-color: var(--yh-danger-border);
  color: var(--yh-danger-text);
}

/* Screen-reader only utility */
.yh-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;
}

/* Reduced Motion Preference (WCAG 2.2 AA) */
@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;
  }
}

@media (max-width: 640px) {
  .yh-theme-option span.yh-theme-label {
    display: none;
  }
  .yh-theme-option {
    padding: 0.45rem 0.55rem;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
  }
}

