/**
 * EliteBulletin Design System — Master Tokens & Shell Components
 * Human-designed, restrained, fast, accessible.
 */

/* Native Cross-Document View Transitions (Zero-Reload / App Feel) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 160ms;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout & Sizing */
  --nav-height: 56px;
  --container-max: 1080px;
  --container-tool: 920px;

  /* Spacing */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-normal: 200ms;

  /* Palette: Light Mode (Default) */
  --bg-page: #fbfbfc;
  --bg-surface: #ffffff;
  --bg-subtle: #f5f6f8;
  --bg-hover: #ebecef;
  --bg-active: #e2e4e8;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-inverse: #ffffff;

  --border-subtle: #f0f1f4;
  --border-default: #e5e7eb;
  --border-hover: #d1d5db;
  --border-strong: #9ca3af;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: rgba(37, 99, 235, 0.08);

  --color-success: #059669;
  --color-success-subtle: rgba(5, 150, 105, 0.1);

  --color-error: #dc2626;
  --color-error-subtle: rgba(220, 38, 38, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);

  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-page: #0c0d0e;
  --bg-surface: #151719;
  --bg-subtle: #1c1e22;
  --bg-hover: #25282d;
  --bg-active: #2e3238;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #111827;

  --border-subtle: #1e2024;
  --border-default: #282a30;
  --border-hover: #373a42;
  --border-strong: #4b5563;

  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-subtle: rgba(59, 130, 246, 0.15);

  --color-success: #10b981;
  --color-success-subtle: rgba(16, 185, 129, 0.15);

  --color-error: #ef4444;
  --color-error-subtle: rgba(239, 68, 68, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);

  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* Base Reset & Typography Standards */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Global Unified AppHeader Component
   Consistent height, brand mark, navigation link, and theme toggle
   ========================================================================== */
.site-header {
  height: var(--nav-height);
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Brand Identity */
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: var(--space-1) 0;
  border-radius: var(--radius-sm);
  transition: opacity var(--dur-fast) var(--ease);
}

.brand-link:hover {
  opacity: 0.85;
}

.brand-icon {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-default);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  margin-left: 2px;
}

/* Header Navigation & Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.header-nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.header-nav-link svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* Unified Theme Toggle Button */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--color-primary);
}

.theme-toggle-btn svg {
  width: 17px;
  height: 17px;
  transition: transform var(--dur-normal) var(--ease);
}

.theme-toggle-btn:hover svg {
  transform: rotate(15deg);
}

/* ==========================================================================
   Global Unified AppFooter Component
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-default);
  background-color: var(--bg-page);
  margin-top: var(--space-16);
  padding: var(--space-8) 0;
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.footer-copy {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-nav a {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease);
}

.footer-nav a:hover {
  color: var(--color-primary);
}

/* ==========================================================================
   Shared Button Styles
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  text-decoration: none;
  line-height: 1.25;
  min-height: 38px;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

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

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 32px;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

/* Accessible Screen Reader 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-width: 0;
}
