/* ==========================================================================
   WHIS33 THEME FOUNDATION
   Loaded AFTER style.css and Bootstrap. Defines the modern design system:
   palette, breakpoints, motion, typography tokens, and global a11y rules.
   Inline <style> blocks in pages may override these tokens locally.
   ========================================================================== */

:root {
  /* --- Modern palette ------------------------------------------------------ */
  --bg-0: #0A0A0F;
  --bg-1: #10131A;
  --bg-2: #151925;
  --surface: #1A1F2E;
  --surface-hi: #222839;
  --border: #2A3142;
  --border-hi: #3a4258;

  --accent-green: #45F882;
  --accent-green-dim: #2DD36F;
  --accent-green-soft: rgba(69, 248, 130, 0.12);
  --accent-purple: #A78BFA;
  --accent-purple-dim: #8B6FE8;
  --accent-cyan: #22D3EE;

  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #22C55E;

  --text-0: #F8FAFC;
  --text-1: #CBD5E1;
  --text-2: #94A3B8;
  --text-3: #64748B;

  /* --- Legacy aliases (keep existing inline styles working) --------------- */
  --primary: var(--accent-green);
  --primary-dark: var(--accent-green-dim);
  --primary-glow: rgba(69, 248, 130, 0.28);
  --text-primary: var(--text-0);
  --text-secondary: var(--text-1);
  --text-muted: var(--text-2);

  /* --- Gradients ---------------------------------------------------------- */
  --gradient-brand: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-purple) 100%);
  --gradient-brand-soft: linear-gradient(135deg, rgba(69, 248, 130, 0.15) 0%, rgba(167, 139, 250, 0.15) 100%);
  --gradient-mesh: radial-gradient(at 20% 0%, rgba(69, 248, 130, 0.12) 0px, transparent 50%),
                   radial-gradient(at 80% 30%, rgba(167, 139, 250, 0.10) 0px, transparent 55%),
                   radial-gradient(at 40% 100%, rgba(34, 211, 238, 0.08) 0px, transparent 60%);

  /* --- Spacing scale ------------------------------------------------------ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* --- Radius ------------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-pill: 999px;

  /* --- Typography --------------------------------------------------------- */
  --font-display: 'Rajdhani', 'Poppins', system-ui, -apple-system, sans-serif;
  --font-body:    'Poppins', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, Consolas, monospace;

  --fs-xs:  clamp(0.75rem, 0.4vw + 0.65rem, 0.8rem);
  --fs-sm:  clamp(0.85rem, 0.4vw + 0.75rem, 0.9rem);
  --fs-base:clamp(0.95rem, 0.5vw + 0.8rem, 1rem);
  --fs-lg:  clamp(1.05rem, 0.8vw + 0.85rem, 1.15rem);
  --fs-xl:  clamp(1.2rem, 1vw + 0.9rem, 1.4rem);
  --fs-h3:  clamp(1.35rem, 1.8vw + 0.9rem, 1.75rem);
  --fs-h2:  clamp(1.6rem, 2.5vw + 0.9rem, 2.4rem);
  --fs-h1:  clamp(1.9rem, 4vw + 1rem, 3.5rem);
  --fs-hero:clamp(2.1rem, 5vw + 1rem, 4rem);

  /* --- Motion ------------------------------------------------------------- */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 140ms;
  --dur-mid:  240ms;
  --dur-slow: 420ms;

  /* --- Shadows ------------------------------------------------------------ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow-green: 0 0 0 1px rgba(69, 248, 130, 0.25), 0 12px 30px -8px rgba(69, 248, 130, 0.25);
  --shadow-glow-purple:0 0 0 1px rgba(167, 139, 250, 0.25), 0 12px 30px -8px rgba(167, 139, 250, 0.25);

  /* --- Breakpoints (for JS & CSS @container refs) ------------------------- */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1536px;
}

/* ==========================================================================
   Global reset-extras + a11y
   ========================================================================== */

html {
  scroll-behavior: smooth;
}

/* Force solid dark bg site-wide. Some pages / older CSS had pale or transparent
   gradients — and SASS @use directive at the top of style.css tripped some
   parsers and blanked body styles. Locking html + body to bg-0 kills all of that. */
html, body {
  background-color: #0A0A0F !important;
  color: #F8FAFC;
  min-height: 100vh;
}
body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Reduced motion — respect user OS preference */
@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;
  }
}

/* Consistent focus ring for all keyboard nav (works with existing styles) */
:where(a, button, input, select, textarea, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
  border-radius: 4px;
}
:where(button, [role="button"]):focus-visible {
  box-shadow: 0 0 0 4px rgba(69, 248, 130, 0.25);
}

/* Touch-device hover guard — disable hover-only effects on touch */
@media (hover: none) {
  .hover-only { display: none !important; }
}

/* ==========================================================================
   Small utility classes
   ========================================================================== */

.th-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;
}

.th-brand-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.th-container {
  width: min(100% - var(--space-8), 1280px);
  margin-inline: auto;
}

.th-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.th-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin-block: var(--space-8);
}

.th-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
}
.th-chip--green {
  background: var(--accent-green-soft);
  border-color: rgba(69, 248, 130, 0.3);
  color: var(--accent-green);
}

/* Button press effect — applied to common button classes */
button:active:not(:disabled),
.btn:active:not(:disabled),
.th-btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* Smooth theme-controlled transitions */
a, button, .card, .th-card {
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-mid) var(--ease-out),
    box-shadow var(--dur-mid) var(--ease-out);
}

/* ==========================================================================
   Fix: hero page-entry reveal
   ========================================================================== */
.th-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.th-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Toast system
   ========================================================================== */
.th-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.th-toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-green);
  color: var(--text-0);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  min-width: 240px;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: th-toast-in 260ms var(--ease-out);
}
.th-toast.th-toast--error   { border-left-color: var(--danger);  }
.th-toast.th-toast--warning { border-left-color: var(--warning); }
.th-toast.th-toast--info    { border-left-color: var(--accent-cyan); }
.th-toast.is-leaving { animation: th-toast-out 220ms var(--ease-inout) forwards; }

@keyframes th-toast-in  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes th-toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ==========================================================================
   Footer responsive polish (overrides style.css base)
   ========================================================================== */
.footer .footer-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(24px, 4vw, 48px);
    max-width: 1280px;
    margin: 0 auto;
    padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 40px);
}
.footer .footer-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.footer .footer-section h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-0);
    margin: 0 0 8px 0;
    letter-spacing: 0.04em;
}
.footer .footer-section p,
.footer .footer-section a {
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.5;
    text-decoration: none;
    transition: color 160ms var(--ease-out);
}
.footer .footer-section a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.footer .footer-section a:hover,
.footer .footer-section a:focus-visible {
    color: var(--accent-green);
}
.footer .social-links {
    display: flex;
    justify-content: center;
    gap: 14px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    max-width: 1280px;
    margin: 0 auto;
}
.footer .social-links a {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-1);
    font-size: 1rem;
    transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out), background 160ms var(--ease-out), transform 180ms var(--ease-out);
}
.footer .social-links a:hover,
.footer .social-links a:focus-visible {
    color: var(--accent-green);
    border-color: rgba(69, 248, 130, 0.35);
    background: var(--surface-hi);
    transform: translateY(-2px);
}
.footer .footer-bottom {
    text-align: center;
    padding: 20px;
    color: var(--text-3);
    font-size: 0.85rem;
}
.footer .footer-bottom strong { color: var(--text-1); }

@media (max-width: 1024px) {
    .footer .footer-content { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .footer .footer-content { grid-template-columns: 1fr; gap: 24px; }
}

/* ==========================================================================
   Skip-to-content link (a11y)
   ========================================================================== */
.th-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-green);
  color: var(--bg-0);
  padding: 10px 14px;
  font-weight: 700;
  z-index: 10000;
  border-radius: 0 0 var(--radius-sm) 0;
}
.th-skip-link:focus {
  left: 0;
}
