/* ============================================================================
   IMRF — Design System  ·  v1.0
   ----------------------------------------------------------------------------
   Premium corporate awards & recognition theme.
   Royal navy · deep corporate blue · white · elegant orange/gold accents.

   This file defines ONLY tokens + primitives (typography, buttons, cards,
   badges, forms, section scaffolding, motion). Page-specific layout lives in
   frontend.css (Phase 2) and admin.css (Phase 3), both built on these tokens.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   1 · FONTS
   Inter (English UI) · Manrope (display headings)
   Noto Sans Telugu · Noto Sans Devanagari
   Loaded via Google Fonts in header.php with font-display: swap.
--------------------------------------------------------------------------- */

:root {
  /* ------- Brand palette ------- */
  --navy-950: #071539;   /* darkest — footer, admin sidebar */
  --navy-900: #0B1F4B;   /* royal navy — primary dark surface */
  --navy-800: #122A66;
  --navy-700: #1E3A8A;   /* deep corporate blue — primary */
  --navy-600: #2547A8;
  --navy-500: #2E56C5;
  --navy-100: #DCE4F7;
  --navy-50:  #EEF2FC;

  --orange-600: #EA580C; /* elegant orange — primary CTA */
  --orange-500: #F97316;
  --orange-100: #FFEDD5;

  --gold-600: #B45309;   /* restrained gold — highest honour accents */
  --gold-500: #D97706;
  --gold-100: #FDF3E3;

  --green-600: #16A34A;  /* minimal green — success / verified only */
  --green-100: #DCFCE7;

  --red-600: #DC2626;    /* errors only */
  --red-100: #FEE2E2;

  /* ------- Neutrals ------- */
  --ink-900: #0F172A;    /* headings */
  --ink-700: #334155;    /* body */
  --ink-500: #64748B;    /* secondary text */
  --ink-300: #CBD5E1;    /* borders */
  --ink-100: #F1F5F9;    /* subtle fill */
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;

  /* ------- Semantic aliases ------- */
  --color-primary: var(--navy-700);
  --color-primary-dark: var(--navy-900);
  --color-accent: var(--orange-600);
  --color-accent-hover: #C2410C;
  --color-success: var(--green-600);
  --color-danger: var(--red-600);

  /* ------- Typography ------- */
  --font-body: 'Anek Latin', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Anek Latin', 'Manrope', 'Inter', system-ui, sans-serif;
  --font-telugu: 'Anek Telugu', 'Noto Sans Telugu', 'Inter', sans-serif;
  --font-hindi: 'Anek Devanagari', 'Noto Sans Devanagari', 'Inter', sans-serif;

  /* Fluid type scale (min @360px → max @1440px) */
  --text-xs:   clamp(0.75rem, 0.72rem + 0.10vw, 0.8125rem);
  --text-sm:   clamp(0.875rem, 0.85rem + 0.10vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.15vw, 1.0625rem);
  --text-lg:   clamp(1.125rem, 1.05rem + 0.30vw, 1.25rem);
  --text-xl:   clamp(1.25rem, 1.15rem + 0.45vw, 1.5rem);
  --text-2xl:  clamp(1.5rem, 1.32rem + 0.80vw, 1.9375rem);
  --text-3xl:  clamp(1.875rem, 1.60rem + 1.20vw, 2.5rem);
  --text-4xl:  clamp(2.25rem, 1.85rem + 1.80vw, 3.25rem);
  --text-hero: clamp(2.5rem, 1.95rem + 2.45vw, 4rem);

  /* ------- Spacing (8pt grid) ------- */
  --space-1: 0.25rem;  --space-2: 0.5rem;   --space-3: 0.75rem;
  --space-4: 1rem;     --space-5: 1.5rem;   --space-6: 2rem;
  --space-7: 3rem;     --space-8: 4rem;     --space-9: 6rem;
  --section-y: clamp(3.5rem, 2.5rem + 4vw, 6.5rem);

  /* ------- Radii ------- */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* ------- Shadows (soft, premium) ------- */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 18px 44px rgba(11, 31, 75, 0.14);
  --shadow-navy: 0 12px 32px rgba(11, 31, 75, 0.22);
  --shadow-accent: 0 10px 26px rgba(234, 88, 12, 0.30);

  /* ------- Motion ------- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 160ms;
  --dur-med: 280ms;
  --dur-slow: 480ms;

  /* ------- Layout ------- */
  --container-max: 1240px;
  --container-wide: 1400px;
  --header-height: 76px;
  --topbar-height: 38px;
}

/* ---------------------------------------------------------------------------
   2 · RESET + BASE
--------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--ink-700);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Language-aware font stacks — applied via body class by Language::fontClass() */
body.lang-te { font-family: var(--font-telugu); line-height: 1.85; }
body.lang-hi { font-family: var(--font-hindi); line-height: 1.8; }
body.lang-te h1, body.lang-te h2, body.lang-te h3,
body.lang-te h4, body.lang-te h5 { font-family: var(--font-telugu); }
body.lang-hi h1, body.lang-hi h2, body.lang-hi h3,
body.lang-hi h4, body.lang-hi h5 { font-family: var(--font-hindi); }

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

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  color: var(--ink-900);
  line-height: 1.2;
  margin: 0 0 var(--space-4);
  font-weight: 700;
  letter-spacing: -0.015em;
}

h1 { font-size: var(--text-4xl); font-weight: 800; }
h2 { font-size: var(--text-3xl); font-weight: 800; }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

a { color: var(--color-primary); text-decoration: none; transition: color var(--dur-fast) ease; }
a:hover { color: var(--color-accent); }

:focus-visible {
  outline: 3px solid var(--orange-500);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--navy-700); color: #fff; }

/* ---------------------------------------------------------------------------
   3 · LAYOUT PRIMITIVES
--------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}
.container--wide { max-width: var(--container-wide); }

.section { padding-block: var(--section-y); }
.section--alt { background: var(--surface-alt); }
.section--navy { background: var(--navy-900); color: #C7D2E8; }
.section--navy h2, .section--navy h3 { color: #fff; }

/* Section header pattern: eyebrow → title → lede */
.section-head { max-width: 720px; margin-inline: auto; text-align: center; margin-bottom: var(--space-7); }
.section-head--left { margin-inline: 0; text-align: left; }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--color-accent);
  background: var(--orange-100); border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem; margin-bottom: var(--space-4);
}
.section--navy .eyebrow { background: rgba(249, 115, 22, 0.15); color: var(--orange-500); }
.lede { font-size: var(--text-lg); color: var(--ink-500); }
.section--navy .lede { color: #9FB0D4; }

/* Responsive auto-grids */
.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }

/* ---------------------------------------------------------------------------
   4 · BUTTONS
--------------------------------------------------------------------------- */

.btn {
  --btn-bg: var(--color-primary);
  --btn-color: #fff;
  --btn-shadow: var(--shadow-navy);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1.7rem;
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600;
  color: var(--btn-color); background: var(--btn-bg);
  border: 2px solid transparent; border-radius: var(--radius-pill);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--btn-shadow); color: var(--btn-color); }
.btn:active { transform: translateY(0); }

.btn .btn-arrow { transition: transform var(--dur-fast) var(--ease-out); }
.btn:hover .btn-arrow { transform: translateX(4px); }

.btn--accent { --btn-bg: var(--color-accent); --btn-shadow: var(--shadow-accent); }
.btn--accent:hover { background: var(--color-accent-hover); }

.btn--outline {
  --btn-bg: transparent; --btn-color: var(--color-primary);
  border-color: currentColor; --btn-shadow: var(--shadow-sm);
}
.btn--outline:hover { background: var(--navy-50); }

.btn--ghost-light {
  --btn-bg: rgba(255, 255, 255, 0.1); --btn-color: #fff;
  border-color: rgba(255, 255, 255, 0.4); backdrop-filter: blur(4px);
  --btn-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}
.btn--ghost-light:hover { background: rgba(255, 255, 255, 0.2); }

.btn--lg { padding: 1rem 2.2rem; font-size: var(--text-base); }
.btn--sm { padding: 0.5rem 1.1rem; font-size: var(--text-xs); }

.btn:disabled, .btn.is-disabled {
  opacity: 0.55; pointer-events: none; transform: none; box-shadow: none;
}

/* Loading state: <button class="btn is-loading"> */
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 1.1em; height: 1.1em;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  border-radius: 50%; animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Success state after form submit */
.btn.is-success { --btn-bg: var(--color-success); }

/* ---------------------------------------------------------------------------
   5 · CARDS
--------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  transition: transform var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out),
              border-color var(--dur-med) ease;
}
.card--hover:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--navy-100);
}

/* Recognition circle card — accent set inline: style="--circle-accent:#B45309" */
.card--circle {
  --circle-accent: var(--navy-700);
  position: relative; overflow: hidden;
  border-top: 4px solid var(--circle-accent);
}
.card--circle .circle-icon {
  width: 56px; height: 56px; display: grid; place-items: center;
  font-size: 1.5rem; color: var(--circle-accent);
  background: color-mix(in srgb, var(--circle-accent) 10%, white);
  border-radius: var(--radius-md); margin-bottom: var(--space-4);
}
.card--circle .circle-level {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-500);
}
.card--circle .circle-name { color: var(--circle-accent); }

/* Icon feature card (trust highlights, benefits) */
.card--feature { text-align: left; }
.card--feature .feature-icon {
  width: 52px; height: 52px; display: grid; place-items: center;
  font-size: 1.4rem; color: var(--color-primary);
  background: var(--navy-50); border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

/* ---------------------------------------------------------------------------
   6 · BADGES & STATUS  (never rely on color alone — always include text)
--------------------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--text-xs); font-weight: 600;
  padding: 0.3rem 0.75rem; border-radius: var(--radius-pill);
  background: var(--ink-100); color: var(--ink-700);
}
.badge--navy    { background: var(--navy-50);   color: var(--navy-700); }
.badge--accent  { background: var(--orange-100); color: var(--orange-600); }
.badge--gold    { background: var(--gold-100);  color: var(--gold-600); }
.badge--success { background: var(--green-100); color: var(--green-600); }
.badge--danger  { background: var(--red-100);   color: var(--red-600); }

/* ---------------------------------------------------------------------------
   7 · FORMS
--------------------------------------------------------------------------- */

.form-group { margin-bottom: var(--space-5); }

.form-label {
  display: block; font-size: var(--text-sm); font-weight: 600;
  color: var(--ink-900); margin-bottom: var(--space-2);
}
.form-label .required { color: var(--red-600); margin-left: 2px; }

.form-control {
  width: 100%; padding: 0.75rem 1rem;
  font-family: inherit; font-size: var(--text-base); color: var(--ink-900);
  background: var(--surface); border: 1.5px solid var(--ink-300);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.form-control:focus {
  outline: none; border-color: var(--navy-500);
  box-shadow: 0 0 0 4px rgba(46, 86, 197, 0.12);
}
.form-control.is-invalid { border-color: var(--red-600); }
.form-error {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: var(--text-xs); color: var(--red-600); margin-top: var(--space-1);
}
.form-hint { font-size: var(--text-xs); color: var(--ink-500); margin-top: var(--space-1); }

textarea.form-control { min-height: 140px; resize: vertical; }

/* ---------------------------------------------------------------------------
   8 · MOTION — reveal-on-scroll (Intersection Observer adds .is-visible)
--------------------------------------------------------------------------- */

/* Hidden state applies ONLY when JS is running (html.js set in header) —
   without JS every section stays fully visible (progressive enhancement). */
.js .reveal { opacity: 0; transform: translateY(24px);
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out); }
.js .reveal.is-visible { opacity: 1; transform: none; }
.js .reveal[data-delay="1"] { transition-delay: 90ms; }
.js .reveal[data-delay="2"] { transition-delay: 180ms; }
.js .reveal[data-delay="3"] { transition-delay: 270ms; }

/* Counter numbers (statistics) */
.stat-number {
  font-family: var(--font-display); font-size: var(--text-4xl);
  font-weight: 800; color: var(--color-primary); line-height: 1;
}
.section--navy .stat-number { color: #fff; }

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------------
   9 · UTILITIES
--------------------------------------------------------------------------- */

.text-center { text-align: center; }
.text-accent { color: var(--color-accent); }
.text-muted { color: var(--ink-500); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute; top: -48px; left: var(--space-4); z-index: 1000;
  background: var(--navy-900); color: #fff; padding: 0.6rem 1.2rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: top var(--dur-fast) ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* --- English (Anek Latin) — optical size tuning -------------------------
   Anek Latin same px lo Inter kanna konchem chinna ga kanipistundi, so
   English lo type scale ni ~6% penchi, line-height open chesam.
   Telugu/Hindi tokens maaravu — vaatiki own fonts unnayi. */
body.lang-en {
  --text-xs:   clamp(0.80rem, 0.77rem + 0.10vw, 0.86rem);
  --text-sm:   clamp(0.93rem, 0.90rem + 0.11vw, 1.00rem);
  --text-base: clamp(1.06rem, 1.02rem + 0.16vw, 1.13rem);
  --text-lg:   clamp(1.19rem, 1.11rem + 0.32vw, 1.33rem);
  --text-xl:   clamp(1.33rem, 1.22rem + 0.48vw, 1.59rem);
  --text-2xl:  clamp(1.59rem, 1.40rem + 0.85vw, 2.05rem);
  --text-3xl:  clamp(1.99rem, 1.70rem + 1.27vw, 2.65rem);
  --text-4xl:  clamp(2.39rem, 1.96rem + 1.91vw, 3.45rem);
  --text-hero: clamp(2.60rem, 2.03rem + 2.55vw, 4.15rem);
  font-size: var(--text-base);
  line-height: 1.72;
  letter-spacing: 0.004em;
}
body.lang-en h1, body.lang-en h2, body.lang-en h3 { line-height: 1.22; }
body.lang-en .lede, body.lang-en p { line-height: 1.75; }
