/**
 * Wangklaikangwon Industrial and Community Education College (KKWIND)
 * Institutional Design Tokens & Core Style System
 * 
 * Version: 2.1.0
 * Architecture: CSS Custom Properties (Tokens) + Institutional Component Primitives
 * Conformance: WCAG 2.1 AA Standards (Contrast Ratio >= 4.5:1 for normal text, >= 3:1 for large text)
 * Responsive Viewports: Mobile (320px - 640px), Tablet (768px - 1024px), Desktop (1200px+)
 * Touch Target Standard: Ergonomic Touch Guidelines (Min 44x44px interactive tap area)
 * 
 * Documentation & Extension Guide:
 * - Brand Colors: Iconic Wangklaikangwon navy/purple palette (--color-primary, --color-primary-dark).
 * - Surfaces & Contrast: Dignified institutional surfaces without overly saturated tech/AI neon glows.
 * - Corner Radii: Strict institutional card standard (--radius-card: 8px, --radius-btn: 6px, --radius-menu: 6px).
 * - Elevation: Natural multi-layer soft shadows replacing harsh borders or hyper-diffuse glows.
 * - Reusable Classes: Use .btn-primary, .btn-secondary, .btn-outline, .btn-ghost, .inst-card, .touch-target.
 */

:root {
  /* ==========================================================================
     1. Brand Color Palette (College Navy, Dignified Purple & Academic Accents)
     ========================================================================== */
  /* Primary College Navy / Purple */
  --color-primary: #2b1b54;            /* Primary brand: Deep institutional purple-navy */
  --color-primary-hover: #3b2374;      /* Hover state: 10% lighter */
  --color-primary-active: #1d123a;     /* Active/pressed state */
  --color-primary-dark: #1b1031;       /* Deep header/footer canvas */
  --color-primary-light: #5b21b6;      /* Accent violet for focused highlights */
  --color-primary-subtle: #f5f3ff;     /* 5% tint for badge/card highlight backgrounds */
  --color-primary-tint: #ede9fe;       /* 10% tint for active hover tabs */
  
  /* Secondary & Neutral Slate */
  --color-secondary: #1e293b;          /* Professional slate navy for secondary actions */
  --color-secondary-hover: #0f172a;    /* Darker slate hover */
  --color-secondary-subtle: #f1f5f9;   /* Subtle slate background */
  
  /* Institutional Academic Accent */
  --color-accent: #b45309;             /* Academic gold / amber */
  --color-accent-hover: #92400e;       /* Hover gold */
  --color-accent-subtle: #fef3c7;      /* Subtle warm gold tint for alerts & awards */
  --color-accent-text: #78350f;        /* High-contrast gold text */

  /* Semantic Feedback Colors */
  --color-success: #15803d;            /* WCAG AA compliant green */
  --color-success-subtle: #dcfce7;
  --color-warning: #b45309;            /* WCAG AA compliant amber */
  --color-warning-subtle: #fef3c7;
  --color-danger: #b91c1c;             /* WCAG AA compliant red */
  --color-danger-subtle: #fee2e2;
  --color-info: #1d4ed8;               /* WCAG AA compliant blue */
  --color-info-subtle: #dbeafe;

  /* Surfaces & Backgrounds */
  --color-surface: #ffffff;            /* Pure white card surface */
  --color-surface-subtle: #f8fafc;     /* Clean off-white page background */
  --color-surface-muted: #f1f5f9;      /* Container background */
  --color-surface-dark: #1b1031;       /* Deep institutional dark section */
  --color-surface-dark-card: #261646;  /* Card surface on dark sections */
  
  /* High-Contrast Typography (WCAG 2.1 AA / AAA) */
  --color-text-primary: #0f172a;       /* 15.3:1 contrast against white (AAA) */
  --color-text-secondary: #334155;     /* 7.5:1 contrast against white (AAA) */
  --color-text-muted: #475569;         /* 4.8:1 contrast against white (AA) */
  --color-text-light: #ffffff;         /* Pure white on dark backgrounds */
  --color-text-light-muted: #cbd5e1;   /* Muted text on dark canvas */
  --color-text-brand: #2b1b54;

  /* Institutional Borders */
  --color-border: #e2e8f0;             /* Crisp clean border */
  --color-border-subtle: #f1f5f9;      /* Extra light separator */
  --color-border-strong: #cbd5e1;      /* Focused input / card border */
  --color-border-dark: rgba(255, 255, 255, 0.15); /* Border on dark background */

  /* Legacy Property Aliases for Seamless Backward-Compatibility across Templates */
  --primary: #2b1b54;
  --secondary: #1e293b;
  --accent: #b45309;
  --dark: #1b1031;
  --light: #f8fafc;
  --white: #ffffff;
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --border-radius-lg: 6px;
  --gradient-primary: linear-gradient(135deg, #1b1031 0%, #2b1b54 100%);
  --gradient-accent: linear-gradient(135deg, #b45309 0%, #2b1b54 100%);
  --gradient-dark: linear-gradient(135deg, #110b22 0%, #1b1031 100%);

  /* ==========================================================================
     2. Typography Scales & Weights
     ========================================================================== */
  --font-family-base: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-md: 1.125rem;   /* 18px */
  --font-size-lg: 1.25rem;    /* 20px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-2xl: 1.875rem;  /* 30px */
  --font-size-3xl: 2.25rem;   /* 36px */
  --font-size-4xl: 2.75rem;   /* 44px */

  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.65;

  /* ==========================================================================
     3. Institutional Elevation System (Soft multi-layer shadows, no neon AI glows)
     ========================================================================== */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.07), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  
  /* Semantic Component Elevation */
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 8px 20px -2px rgba(27, 16, 49, 0.12), 0 3px 6px -1px rgba(27, 16, 49, 0.06);
  --shadow-dropdown: 0 10px 25px -3px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);

  /* ==========================================================================
     4. Border Radius Scale (Strict Institutional Standard: 4px to 8px max!)
     Replaces informal bubble / pill 20px+ radii with crisp rectangular contours
     ========================================================================== */
  --radius-none: 0;
  --radius-xs: 2px;
  --radius-sm: 4px;           /* Minor elements, file-type tags, badges */
  --radius-md: 6px;           /* Interactive buttons, inputs, dropdown menus */
  --radius-lg: 8px;           /* Main cards, modal frames, banner frames */
  
  /* Semantic Component Radii */
  --radius-card: 8px;         /* Canonical card radius */
  --radius-btn: 6px;          /* Canonical button radius */
  --radius-menu: 6px;         /* Dropdown menu radius */
  --radius-badge: 4px;        /* Badge / pill replacement radius */
  --radius-input: 6px;        /* Form input radius */
  --radius-thumb: 6px;        /* Image thumbnail corner radius */

  /* ==========================================================================
     5. Spacing & Ergonomic Touch Targets (Min 44x44px for UX/UI Best Practices)
     ========================================================================== */
  --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 */

  --touch-target-min: 44px; /* Minimum interactive touch area on mobile */
  
  /* ==========================================================================
     6. Transitions & Motion (Smooth, CLS-safe, GPU-accelerated)
     ========================================================================== */
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Global Viewport & Overflow Guards (R1: Zero Page Horizontal Overflow)
   ========================================================================== */
html {
  box-sizing: border-box;
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  font-family: var(--font-family-base);
  color: var(--color-text-primary);
  background-color: var(--color-surface-subtle);
  line-height: var(--line-height-normal);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body, h1, h2, h3, h4, h5, h6, p, a, span {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   Standardized Touch Targets (R3: UX/UI Ergonomics)
   ========================================================================== */
.touch-target {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Standardized Institutional Button System (R2, R3)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.25rem;
  min-height: var(--touch-target-min);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
  border-radius: var(--radius-btn) !important;
  border: 1.5px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-base);
  user-select: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 3px solid rgba(43, 27, 84, 0.45);
  outline-offset: 2px;
}

/* Primary Button: College Navy/Purple */
.btn-primary,
.btn-hero-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-light) !important;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.btn-hero-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-text-light) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active,
.btn-hero-primary:active {
  background-color: var(--color-primary-active);
  border-color: var(--color-primary-active);
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

/* Secondary Button: Slate Navy */
.btn-secondary,
.btn-hero-secondary {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-text-light) !important;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover,
.btn-hero-secondary:hover {
  background-color: var(--color-secondary-hover);
  border-color: var(--color-secondary-hover);
  color: var(--color-text-light) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Outline Buttons */
.btn-outline-primary {
  background-color: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary) !important;
}

.btn-outline-primary:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-light) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-outline-secondary {
  background-color: transparent;
  border-color: var(--color-secondary);
  color: var(--color-secondary) !important;
}

.btn-outline-secondary:hover {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-text-light) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-outline-light {
  background-color: transparent;
  border-color: rgba(255, 255, 255, 0.7);
  color: var(--color-text-light) !important;
}

.btn-outline-light:hover {
  background-color: var(--color-text-light);
  border-color: var(--color-text-light);
  color: var(--color-primary-dark) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Ghost Button */
.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--color-primary);
}

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

/* Button Sizes */
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: var(--font-size-sm);
  min-height: 38px;
  border-radius: var(--radius-sm) !important;
}

@media (max-width: 991.98px) {
  .btn-sm {
    min-height: var(--touch-target-min); /* Ergonomic touch target on mobile */
  }
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: var(--font-size-md);
  min-height: 50px;
  border-radius: var(--radius-btn) !important;
}

/* ==========================================================================
   Institutional Cards & Containers (R2: Rectangular subtle radii, natural elevation)
   ========================================================================== */
.card,
.inst-card,
.modal-content {
  border-radius: var(--radius-card) !important;
}

.modal-content {
  box-shadow: var(--shadow-modal) !important;
  border: 1px solid var(--color-border) !important;
}

.dropdown-menu {
  border-radius: var(--radius-menu) !important;
  box-shadow: var(--shadow-dropdown) !important;
}

.inst-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card) !important;
  box-shadow: var(--shadow-card);
  transition: var(--transition-base);
  overflow: hidden;
  position: relative;
}

.inst-card:hover {
  border-color: rgba(43, 27, 84, 0.25);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

/* ==========================================================================
   Institutional Badges (Subtle 4px radius, clear contrast)
   ========================================================================== */
.inst-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-badge);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}

.inst-badge-primary {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
  border: 1px solid rgba(43, 27, 84, 0.15);
}

.inst-badge-featured {
  background-color: var(--color-accent);
  color: var(--color-text-light);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Accessible Reduced Motion
   ========================================================================== */
@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;
  }
}
