/* ==========================================================================
   base.css — Design tokens, reset, typography, global defaults, utilities
   ========================================================================== */

/* ── Self-hosted Inter (variable font, latin subset) ──
   Eliminates Google Fonts FOUT and removes the runtime CSP allowance for
   googleapis/gstatic. The single woff2 contains all weights from 100-900;
   the browser renders the requested font-weight directly from the file. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── Design Tokens ── */
:root {
  /* Brand */
  --color-primary: #3E93EB;
  --color-primary-light: #6BAEF0;
  --color-primary-dark: #2A75C4;
  --color-secondary: #48D0D4;
  --color-secondary-light: #7FDDE0;
  --color-secondary-dark: #2FA9AD;
  --color-accent: #F6B507;
  --color-accent-light: #FCC940;
  --color-accent-dark: #C7910A;

  /* Semantic */
  --color-success: #16a34a;
  --color-warning: #F6B507;
  --color-error: #dc2626;
  --color-info: #3E93EB;

  /* Surfaces & text (light theme) */
  --color-bg: #eaf4fe;
  --color-bg-gradient: linear-gradient(135deg, #eaf4fe 0%, #e0f7fa 40%, #fef9e7 100%);
  --color-surface: #ffffff;
  --color-surface-glass: rgba(255, 255, 255, 0.55);
  --color-surface-glass-strong: rgba(255, 255, 255, 0.75);
  --color-surface-glass-stronger: rgba(255, 255, 255, 0.85);
  --color-surface-glass-max: rgba(255, 255, 255, 0.90);
  --color-overlay-white-faint: rgba(255, 255, 255, 0.08);
  --color-overlay-white-light: rgba(255, 255, 255, 0.10);
  --color-overlay-white-mild: rgba(255, 255, 255, 0.20);
  --color-overlay-white-soft: rgba(255, 255, 255, 0.25);
  --color-overlay-white-medium: rgba(255, 255, 255, 0.35);
  --color-overlay-white-border: rgba(255, 255, 255, 0.30);
  --color-overlay-white-shine: rgba(255, 255, 255, 0.40);
  --color-overlay-white-half: rgba(255, 255, 255, 0.50);
  --color-overlay-white-strong: rgba(255, 255, 255, 0.80);
  --color-overlay-white-bold: rgba(255, 255, 255, 0.90);
  --color-overlay-white-full: rgba(255, 255, 255, 1);
  --color-overlay-black-soft: rgba(0, 0, 0, 0.04);
  --color-overlay-black-faint: rgba(0, 0, 0, 0.06);
  --color-overlay-black-medium: rgba(0, 0, 0, 0.08);
  --color-overlay-black-light: rgba(0, 0, 0, 0.10);
  --color-overlay-black-mild: rgba(0, 0, 0, 0.15);
  --color-primary-alpha-04: rgba(62, 147, 235, 0.04);
  --color-primary-alpha-06: rgba(62, 147, 235, 0.06);
  --color-primary-alpha-20: rgba(62, 147, 235, 0.20);
  --color-primary-alpha-25: rgba(62, 147, 235, 0.25);
  --color-primary-alpha-30: rgba(62, 147, 235, 0.30);
  --color-primary-alpha-40: rgba(62, 147, 235, 0.40);
  --color-primary-alpha-50: rgba(62, 147, 235, 0.50);
  --color-secondary-alpha-04: rgba(72, 208, 212, 0.04);
  --color-secondary-alpha-06: rgba(72, 208, 212, 0.06);
  --color-secondary-alpha-10: rgba(72, 208, 212, 0.10);
  --color-secondary-alpha-20: rgba(72, 208, 212, 0.20);
  --color-secondary-alpha-30: rgba(72, 208, 212, 0.30);
  --color-secondary-alpha-40: rgba(72, 208, 212, 0.40);
  --color-secondary-alpha-50: rgba(72, 208, 212, 0.50);
  --color-secondary-alpha-70: rgba(72, 208, 212, 0.70);
  --color-error-alpha-12: rgba(220, 38, 38, 0.12);
  --color-error-alpha-20: rgba(220, 38, 38, 0.20);
  --color-accent-alpha-12: rgba(246, 181, 7, 0.12);
  --color-primary-alpha-12: rgba(62, 147, 235, 0.12);
  --color-secondary-alpha-12: rgba(72, 208, 212, 0.12);
  /* Neutral subtle surface — input/select/code backgrounds inside cards. */
  --color-surface-subtle: #f4f7fb;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-text-inverse: #ffffff;
  --color-muted: #6b7280;
  --color-border: rgba(31, 41, 55, 0.10);
  --color-border-strong: rgba(31, 41, 55, 0.18);
  --color-focus: #F6B507;
  --color-link: #2A75C4;
  --color-link-visited: #6B5BB0;

  /* Admin dashboard — dark sidebar rail + flat content surface */
  --color-sidebar-bg: #1e293b;
  --color-sidebar-bg-hover: #334155;
  --color-sidebar-text: rgba(255, 255, 255, 0.80);
  --color-sidebar-text-dim: rgba(255, 255, 255, 0.50);
  --color-sidebar-border: rgba(255, 255, 255, 0.10);
  --color-dashboard-bg: #f9fafb;

  /* Status / destructive accents — dashboard badges, stat icons, charts */
  --color-danger: #ef4444;
  --color-danger-soft: rgba(239, 68, 68, 0.10);
  --color-danger-strong: #b91c1c;
  --color-success-strong: #047857;
  --color-warning-surface: #fde68a;
  --color-warning-text: #92400e;

  /* Attendance status palette — dashboard attendance badges (present/late/excused
     count as "attended"; ported from the legacy .att--* colours). */
  --color-attendance-present-surface: #e6f6e6;
  --color-attendance-present-text: #116611;
  --color-attendance-present-border: #b7e3b7;
  --color-attendance-absent-surface: #ffe9e9;
  --color-attendance-absent-text: #a11212;
  --color-attendance-absent-border: #f7b6b6;
  --color-attendance-late-surface: #fff4e5;
  --color-attendance-late-text: #8a4b00;
  --color-attendance-late-border: #ffd9a6;
  --color-attendance-excused-surface: #eaf2ff;
  --color-attendance-excused-text: #0b4aa6;
  --color-attendance-excused-border: #c6d9ff;
  --color-attendance-unmarked-surface: #f2f2f3;
  --color-attendance-unmarked-text: #444444;
  --color-attendance-unmarked-border: #e0e0e0;

  /* Modal scrim — full-screen dim behind a dialog. */
  --color-scrim: rgba(15, 23, 42, 0.55);

  /* Typography */
  --font-family-base: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-display: "Inter", system-ui, sans-serif;
  --font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.75rem;
  --font-size-4xl: 3.5rem;
  --font-size-display: clamp(2.125rem, 5vw, 4rem);

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

  --line-height-extra-tight: 1.1;
  --line-height-tight: 1.15;
  --line-height-snug: 1.3;
  --line-height-base: 1.6;
  --line-height-loose: 1.8;

  /* Spacing (8px base) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;
  --spacing-4xl: 96px;
  --spacing-5xl: 128px;

  /* Border Radius */
  --radius-xs: 2px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-2xl: 24px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --radius-full: 9999px;

  /* Shadows (brand-tinted, soft) */
  --shadow-sm: 0 1px 3px rgba(31, 41, 55, 0.06);
  --shadow-md: 0 6px 18px rgba(62, 147, 235, 0.08);
  --shadow-lg: 0 14px 40px rgba(62, 147, 235, 0.14);
  --shadow-card-lift: 0 10px 15px -3px rgba(31, 41, 55, 0.10), 0 4px 6px -2px rgba(31, 41, 55, 0.05);
  --shadow-xl: 0 24px 60px rgba(62, 147, 235, 0.18);
  --shadow-glass: 0 8px 32px rgba(31, 41, 55, 0.08);
  --shadow-mascot: 0 16px 36px rgba(72, 208, 212, 0.30);
  --shadow-card-glass: 0 16px 32px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-card-brand: 0 20px 40px rgba(72, 208, 212, 0.20), 0 8px 16px rgba(62, 147, 235, 0.15);
  --shadow-slide-stack: 0 16px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-image-heavy: 0 22px 44px rgba(0, 0, 0, 0.25);
  --shadow-image-soft: 0 12px 24px rgba(0, 0, 0, 0.20);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  --gradient-warm: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  --gradient-brand: var(--gradient-primary);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --transition-reveal: 600ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-stagger: 80ms;
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-mascot: 250;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* Layout widths */
  --width-content: 720px;
  --width-wide: 1080px;
  --width-max: 1280px;

  /* Layout heights */
  --height-header: 64px;
  --section-py: clamp(4rem, 8vw, 7rem);

  /* Decorative sizes */
  --width-accent-line: 60px;
  --width-accent-line-thin: 2px;
  --bullet-size-md: 12px;

  /* Glass blur */
  --blur-sm: blur(6px);
  --blur-md: blur(12px);
  --blur-xl: blur(20px);
  --blur-lg: blur(24px);
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-snug);
  font-family: var(--font-family-display);
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:visited {
  color: var(--color-link-visited);
}

code {
  font-family: var(--font-family-mono);
}

/* Ensure the HTML hidden attribute always hides elements. */
[hidden] {
  display: none !important;
}

/* ── Focus states ── */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* ── Utilities ── */
.muted {
  color: var(--color-muted);
}

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

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: var(--z-overlay);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.skip-link:focus {
  top: 0;
}

/* ── Scroll Reveal ── */
/* Gated behind .js class added by init.js — content stays visible if JS fails */
.js .reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.js .reveal--left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.js .reveal--right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.js .reveal--scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

/* Subtler reveal variants used by Phase 4+ polish. */
.js .reveal--up-sm {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.js .reveal--fade {
  opacity: 0;
  transition: opacity var(--transition-reveal);
}

.js .reveal--blur {
  opacity: 0;
  filter: blur(6px);
  transition: opacity var(--transition-reveal), filter var(--transition-reveal);
}

/* GCO-97 candidate: zoom-rise + spring overshoot ("arrival pop"). */
.js .reveal--pop {
  opacity: 0;
  transform: translateY(34px) scale(0.9);
  transition:
    opacity 0.7s ease,
    transform 0.7s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.reveal.is-visible,
.reveal--left.is-visible,
.reveal--right.is-visible,
.reveal--scale.is-visible,
.reveal--up-sm.is-visible,
.reveal--fade.is-visible,
.reveal--blur.is-visible,
.reveal--pop.is-visible {
  opacity: 1;
  transform: translate(0) scale(1);
  filter: none;
}

/* Stagger children — legacy nth-child cascade (still used by existing markup). */
.stagger > .reveal:nth-child(1) { transition-delay: calc(0 * var(--transition-stagger)); }
.stagger > .reveal:nth-child(2) { transition-delay: calc(1 * var(--transition-stagger)); }
.stagger > .reveal:nth-child(3) { transition-delay: calc(2 * var(--transition-stagger)); }
.stagger > .reveal:nth-child(4) { transition-delay: calc(3 * var(--transition-stagger)); }
.stagger > .reveal:nth-child(5) { transition-delay: calc(4 * var(--transition-stagger)); }
.stagger > .reveal:nth-child(6) { transition-delay: calc(5 * var(--transition-stagger)); }

/* Stagger hook — scroll-stagger.js writes --stagger-i on each child so this
   delay scales to arbitrary list lengths without bespoke nth-child rules. */
.js .reveal[style*="--stagger-i"],
.js .reveal--up-sm[style*="--stagger-i"],
.js .reveal--fade[style*="--stagger-i"],
.js .reveal--blur[style*="--stagger-i"] {
  transition-delay: calc(var(--stagger-i, 0) * var(--transition-stagger) + var(--reveal-delay, 0ms));
}

/* Parents staggered via scroll-stagger.js receive .is-revealed; their children
   inherit visibility via .is-visible directly when the existing observer also
   tags them, but for parents with non-`.reveal` children we expose this hook. */
.is-revealed > [data-reveal] {
  opacity: 1;
  transform: none;
}

/* ── Section bridge component ──
   Decorative gradient strip used between adjacent sections to dissolve
   abrupt color seams. Colors are supplied by BEM modifier classes (no
   `style="..."` attributes per kore standards). */
.section-bridge {
  display: block;
  height: 12vh;
  min-height: 80px;
  background: linear-gradient(
    to bottom,
    var(--bridge-from, transparent),
    var(--bridge-to, transparent)
  );
  pointer-events: none;
  margin-block: calc(var(--section-py) * -0.5) 0;
}

/* ── 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;
  }

  .js .reveal,
  .js .reveal--left,
  .js .reveal--right,
  .js .reveal--scale,
  .js .reveal--up-sm,
  .js .reveal--fade,
  .js .reveal--blur,
  .js .reveal--pop {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* ── Print Styles ── */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  nav,
  .skip-link,
  .no-print {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }
}
