/* ============================================================================
 * nfk-core.css — NFK Render unified design system (F1 / Pilar A).
 * ONE source of truth for tokens + base + chrome + core components, shared by
 * the public site AND the dashboard (dash.css tokens become a subset of these).
 *
 * Backward-compatible: keeps every var name from the old static/nfk-ui.css
 * (--bg-*, --text-*, --accent-*, --success/--danger/--border, --font-family)
 * so linking this file is a DROP-IN — pages that already use those vars keep
 * working. Adds the layout/type/space/radius/shadow tokens that were previously
 * duplicated inline per page, the unified .nfk-header chrome, and core
 * components (button/card/form/badge). a11y: AA-contrast text, :focus-visible,
 * reduced-motion. Replaces ~4.3k lines of duplicated inline CSS as pages migrate.
 * ========================================================================== */

/* ---- TOKENS: dark (default) ---- */
:root, [data-theme="dark"] {
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-tertiary: #1A1A1A;
  --bg-elevated: #1E1E1E;
  --text-primary: #FFFFFF;
  --text-secondary: #A6ADBB;   /* cool gray, AA ~7:1 (LOKAL T-0102); was #888 */
  --text-tertiary: #8B919E;    /* cool gray, AA ~5:1 (LOKAL); was #555 (FAILED AA ~2.7:1) */
  --accent-1: #6C5CE7;         /* brand purple — fills/borders */
  --accent-1-text: #A99CF5;    /* AA-safe purple for links/text on dark */
  --accent-2: #FF6B35;         /* brand orange — CTA */
  --accent-3: #00D2FF;         /* brand cyan — tech accent */
  --success: #00E676;
  --danger: #FF4757;
  --warning: #FFB020;
  --border: #222222;
  --border-strong: #333333;
  --overlay: rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---- TOKENS: light ---- */
[data-theme="light"] {
  --bg-primary: #F5F6FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EEEEEE;
  --bg-elevated: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #565F6B;   /* cool gray, AA ~7:1 (LOKAL T-0102); was #666 */
  --text-tertiary: #6B7280;    /* cool gray, AA ~4.9:1 (LOKAL); was #999 (FAILED AA ~2.6:1) */
  --accent-1: #5B4AE0;
  --accent-1-text: #4A39C9;    /* AA-safe purple for links on light */
  --accent-2: #E25420;         /* AA-safe orange-for-text on light; bg use keeps #FF6B35 */
  --accent-3: #0099CC;
  --success: #00A152;
  --danger: #E03444;
  --warning: #B26A00;
  --border: #E0E0E0;
  --border-strong: #CFCFCF;
  --overlay: rgba(0,0,0,.4);
  color-scheme: light;
}

/* ---- PLAYFUL accent VARIANT (F1 decision B: "one system, two moods") ----
 * games/english keep their vibrant energy but DERIVED from core. Add class="theme-play"
 * on the page <body> (or a section) to remap the brand accents; structure/tokens stay core. */
:root { --accent-play-1: #7C3AED; --accent-play-2: #E040A0; --accent-play-3: #60A5FA;
  --grad-play: linear-gradient(135deg, var(--accent-play-1), var(--accent-play-2)); }
.theme-play { --accent-1: var(--accent-play-1); --accent-1-text: #B79BFF; --accent-2: var(--accent-play-2); --accent-3: var(--accent-play-3); }

/* ---- TOKENS: non-color (single source; were inline-per-page) ---- */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Courier New', monospace;
  --font-family: var(--font-sans);  /* legacy alias (old pages reference --font-family) */

  --fs-xs: .75rem;  --fs-sm: .875rem;  --fs-base: 1rem;  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem; --fs-2xl: 1.5rem;  --fs-3xl: 2rem;   --fs-4xl: 2.75rem; --fs-5xl: 3.5rem;
  --fw-normal: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700; --fw-black: 800;
  --lh-tight: 1.15; --lh-snug: 1.35; --lh-normal: 1.6;

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-8: 3rem; --space-10: 4rem; --space-12: 6rem;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.18);
  --shadow-md: 0 6px 20px rgba(0,0,0,.22);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.30);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent-1) 55%, transparent);

  --header-height: 68px;
  --container-max: 1200px;
  --section-pad-y: clamp(3rem, 7vw, 6rem);
  --gap: clamp(1rem, 3vw, 2rem);

  --ease-out: cubic-bezier(.4, 0, .2, 1);                  /* motion easing (LOKAL T-0107 FIX-3) */
  --dur-fast: .15s; --dur-base: .25s; --dur-slow: .4s;     /* motion duration scale */
  --t-fast: var(--dur-fast) var(--ease-out); --t-base: var(--dur-base) var(--ease-out); --t-slow: var(--dur-slow) var(--ease-out);  /* composed aliases (back-compat; timings identical) */
  --z-header: 100; --z-dropdown: 200; --z-modal: 1000;
}

/* ---- RESET / BASE ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
a { color: var(--accent-1-text); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--text-primary); }  /* AA-safe hover (was orange --accent-2: light #E25420=3.80 fail); text-primary=max contrast + clear feedback (LOKAL T-0107 FIX-2) */
h1,h2,h3,h4 { line-height: var(--lh-tight); font-weight: var(--fw-bold); }
h1 { font-size: var(--fs-5xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-xl); }
:where(input,button,textarea,select) { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- LAYOUT ---- */
.nfk-container { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: var(--space-5); }
.nfk-section { padding-block: var(--section-pad-y); }
.nfk-grid { display: grid; gap: var(--gap); }
.nfk-grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---- CHROME: shared header / nav (canonical .nfk-header markup) ---- */
.nfk-header {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--space-5);
  height: var(--header-height); padding-inline: var(--space-5);
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-logo a { color: var(--text-primary); font-weight: var(--fw-black); font-size: var(--fs-xl); letter-spacing: -.02em; }
.header-logo .accent { color: var(--accent-2); }
.header-nav { display: flex; align-items: center; gap: var(--space-5); margin-inline-start: auto; }
.header-nav > a { color: var(--text-secondary); font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.header-nav > a:hover, .header-nav > a[aria-current="page"] { color: var(--text-primary); }
.nav-more { position: relative; }
.nav-more-dropdown {
  position: absolute; top: 130%; right: 0; min-width: 180px; display: none; flex-direction: column;
  padding: var(--space-2); background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: var(--z-dropdown);
}
.nav-more-dropdown a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--text-secondary); }
.nav-more-dropdown a:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-more[aria-expanded="true"] .nav-more-dropdown, .nav-more.open .nav-more-dropdown { display: flex; }
.hamburger { display: none; flex-direction: column; gap: 5px; width: 40px; height: 40px; padding: 9px 8px; background: none; border: 0; cursor: pointer; }
.hamburger span { height: 2px; background: var(--text-primary); border-radius: 2px; transition: transform var(--t-base), opacity var(--t-base); }
@media (max-width: 860px) {
  .hamburger { display: flex; margin-inline-start: auto; position: relative; z-index: 2; }
  .nfk-header > .btn-contact { display: none; }
  .header-nav {
    position: fixed; inset: var(--header-height) 0 auto 0; flex-direction: column; align-items: stretch;
    gap: 0; padding: var(--space-3); margin: 0; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    transform: translateY(-120%); transition: transform var(--t-slow); box-shadow: var(--shadow-lg);
    pointer-events: none;
  }
  .nfk-header.open .header-nav { transform: translateY(0); pointer-events: auto; }
  .header-nav > a { padding: var(--space-3); border-radius: var(--radius-sm); }
  .nav-more-dropdown { position: static; display: flex; box-shadow: none; border: 0; background: transparent; padding-inline: var(--space-4); }
}

/* ---- COMPONENTS: button ---- */
.nfk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); border: 1px solid transparent;
  font-weight: var(--fw-semibold); font-size: var(--fs-sm); line-height: 1; cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast); white-space: nowrap;
}
.nfk-btn:active { transform: translateY(1px); }
.nfk-btn--primary { background: var(--accent-1); color: #fff; }
.nfk-btn--primary:hover { background: color-mix(in srgb, var(--accent-1) 88%, #000); color: #fff; }  /* darken-on-hover: AA-safe w/ white text (lighten->white dropped to ~3.7) */
.nfk-btn--cta, .btn-contact { background: var(--accent-1); color: #fff; border-radius: var(--radius-full); padding: var(--space-3) var(--space-5); font-weight: var(--fw-semibold); }  /* CTA = brand purple (AA 4.86 white-on-#6C5CE7); orange demoted to illustrative per blueprint (LOKAL T-0107 FIX-1) */
.nfk-btn--cta:hover, .btn-contact:hover { background: color-mix(in srgb, var(--accent-1) 88%, #000); color: #fff; }  /* darken-on-hover keeps AA (~5.96) */
.nfk-btn--ghost { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.nfk-btn--ghost:hover { background: var(--bg-tertiary); }
.nfk-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- COMPONENTS: card ---- */
.nfk-card {
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); transition: transform var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
}
.nfk-card--hover:hover { transform: translateY(-4px); border-color: var(--accent-1); box-shadow: var(--shadow-md); }

/* ---- COMPONENTS: form ---- */
.nfk-label { display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-secondary); margin-bottom: var(--space-2); }
.nfk-input, .nfk-textarea, .nfk-select {
  width: 100%; padding: var(--space-3) var(--space-4); background: var(--bg-tertiary);
  color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.nfk-input::placeholder, .nfk-textarea::placeholder { color: var(--text-tertiary); }
.nfk-input:focus, .nfk-textarea:focus, .nfk-select:focus { border-color: var(--accent-1); box-shadow: var(--ring); outline: none; }

/* ---- COMPONENTS: badge ---- */
.nfk-badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-semibold); background: var(--bg-tertiary); color: var(--text-secondary); }
.nfk-badge--success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.nfk-badge--danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

/* ---- a11y utilities ---- */
.sr-only { position: absolute !important; 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; left: -999px; top: 0; z-index: var(--z-modal); padding: var(--space-3) var(--space-4); background: var(--accent-1); color: #fff; border-radius: 0 0 var(--radius-md) 0; }
.skip-link:focus { left: 0; }

/* ---- SVG icon convention: <svg class="nfk-icon"><use href="#i-name"/></svg> ----
 * Sprite lives in partials/icons.svg (F1/A3); replaces emoji-as-icon (a11y). */
.nfk-icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; flex: none; }
