/* ==========================================================================
   JRufer / VoxCtrl — Shared Design System
   Loaded on every page (root + /voxctrl) BEFORE the page-specific stylesheet.
   Cascade layers keep this foundation cheap to override per-page.
   ========================================================================== */

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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   Tokens
   Tier 1 (literal) colors are inherited from css/style.css today; this file
   only adds Tier 2 semantic tokens that both pages share.
   -------------------------------------------------------------------------- */
@layer tokens {
  :root {
    color-scheme: dark;

    /* Semantic pairing: cyan = the product/signal, amber = the person/human */
    --accent-signal: var(--cyan-400, #22d3ee);
    --accent-signal-glow: var(--cyan-glow, rgba(34, 211, 238, 0.25));
    --accent-human: var(--amber-400, #fbbf24);
    --accent-human-glow: var(--amber-glow, rgba(245, 158, 11, 0.25));

    /* Motion durations (reuse existing transition tokens as the source) */
    --motion-fast: var(--transition-fast, 0.15s cubic-bezier(0.4, 0, 0.2, 1));
    --motion-normal: var(--transition-normal, 0.25s cubic-bezier(0.4, 0, 0.2, 1));
    --motion-slow: var(--transition-slow, 0.4s cubic-bezier(0.4, 0, 0.2, 1));
    --reveal-distance: 16px;

    /* Reduced-motion escape hatch (see utilities layer below) */
    --reveal-anim: reveal-in;
  }

  /* DO NOT set animation-duration:0.01ms globally — swap the animation itself
     per the modern-web-guidance accessibility guidance, one property. */
  @property --reveal-anim {
    syntax: "*";
    inherits: true;
    initial-value: reveal-in;
  }

  @media (prefers-reduced-motion: reduce) {
    :root {
      --reveal-anim: none;
    }
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
@layer base {
  :where(html) {
    scrollbar-color: var(--accent-signal-glow) transparent;
  }

  :where(a, button) {
    transition: color var(--motion-fast), border-color var(--motion-fast),
      box-shadow var(--motion-fast), background-color var(--motion-fast);
  }

  :where(a:focus-visible, button:focus-visible, [tabindex]:focus-visible) {
    outline: 2px solid var(--accent-signal);
    outline-offset: 2px;
  }
}

/* --------------------------------------------------------------------------
   Components
   -------------------------------------------------------------------------- */
@layer components {
  /* Shared site nav — sits above any page-specific nav styling in style.css */
  .site-nav {
    position: sticky;
    inset-block-start: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding-inline: clamp(1rem, 4vw, 2.5rem);
    padding-block: 0.9rem;
    background: color-mix(in oklab, var(--bg-primary, #080b11) 88%, transparent);
    backdrop-filter: blur(16px) saturate(140%);
    border-block-end: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.07));
  }

  .site-nav__brand {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .site-nav__links {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2vw, 1.75rem);
    list-style: none;
  }

  .site-nav__links a {
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
    font-size: 0.9rem;
  }

  .site-nav__links a:hover,
  .site-nav__links a[aria-current="page"] {
    color: var(--text-primary, #f1f5f9);
  }

  /* Glass card — the recurring surface treatment for both pages */
  .card-glass {
    background: var(--bg-card, rgba(14, 20, 32, 0.75));
    border: 1px solid var(--border-card, rgba(56, 189, 248, 0.12));
    border-radius: var(--radius-lg, 16px);
    backdrop-filter: blur(12px);
  }
}

/* --------------------------------------------------------------------------
   Utilities — motion
   -------------------------------------------------------------------------- */
@layer utilities {
  /* Ambient looping media (hero waveform, overlay previews). Always inert
     for users who prefer reduced motion. */
  .ambient-loop {
    opacity: 0.5;
  }

  @media (prefers-reduced-motion: reduce) {
    .ambient-loop {
      display: none;
    }
  }

  /* Scroll-triggered entry: fade + rise as a section comes into view.
     Native implementation via CSS scroll-driven animations, gated behind
     feature detection; falls back to a plain fade handled by reveal.js
     (IntersectionObserver) for browsers without animation-timeline support. */
  @keyframes reveal-in {
    from {
      opacity: 0;
      translate: 0 var(--reveal-distance);
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    @supports ((animation-timeline: view()) and (animation-range: entry)) {
      .reveal {
        animation: var(--reveal-anim) 1s linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 40%;
      }
    }
  }

  /* JS fallback target state (see js/reveal.js) for browsers without
     scroll-driven animation support. */
  @supports not ((animation-timeline: view()) and (animation-range: entry)) {
    @media (prefers-reduced-motion: no-preference) {
      .reveal {
        opacity: 0;
        translate: 0 var(--reveal-distance);
        transition: opacity var(--motion-slow), translate var(--motion-slow);
      }

      .reveal.is-visible {
        opacity: 1;
        translate: 0 0;
      }
    }
  }

  /* Hover = "listening" — a glow response instead of a transform/scale,
     used on cards, buttons, and nav links across both pages. */
  .glow-hover {
    transition: box-shadow var(--motion-normal), border-color var(--motion-normal);
  }

  .glow-hover:hover,
  .glow-hover:focus-visible {
    border-color: var(--border-active, rgba(34, 211, 238, 0.5));
    box-shadow: var(--shadow-glow-cyan, 0 0 30px rgba(6, 182, 212, 0.25));
  }
}
