/*
 * IMAT Quest — Design System
 * css/style.css
 *
 * This file defines all CSS custom properties (tokens), resets, base typography,
 * reusable components (buttons, cards, badges), and utility classes.
 * Every other CSS file imports or builds on top of these tokens.
 */

/* ============================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */

/* @layer base — puts these legacy token declarations below @layer tokens in cascade
   priority. tokens.css wraps its :root block in @layer tokens; since tokens loads
   after this file, @layer tokens is declared later = higher priority. Result: Ω fluid
   tokens in tokens.css always win over these flat legacy values for any clashing names
   (--text-*, --color-*, --font-*, --weight-*). Pages that don't load tokens.css
   (about-imat, medicine-italy, courses) are unaffected — no competing declarations. */
@layer base {
  :root {
    /* --- Brand Colors (Renaissance Editorial Palette, 2026-04-14) --- */
    --color-navy: #001f3d; /* Anchor — navbar, footer, headings, dark sections */
    --color-navy-light: #002a52; /* Lighter navy for dark card hover states */
    --color-navy-deep: #001428; /* Deeper navy for footer bg */
    --color-white: #ffffff; /* Dominant background */
    --color-cream: #f6eedc; /* Warm neutral — card backs, paper surfaces, soft dividers */
    --color-burgundy: #6b2838; /* Primary accent, deep end — ink, borders, CTA gradient end */
    --color-pink: #e8476b; /* Primary accent, light end — CTA gradient start, accent flourishes */
    --color-rose: #e8c4c9; /* Dusty rose (light burgundy) — map region base, soft hovers */
    --color-amber: #d99b47; /* Support accent — scholarship callouts, flourishes, highlight stats */
    --color-amber-ink: #8a651e; /* Darkened amber for informational TEXT on light bg (WCAG AA, ≈5.3:1 on white). Use --color-amber for fills, borders, rules, dark-bg text, decorative flourishes. */
    --color-teal: #2e7d7a; /* Cool contrast — wayfinding, filter chip active, data viz only */
    --color-ice: #dce7f3; /* Glass tint only — lives inside --glass-bg, never a flat fill */

    /* Accent family — any primary-accent surface should live on this ramp. */
    --gradient-accent: linear-gradient(135deg, var(--color-pink) 0%, var(--color-burgundy) 100%);
    --gradient-accent-wide: linear-gradient(
      135deg,
      var(--color-pink) 0%,
      var(--color-burgundy) 60%,
      var(--color-pink) 120%
    );

    /* Legacy alias — new work should prefer --color-amber. */
    --color-orange: var(--color-amber); /* was #eaa149 bright orange */

    /* --- Text Colors --- */
    --color-text-primary: #1e293b; /* Main body text — dark slate, not harsh black */
    --color-text-secondary: #64748b; /* Supporting text — subtitles, meta, helper text */
    --color-text-muted: #94a3b8; /* Muted — placeholders, disabled states */
    --color-text-white: #ffffff;
    --color-text-white-60: rgba(255, 255, 255, 0.6);
    --color-text-white-80: rgba(255, 255, 255, 0.8);

    /* --- Semantic / Utility Colors --- */
    --color-success: #16a34a;
    --color-warning: var(--color-amber); /* alias to amber — same semantic */
    --color-error: #dc2626;
    --color-border: #e2e8f0; /* Default border on cards */

    /* --- Subject Accent Colors (course card top borders only) --- */
    --color-biology: #16a34a;
    --color-chemistry: #2563eb;
    --color-physics: #7c3aed;
    --color-maths: #0891b2;
    --color-logic: #dc2626;
    --color-gk: var(--color-amber);

    /* --- Glass System (overlay / floating UI only — never on content cards) --- */
    --glass-bg: rgba(220, 231, 243, 0.55);
    --glass-blur: blur(18px) saturate(160%);
    --glass-border: 1px solid rgba(255, 255, 255, 0.65);
    --glass-shadow: 0 10px 40px -12px rgba(0, 31, 61, 0.22);
    --glass-fallback: var(--color-cream); /* solid fallback when backdrop-filter unsupported */

    /* --- Typography --- */
    --font-heading: "Outfit", sans-serif;
    --font-body: "Inter", sans-serif;
    --font-serif-editorial: Georgia, "Times New Roman", serif;
    --font-sans-system: system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", sans-serif;

    /* --- Font Sizes --- */
    --text-xs: 0.75rem; /* 12px */
    --text-sm: 0.8125rem; /* 13px */
    --text-base: 1rem; /* 16px */
    --text-lg: 1.125rem; /* 18px */
    --text-xl: 1.25rem; /* 20px */
    --text-2xl: 1.5rem; /* 24px */
    --text-3xl: 1.875rem; /* 30px */
    --text-4xl: 2.25rem; /* 36px */
    --text-5xl: 3rem; /* 48px */
    --text-6xl: 3.75rem; /* 60px */
    --text-7xl: 4.5rem; /* 72px */

    /* --- Font Weights --- */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* --- Line Heights --- */
    --leading-tight: 1.2;
    --leading-snug: 1.4;
    --leading-normal: 1.6;
    --leading-relaxed: 1.75;

    /* --- Spacing Scale --- */
    --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 */
    --space-20: 5rem; /* 80px */
    --space-24: 6rem; /* 96px */
    --space-30: 7.5rem; /* 120px — section padding */

    /* --- Border Radius --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* --- Shadows --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08);

    /* --- Transitions (legacy shorthand) --- */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* --- Durations (Part 5 motion system) --- */
    --duration-instant: 100ms;
    --duration-fast: 150ms;
    --duration-hover: 220ms;
    --duration-base: 250ms;
    --duration-moderate: 350ms;
    --duration-slow: 500ms;
    --duration-reveal: 700ms;

    /* --- Easing Curves (Part 5 motion system) --- */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- Movement Distances (Part 5 motion system) --- */
    --move-sm: 8px;
    --move-md: 16px;
    --move-lg: 20px;
    --move-reveal: 24px;
    --move-lift-sm: 4px;
    --move-lift-md: 6px;
    --move-lift-btn: 2px;

    /* --- Layout --- */
    --container-max: 1200px;
    --container-wide: 1400px;
    --navbar-height: 72px;
    --navbar-height-mobile: 60px;
    --section-padding: var(--space-30);

    /* --- Navbar: brooch badge --- */
    --brooch-bg: #f3d9c6; /* tint bleed behind logo */
    --brooch-border-color: rgba(74, 26, 38, 0.55);

    /* --- Navbar: silk state (over hero) --- */
    --silk-card-bg: linear-gradient(
      104deg,
      #c9a566 0%,
      #ddbe85 12%,
      #eed5a8 24%,
      #f7e6c2 36%,
      #fcefd4 50%,
      #f7e6c2 64%,
      #eed5a8 76%,
      #ddbe85 88%,
      #c9a566 100%
    );
    --silk-card-border: rgba(107, 40, 56, 0.45);

    /* --- Navbar: ink state (past hero) --- */
    --ink-card-bg: linear-gradient(
      95deg,
      #001829 0%,
      #002746 20%,
      #3a2438 45%,
      #4f2636 54%,
      #3a2438 63%,
      #002746 82%,
      #001829 100%
    );
    --ink-card-border: rgba(74, 26, 38, 0.55);

    /* --- Navbar: wordmark gradient (burgundy, both states) --- */
    --wordmark-gradient: linear-gradient(180deg, #7a2e3e 0%, #6b2838 50%, #4a1a26 100%);

    /* --- Navbar substrate + peek --- */
    --navbar-substrate: linear-gradient(135deg, #4a1a26 0%, #6b2838 45%, #3a0f18 100%);
    --peek-back: #dcc7a8; /* paper-deep */
    --peek-mid: #ead8bc; /* paper-shade */
  }
} /* end @layer base */

@keyframes nav-ink-drift {
  0% {
    background-position: 38% 50%;
  }
  100% {
    background-position: 62% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes nav-ink-drift {
    0%,
    100% {
      background-position: 50% 50%;
    }
  }
}

/* ============================================================
   2. RESET & BASE STYLES
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

input,
textarea,
select {
  font-family: var(--font-body);
}

/* ============================================================
   3. TYPOGRAPHY SCALE
   ============================================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-navy);
}

h1 {
  font-size: var(--text-7xl);
}
h2 {
  font-size: var(--text-5xl);
  font-weight: var(--weight-semibold);
}
h3 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
}
h4 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

p {
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
}

.text-lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

.overline {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-pink);
}

/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */

.container {
  inline-size: 100%;
  max-inline-size: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--wide {
  max-inline-size: var(--container-wide);
}

.section-padding {
  padding: var(--section-padding) 0;
}

.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}

.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid {
  display: grid;
}

/* ============================================================
   5. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  line-height: 1;
  padding: 0 var(--space-8);
  height: 52px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
}

/* Primary — Pink→Burgundy gradient with flutter on hover.
   The background is oversized (200% wide) and parked at 0% so the
   pink end reads at rest. On hover, we slide the position to 100% —
   the gradient appears to drift/flutter across the button. */
.btn-primary {
  background: var(--gradient-accent-wide);
  background-size: 200% 100%;
  background-position: 0% 50%;
  color: var(--color-white);
  border-color: var(--color-burgundy);
  transition:
    background-position var(--dur-crawl) var(--ease-flutter),
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast);
}
.btn-primary:hover {
  background-position: 100% 50%;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--color-burgundy), transparent 65%);
}
@media (prefers-reduced-motion: reduce) {
  .btn-primary {
    transition:
      transform var(--transition-fast),
      box-shadow var(--transition-fast);
  }
  .btn-primary:hover {
    background-position: 0% 50%;
  }
}

/* Secondary — Amber outline */
.btn-secondary {
  background: transparent;
  color: var(--color-orange);
  border-color: var(--color-orange);
}
.btn-secondary:hover {
  background: var(--color-orange);
  color: var(--color-white);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--color-amber), transparent 65%);
}

/* Ghost — White outline (for dark backgrounds) */
.btn-ghost {
  background: var(--color-white);
  color: var(--color-pink);
  border-color: var(--color-white);
}
.btn-ghost:hover {
  background: transparent;
  color: var(--color-white);
  transform: translateY(-2px);
}

/* Small variant */
.btn-sm {
  height: 40px;
  padding: 0 var(--space-5);
  font-size: var(--text-sm);
}

/* Text link CTA */
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
  color: var(--color-pink);
  transition:
    gap var(--transition-fast),
    opacity var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
  height: auto;
}
.btn-text:hover {
  gap: var(--space-3);
  opacity: 0.85;
}

/* ============================================================
   6. CARDS
   ============================================================ */

/* Type 1 — Flat Material (default) */
.card-flat {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}
.card-flat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Type 2 — Minimal Elevated / Neutral Bordered */
.card-elevated {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}
.card-elevated:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Type 3 — Light Premium Hybrid (warmed to cream for editorial register) */
.card-premium {
  background: linear-gradient(135deg, var(--color-white) 0%, var(--color-cream) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}
.card-premium:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Dark card (for navy sections) */
.card-dark {
  background: var(--color-navy-light);
  border: 1px solid color-mix(in oklch, var(--color-white), transparent 92%);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  transition:
    background var(--transition-fast),
    transform var(--transition-fast);
}
.card-dark:hover {
  background: #003366; /* intentional: darker navy, no design token for this depth */
  transform: translateY(-6px);
}

/* ============================================================
   7. BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  line-height: var(--lh-relaxed);
}

.badge-orange {
  background: var(--color-orange);
  color: var(--color-white);
}

.badge-pink {
  background: var(--color-pink);
  color: var(--color-white);
}

.badge-navy {
  background: var(--color-navy);
  color: var(--color-white);
}

.badge-ice {
  background: var(--color-cream); /* cream replaces ice for flat fills */
  color: var(--color-navy);
}

/* ============================================================
   8. SECTION HEADERS (Reusable pattern)
   ============================================================ */

.section-header {
  margin-block-end: var(--space-16);
}

.section-header--center {
  text-align: center;
  max-inline-size: 640px;
  margin-inline: auto;
  margin-block-end: var(--space-16);
}

.section-header .overline {
  display: block;
  margin-block-end: var(--space-3);
}

.section-header h2 {
  margin-block-end: var(--space-4);
}

.section-header .text-lead {
  margin-block-start: var(--space-3);
}

/* ============================================================
   9. SCROLL REVEAL (initial state — JS adds .revealed)
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--dur-crawl) var(--ease-out-quart),
    transform var(--dur-crawl) var(--ease-out-quart);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 {
  transition-delay: 100ms;
}
.reveal-delay-2 {
  transition-delay: 200ms;
}
.reveal-delay-3 {
  transition-delay: 300ms;
}
.reveal-delay-4 {
  transition-delay: 400ms;
}
.reveal-delay-5 {
  transition-delay: 500ms;
}

/* ============================================================
   10. RESPONSIVE BREAKPOINTS (mobile-first)
   ============================================================ */

/* Ω approved breakpoints only: 280, 360, 390, 430, 768, 1024, 1366, 1440, 1920, 2560, 3840 */
/* phone-l : ≤430px  (Redmi Note, Indian mass-market — Critical) */
/* tablet  : ≤768px  */
/* laptop-s: ≤1024px */
/* laptop-m: ≤1366px (Indian budget laptop — Critical) */
/* desktop : ≤1440px+ */

@media (max-width: 1024px) {
  :root {
    --section-padding: 5rem;
  }
  h1 {
    font-size: var(--text-6xl);
  }
  h2 {
    font-size: var(--text-4xl);
  }
}

@media (max-width: 768px) {
  :root {
    --section-padding: 3.5rem;
  }
  h1 {
    font-size: var(--text-4xl);
  }
  h2 {
    font-size: var(--text-3xl);
  }
  .btn {
    height: 48px;
  }
}

@media (max-width: 430px) {
  :root {
    --section-padding: 2.5rem;
  }
  h1 {
    font-size: 2.25rem;
  }
  h2 {
    font-size: 1.75rem;
  }
  .container {
    padding: 0 var(--space-4);
  }
}

/* Shared flutter keyframe — used by CTA banners and MI-style flags */
@keyframes mi-flag-flutter {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}
