/* ════════════════════════════════════════════════════════════════════
 * N2Five — Design Tokens (Phase 1 foundation)
 *
 * Single source of truth for color, spacing, shadow, motion, typography
 * and z-index. Consumed by templates/base.html and
 * templates/website/base_website.html.
 *
 * Subsequent phases (landing, auth, dashboard, polish) reference these
 * tokens; do not redefine values inline.
 * ════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Primary brand (logo-matched) ─────────────────────────────── */
  --blue:     #3B5BD9;          /* cobalt — primary CTA / brand */
  --blue-rgb: 59,91,217;
  --sky:      #7BB7FF;          /* light sky accent (logo pill) */
  --sky-rgb:  123,183,255;
  --navy:     #0D1B3E;          /* near-black text + logo "9" mark */
  --navy2:    #1B2B5E;

  /* ── Supporting accents ───────────────────────────────────────── */
  --violet: #7C3AED;
  --lav:    #A78BFA;
  --pink:   #F0ABFC;
  --mint:   #6EE7B7;
  --gold:   #F59E0B;
  --red:    #EF4444;
  --green:  #22C55E;

  /* ── Neutrals + surface ───────────────────────────────────────── */
  --bg:         #F4F7FF;
  --bg2:        #EEF2FF;
  --surface:    #FFFFFF;
  --white:      #FFFFFF;
  --border:     #E4EAF6;
  --border2:    #CBD5F0;
  --muted:      #6B7CA8;
  --text:       #0D1B3E;
  --text-muted: #6B7CA8;

  /* ── Back-compat aliases (used by existing inline styles) ─────── */
  --brand-blue:        var(--blue);
  --brand-violet:      var(--violet);
  --brand-lav:         var(--lav);
  --brand-blue-rgb:    var(--blue-rgb);
  --brand-violet-rgb:  124,58,237;
  --lavender:          var(--lav);              /* alias used in applications/detail.html */
  --blue-soft:         #6B8EF0;                 /* lighter blue for hover states */
  --surface2:          var(--bg);               /* alt tinted surface */

  /* ── External brand colors (WhatsApp button on public site) ──── */
  --whatsapp:      #25D366;
  --whatsapp-dark: #128C7E;

  /* ── Layout dimensions ───────────────────────────────────────── */
  --sidebar-w: 244px;                            /* portal left-nav width — CRITICAL */

  /* ── Gradients ───────────────────────────────────────────────── */
  --grad-brand:        linear-gradient(135deg, var(--blue), var(--sky));
  --grad-brand-deep:   linear-gradient(135deg, var(--navy), var(--blue));
  --grad-brand-violet: linear-gradient(135deg, var(--blue), var(--violet));
  --grad-brand-3:      linear-gradient(135deg, var(--blue), var(--violet), var(--lav));
  --grad-text:         linear-gradient(135deg, var(--navy), var(--blue));
  --grad-mesh:         radial-gradient(circle at 20% 30%, rgba(123,183,255,.18), transparent 50%),
                       radial-gradient(circle at 80% 70%, rgba(59,91,217,.14), transparent 50%);
  --grad-glass:        linear-gradient(135deg, rgba(255,255,255,.65), rgba(255,255,255,.25));
  --grad-shimmer:      linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);

  /* ── Spacing (4-point grid) ──────────────────────────────────── */
  --sp-0:  0;
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;

  /* ── Radius ──────────────────────────────────────────────────── */
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   22px;
  --r-2xl:  28px;
  --r-pill: 999px;

  /* ── Shadow ──────────────────────────────────────────────────── */
  --shadow-sm:  0 1px 3px rgba(13,27,62,.06), 0 1px 2px rgba(13,27,62,.04);
  --shadow-md:  0 4px 16px rgba(59,91,217,.10), 0 1px 4px rgba(13,27,62,.06);
  --shadow-lg:  0 12px 40px rgba(59,91,217,.14), 0 2px 8px rgba(13,27,62,.06);
  --shadow-xl:  0 24px 64px rgba(59,91,217,.18), 0 4px 16px rgba(13,27,62,.08);
  --shadow-glow-blue:   0 0 32px rgba(59,91,217,.30);
  --shadow-glow-sky:    0 0 28px rgba(123,183,255,.35);
  --shadow-cta:         0 8px 32px rgba(59,91,217,.32), 0 2px 8px rgba(59,91,217,.18);
  --ring-focus:         0 0 0 3px rgba(59,91,217,.18);

  /* ── Motion — durations ──────────────────────────────────────── */
  --dur-instant: 80ms;
  --dur-fast:    150ms;
  --dur-base:    240ms;
  --dur-slow:    450ms;
  --dur-reveal:  700ms;
  --dur-counter: 1600ms;

  /* ── Motion — easings ────────────────────────────────────────── */
  --ease-out:    cubic-bezier(.22,1,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);
  --ease-snap:   cubic-bezier(.18,.89,.32,1.28);

  /* ── Typography ──────────────────────────────────────────────── */
  --font-display: 'Rubik', system-ui, sans-serif;
  --font-sans:    'Inter', system-ui, sans-serif;
  --fs-xs:   .72rem;
  --fs-sm:   .82rem;
  --fs-base: .92rem;
  --fs-lg:   1.05rem;
  --fs-xl:   1.25rem;
  --fs-2xl:  1.55rem;
  --fs-3xl:  2.1rem;
  --fs-4xl:  2.8rem;
  --fs-5xl:  3.6rem;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-black:    800;

  /* ── Z-index ─────────────────────────────────────────────────── */
  --z-base:     1;
  --z-elevated: 10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  800;
  --z-modal:    900;
  --z-toast:    1000;
}

/* ════════════════════════════════════════════════════════════════════
 * Component Primitives
 * ════════════════════════════════════════════════════════════════════ */

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-snap),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: var(--dur-instant); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: var(--fs-base); border-radius: var(--r-lg); }

.btn-primary {
  background: var(--grad-brand);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(var(--blue-rgb), .25);
}
.btn-primary:hover { box-shadow: var(--shadow-cta); }

.btn-secondary {
  background: var(--surface);
  color: var(--blue);
  border-color: var(--border2);
}
.btn-secondary:hover { border-color: var(--blue); box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); background: rgba(var(--blue-rgb), .06); }

.btn-danger {
  background: linear-gradient(135deg, #DC2626, var(--red));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(220, 38, 38, .22);
}
.btn-danger:hover { box-shadow: 0 8px 28px rgba(220, 38, 38, .32); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-pill);
}
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-icon.btn-lg { width: 40px; height: 40px; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card-elevated {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
  padding: var(--sp-5);
}
.card-elevated.hover-lift:hover,
.card-elevated:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-glass {
  background: var(--grad-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.card-feature {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.card-feature::before {
  content: '';
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
  width: 12px;
  height: 12px;
  border-radius: var(--r-xs);
  background: var(--grad-brand);
}
.card-feature:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ── Inputs ────────────────────────────────────────────────────── */
.input,
input.form-input,
select.form-input,
textarea.form-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.input:focus,
input.form-input:focus,
select.form-input:focus,
textarea.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring-focus);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input { padding-left: var(--sp-8); }
.input-group .input-icon-leading {
  position: absolute;
  left: var(--sp-3);
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

/* ── Chips ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border-radius: var(--r-pill);
  background: rgba(var(--blue-rgb), .08);
  color: var(--blue);
  line-height: 1.4;
}
.chip-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: currentColor;
}
.chip-removable button {
  margin-left: var(--sp-1);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 1em;
  line-height: 1;
  opacity: .6;
}
.chip-removable button:hover { opacity: 1; }

.chip-blue   { background: rgba(var(--blue-rgb), .08); color: var(--blue); }
.chip-violet { background: rgba(124, 58, 237, .10);    color: var(--violet); }
.chip-green  { background: rgba(34, 197, 94, .10);     color: #15803d; }
.chip-amber  { background: rgba(245, 158, 11, .12);    color: #B45309; }
.chip-red    { background: rgba(239, 68, 68, .10);     color: #B91C1C; }

/* ── Skeletons ─────────────────────────────────────────────────── */
.skeleton {
  position: relative;
  background: rgba(var(--blue-rgb), .06);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grad-shimmer);
  animation: shimmer 1.5s linear infinite;
}
.skeleton-text   { height: 1em; }
.skeleton-circle { border-radius: var(--r-pill); aspect-ratio: 1; }
.skeleton-card   {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: clamp(16px, 5vw, 32px);
  padding-right: clamp(16px, 5vw, 32px);
}
.section        { padding-top: var(--sp-20); padding-bottom: var(--sp-20); }
.section-tight  { padding-top: var(--sp-12); padding-bottom: var(--sp-12); }
.section-wide   { padding-top: var(--sp-24); padding-bottom: var(--sp-24); }

.divider-fade {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border2), transparent);
  border: 0;
  margin: var(--sp-8) 0;
}

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.5;
  border: 1px solid;
}
.alert-success { background: rgba(34, 197, 94, .08);  border-color: rgba(34, 197, 94, .25);  color: #15803d; }
.alert-error   { background: rgba(239, 68, 68, .07);  border-color: rgba(239, 68, 68, .25);  color: #B91C1C; }
.alert-info    { background: rgba(var(--blue-rgb), .07); border-color: rgba(var(--blue-rgb), .25); color: var(--blue); }
.alert-warning { background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .30); color: #B45309; }

/* ── Tooltip ───────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after,
[data-tooltip]::before {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  margin-bottom: 6px;
  padding: var(--sp-1) var(--sp-2);
  background: var(--navy);
  color: var(--white);
  font-size: var(--fs-xs);
  border-radius: var(--r-xs);
  white-space: nowrap;
}
[data-tooltip]::before {
  content: '';
  margin-bottom: 2px;
  border: 4px solid transparent;
  border-top-color: var(--navy);
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus::after,
[data-tooltip]:focus::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* ════════════════════════════════════════════════════════════════════
 * Animation Utilities
 * Activated either via :hover, JS-added .is-visible class, or
 * direct CSS animation declarations.
 * ════════════════════════════════════════════════════════════════════ */

/* Scroll-reveal (triggered by motion.js IntersectionObserver) */
.reveal-up,
.reveal-left,
.reveal-right {
  opacity: 0;
  transition: opacity var(--dur-reveal) var(--ease-out),
              transform var(--dur-reveal) var(--ease-out);
}
.reveal-up    { transform: translateY(24px); }
.reveal-left  { transform: translateX(-24px); }
.reveal-right { transform: translateX(24px); }
.reveal-up.is-visible,
.reveal-left.is-visible,
.reveal-right.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger children — set --i on each child for delay */
.stagger > * {
  transition-delay: calc(var(--i, 0) * 80ms);
}

/* Hover utilities */
.hover-lift {
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.hover-glow {
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.hover-glow:hover { box-shadow: var(--shadow-glow-blue); }

.hover-magnet {
  transition: transform var(--dur-fast) var(--ease-snap);
}
.hover-magnet:hover { transform: scale(1.02); }

/* Decorative loops */
.float-y    { animation: float-y 4.5s var(--ease-in-out) infinite; }
.shimmer    { animation: shimmer 1.5s linear infinite; }
.ring-pulse { animation: ring-pulse 2s var(--ease-out) infinite; }
.spin-slow  { animation: spin-slow 20s linear infinite; }
.fade-in    { animation: fade-in var(--dur-reveal) var(--ease-out) both; }

/* Gradient text — for big headlines */
.gradient-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ════════════════════════════════════════════════════════════════════
 * Keyframes
 * ════════════════════════════════════════════════════════════════════ */

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes ring-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--blue-rgb), .45); }
  70%  { box-shadow: 0 0 0 12px rgba(var(--blue-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--blue-rgb), 0); }
}

@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ════════════════════════════════════════════════════════════════════
 * Reduced-Motion Override
 * Honors the user's OS-level reduced-motion preference.
 * ════════════════════════════════════════════════════════════════════ */

@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;
  }
  .reveal-up,
  .reveal-left,
  .reveal-right {
    opacity: 1;
    transform: none;
  }
  .float-y,
  .shimmer,
  .ring-pulse,
  .spin-slow {
    animation: none;
  }
}
