/* ═══════════════════════════════════════════════════════
   Norbis Design System — Base Layer
   2026 CSS Best Practices: @layer, container queries,
   view transitions, scroll-driven animations
   ═══════════════════════════════════════════════════════ */

@layer reset, tokens, base, layout, components, utilities;

/* ── RESET ── */
@layer reset {
  *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
  html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-optical-sizing: auto;
    hanging-punctuation: first last;
  }
  img { max-width: 100%; display: block; }
  a { color: inherit; text-decoration: none; }
  button { font-family: inherit; cursor: pointer; }
  input, textarea, select { font-family: inherit; }
}

/* ── DESIGN TOKENS ── */
@layer tokens {
  :root {
    /* Colors */
    --purple: #764ba2;
    --blue: #667eea;
    --purple-mid: #8a5bb8;
    --text: #1a1033;
    --muted: #6b5e8a;
    --dim: #9e92b8;
    --border: rgba(118,75,162,0.1);
    --bg: #fafafa;
    --white: #ffffff;
    --green: #16a34a;
    --green-light: #dcfce7;
    --red: #dc2626;
    --red-light: #fee2e2;
    --whatsapp: #25D366;

    /* Typography */
    --font-display: 'Instrument Serif', 'Georgia', 'Times New Roman', serif;
    --font-body: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;

    /* Fluid Type Scale — Major Third 1.25 */
    --text-xs: clamp(0.6875rem, 0.625rem + 0.2vw, 0.75rem);
    --text-sm: clamp(0.8125rem, 0.775rem + 0.15vw, 0.875rem);
    --text-base: clamp(0.875rem, 0.825rem + 0.2vw, 0.9375rem);
    --text-lg: clamp(1rem, 0.925rem + 0.3vw, 1.0625rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
    --text-3xl: clamp(2rem, 1.5rem + 2vw, 3rem);
    --text-4xl: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);
    --text-5xl: clamp(2.75rem, 1.75rem + 4vw, 4.25rem);

    /* Line Heights */
    --leading-tight: 1.18;
    --leading-display: 1.22;
    --leading-snug: 1.25;
    --leading-normal: 1.6;
    --leading-relaxed: 1.75;
    --leading-loose: 1.85;

    /* Letter Spacing */
    --tracking-tighter: -0.03em;
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;
    --tracking-wider: 0.1em;
    --tracking-widest: 0.15em;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --space-2xl: 64px;
    --space-3xl: 100px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(118,75,162,0.06);
    --shadow-md: 0 4px 16px rgba(118,75,162,0.08);
    --shadow-lg: 0 12px 40px rgba(118,75,162,0.1);
    --shadow-xl: 0 20px 64px rgba(118,75,162,0.12);

    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 22px;
    --radius-full: 100px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 0.2s;
    --duration-normal: 0.35s;
    --duration-slow: 0.7s;
  }
}

/* ── BASE ── */
@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: var(--leading-display);
    text-wrap: balance;
  }

  h5, h6 {
    font-family: var(--font-body);
    font-weight: 600;
    line-height: var(--leading-snug);
  }

  p {
    text-wrap: pretty;
  }

  ::selection {
    background: rgba(118,75,162,0.15);
    color: var(--text);
  }

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

/* ── VIEW TRANSITIONS (2026 native) ── */
@view-transition {
  navigation: auto;
}

/* ── SCROLL PROGRESS BAR ── */
@layer utilities {
  .scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 9999;
    background: transparent;
    pointer-events: none;
  }
  .scroll-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--purple));
    width: 0%;
    transition: width 0.1s linear;
  }
}
