/*
 * Rise3 - Your Recovery, Rewarded
 * Modern CSS with @layer, @scope, namespaced custom properties
 * Dark theme with pink/purple gradient accents
 */

/* ============================================
   Layer Order Declaration
   ============================================ */
@layer reset, base, tokens, layout, components, utilities;

/* ============================================
   LAYER: Reset
   ============================================ */
@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

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

  body {
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
  }

  input, button, textarea, select {
    font: inherit;
  }

  p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  ul, ol {
    list-style: none;
  }
}

/* ============================================
   LAYER: Tokens (Namespaced Custom Properties)
   ============================================ */
@layer tokens {
  :root {
    /* --r3 = Rise3 namespace */

    /* Colors - Core */
    --r3-color-surface: #0a0a0f;
    --r3-color-surface-elevated: #18181b;
    --r3-color-surface-muted: #27272a;
    --r3-color-accent: #ec4899;
    --r3-color-accent-dark: #db2777;
    --r3-color-purple: #8b5cf6;
    --r3-color-purple-dark: #7c3aed;
    --r3-color-alert: #ef4444;
    --r3-color-text-primary: #ffffff;
    --r3-color-text-secondary: #e4e4e7;
    --r3-color-text-muted: #71717a;
    --r3-color-border: #27272a;

    /* Glass effect colors */
    --r3-glass-bg: rgba(24, 24, 27, 0.6);
    --r3-glass-border: rgba(236, 72, 153, 0.2);
    --r3-glass-shadow: rgba(0, 0, 0, 0.3);

    /* Typography - Font Families */
    --r3-font-heading: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --r3-font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --r3-font-mono: 'JetBrains Mono', monospace;

    /* Typography - Fluid Sizes (clamp) */
    --r3-text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem);
    --r3-text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.9rem);
    --r3-text-base: clamp(0.95rem, 0.9rem + 0.25vw, 1.1rem);
    --r3-text-lg: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
    --r3-text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.6rem);
    --r3-text-2xl: clamp(1.5rem, 1.25rem + 1.25vw, 2.25rem);
    --r3-text-3xl: clamp(1.9rem, 1.5rem + 2vw, 3rem);
    --r3-text-4xl: clamp(2.5rem, 2rem + 2.5vw, 4rem);
    --r3-text-hero: clamp(3rem, 2.5rem + 3vw, 5.5rem);

    /* Spacing Scale */
    --r3-space-xs: clamp(0.25rem, 0.2rem + 0.25vw, 0.5rem);
    --r3-space-sm: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
    --r3-space-md: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    --r3-space-lg: clamp(1.5rem, 1.25rem + 1.25vw, 2.5rem);
    --r3-space-xl: clamp(2rem, 1.5rem + 2.5vw, 4rem);
    --r3-space-2xl: clamp(3rem, 2rem + 5vw, 6rem);
    --r3-space-section: clamp(4rem, 3rem + 5vw, 8rem);

    /* Border Radius */
    --r3-radius-sm: 0.375rem;
    --r3-radius-md: 0.75rem;
    --r3-radius-lg: 1rem;
    --r3-radius-xl: 1.5rem;
    --r3-radius-full: 9999px;

    /* Transitions */
    --r3-transition-fast: 150ms ease;
    --r3-transition-base: 250ms ease;
    --r3-transition-slow: 400ms ease;

    /* Z-index scale */
    --r3-z-base: 1;
    --r3-z-dropdown: 100;
    --r3-z-sticky: 200;
    --r3-z-fixed: 300;
    --r3-z-modal: 400;
    --r3-z-tooltip: 500;
  }
}

/* ============================================
   LAYER: Base
   ============================================ */
@layer base {
  body {
    font-family: var(--r3-font-body);
    font-size: var(--r3-text-base);
    color: var(--r3-color-text-primary);
    background: var(--r3-color-surface);
    background-image:
      radial-gradient(ellipse at 20% 0%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
    background-attachment: fixed;
    overflow-x: hidden;
  }

  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--r3-font-heading);
    font-weight: 700;
    line-height: 1.2;
    color: var(--r3-color-text-primary);
  }

  h1 { font-size: var(--r3-text-4xl); }
  h2 { font-size: var(--r3-text-3xl); }
  h3 { font-size: var(--r3-text-2xl); }
  h4 { font-size: var(--r3-text-xl); }

  p {
    color: var(--r3-color-text-secondary);
  }

  strong {
    color: var(--r3-color-text-primary);
    font-weight: 600;
  }

  ::selection {
    background: var(--r3-color-accent);
    color: var(--r3-color-surface);
  }
}

/* ============================================
   LAYER: Layout
   ============================================ */
@layer layout {
  .container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--r3-space-md);
  }

  .section {
    padding-block: var(--r3-space-section);
  }

  .grid {
    display: grid;
    gap: var(--r3-space-lg);
  }

  .grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  }

  .grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  }

  .grid--4 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  }

  .flex {
    display: flex;
    gap: var(--r3-space-md);
  }

  .flex--center {
    align-items: center;
    justify-content: center;
  }

  .flex--between {
    align-items: center;
    justify-content: space-between;
  }

  .flex--col {
    flex-direction: column;
  }
}

/* ============================================
   LAYER: Components
   ============================================ */
@layer components {

  /* ----- Glass Card ----- */
  .glass {
    background: var(--r3-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--r3-glass-border);
    border-radius: var(--r3-radius-lg);
    box-shadow:
      0 8px 32px var(--r3-glass-shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all var(--r3-transition-base);
  }

  .glass:hover {
    border-color: rgba(236, 72, 153, 0.3);
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.4),
      0 0 0 1px rgba(236, 72, 153, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  .glass--solid {
    background: var(--r3-color-surface-elevated);
  }

  .glass--accent {
    border-color: var(--r3-color-accent);
    box-shadow:
      0 8px 32px var(--r3-glass-shadow),
      0 0 0 1px rgba(236, 72, 153, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }

  /* ----- Navigation ----- */
  @scope (.nav) {
    :scope {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: var(--r3-z-fixed);
      padding: var(--r3-space-sm) 0;
      transition: background var(--r3-transition-base), box-shadow var(--r3-transition-base);
    }

    :scope.scrolled {
      background: rgba(10, 10, 15, 0.9);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .nav__inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--r3-space-md);
    }

    .nav__logo {
      display: flex;
      align-items: center;
      gap: var(--r3-space-sm);
      font-family: var(--r3-font-heading);
      font-size: var(--r3-text-lg);
      font-weight: 700;
      color: var(--r3-color-text-primary);
    }

    .nav__logo-icon {
      width: 32px;
      height: 32px;
      color: var(--r3-color-accent);
    }

    .nav__wordmark {
      letter-spacing: -0.02em;
    }

    .nav__accent {
      color: var(--r3-color-accent);
    }

    .nav__links {
      display: flex;
      align-items: center;
      gap: var(--r3-space-xs);
    }

    .nav__link {
      padding: var(--r3-space-xs) var(--r3-space-sm);
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
      border-radius: var(--r3-radius-sm);
      transition: color var(--r3-transition-fast), background var(--r3-transition-fast);
    }

    .nav__link:hover,
    .nav__link.active {
      color: var(--r3-color-accent);
      background: rgba(236, 72, 153, 0.1);
    }

    .nav__cta {
      padding: var(--r3-space-xs) var(--r3-space-md);
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      color: var(--r3-color-text-primary);
      font-weight: 600;
      font-size: var(--r3-text-sm);
      border-radius: var(--r3-radius-full);
      transition: transform var(--r3-transition-fast), box-shadow var(--r3-transition-fast);
    }

    .nav__cta:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 20px rgba(236, 72, 153, 0.4);
    }

    .nav__toggle {
      display: none;
      flex-direction: column;
      gap: 5px;
      padding: var(--r3-space-xs);
      background: transparent;
      border: none;
      cursor: pointer;
    }

    .nav__toggle span {
      width: 24px;
      height: 2px;
      background: var(--r3-color-text-primary);
      border-radius: 2px;
      transition: transform var(--r3-transition-fast), opacity var(--r3-transition-fast);
    }

    @media (max-width: 768px) {
      .nav__toggle {
        display: flex;
      }

      .nav__links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        padding: var(--r3-space-md);
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(12px);
        transform: translateY(-10px);
        opacity: 0;
        visibility: hidden;
        transition: all var(--r3-transition-base);
      }

      .nav__links.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
      }

      .nav__link {
        width: 100%;
        padding: var(--r3-space-sm);
        text-align: center;
      }
    }
  }

  /* ----- Hero Section ----- */
  @scope (.hero) {
    :scope {
      min-height: 100vh;
      display: flex;
      align-items: flex-start;
      padding-block-start: clamp(100px, 12vh, 140px);
      padding-block-end: var(--r3-space-2xl);
      position: relative;
      overflow: hidden;
    }

    :scope .container {
      display: grid;
      grid-template-columns: 1fr;
      gap: var(--r3-space-2xl);
      align-items: start;
      inline-size: 100%;
    }

    @media (width >= 64rem) {
      :scope .container {
        grid-template-columns: 1fr 1fr;
        gap: var(--r3-space-xl);
      }
    }

    .hero__content {
      position: relative;
      z-index: 2;
      max-inline-size: 600px;
    }

    .hero__tag {
      display: inline-block;
      padding: var(--r3-space-xs) var(--r3-space-md);
      margin-bottom: var(--r3-space-md);
      font-size: var(--r3-text-sm);
      font-weight: 600;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      color: var(--r3-color-accent);
      background: rgba(236, 72, 153, 0.1);
      border: 1px solid rgba(236, 72, 153, 0.3);
      border-radius: var(--r3-radius-full);
    }

    .hero__title {
      font-size: var(--r3-text-hero);
      margin-bottom: var(--r3-space-md);
      color: var(--r3-color-text-primary);
      line-height: 1.1;
      letter-spacing: -0.02em;
    }

    .hero__accent {
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .hero__subtitle {
      font-size: var(--r3-text-xl);
      color: var(--r3-color-text-muted);
      margin-bottom: var(--r3-space-lg);
      max-width: 600px;
    }

    .hero__pillars {
      display: flex;
      flex-wrap: wrap;
      gap: var(--r3-space-md);
      margin-bottom: var(--r3-space-xl);
    }

    .hero__pillar {
      padding: var(--r3-space-sm) var(--r3-space-md);
      font-size: var(--r3-text-sm);
      font-weight: 500;
      color: var(--r3-color-text-secondary);
      border: 1px solid var(--r3-color-border);
      border-radius: var(--r3-radius-md);
      transition: all var(--r3-transition-fast);
    }

    .hero__pillar:hover {
      background: rgba(236, 72, 153, 0.1);
      border-color: var(--r3-color-accent);
      color: var(--r3-color-accent);
    }

    .hero__actions {
      display: flex;
      flex-wrap: wrap;
      gap: var(--r3-space-md);
    }

    .hero__glow {
      position: absolute;
      top: 50%;
      inset-inline-end: 10%;
      inline-size: min(800px, 80vw);
      block-size: min(800px, 80vw);
      background: radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, transparent 60%);
      transform: translateY(-50%);
      pointer-events: none;
      z-index: 0;
    }

    .hero__visual {
      position: relative;
      z-index: 2;
      inline-size: 100%;
    }

    @media (width >= 64rem) {
      .hero__visual {
        position: sticky;
        top: clamp(100px, 12vh, 140px);
        align-self: start;
      }
    }

    @media (max-width: 63.99rem) {
      :scope {
        padding-block-start: 100px;
        min-height: auto;
      }

      :scope .container {
        gap: var(--r3-space-xl);
      }

      .hero__visual {
        margin-block-start: var(--r3-space-lg);
      }
    }

    @media (max-width: 768px) {
      :scope {
        padding-block-start: 100px;
      }

      .hero__actions {
        flex-direction: column;
      }

      .hero__actions .btn {
        width: 100%;
        text-align: center;
      }
    }
  }

  /* ----- Transformation Flow Animation ----- */
  @scope (.transformation-flow) {
    :scope {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      gap: var(--r3-space-xl);
      align-items: center;
      padding: var(--r3-space-xl);
      background: var(--r3-glass-bg);
      backdrop-filter: blur(12px);
      border: 1px solid var(--r3-color-border);
      border-radius: var(--r3-radius-lg);
      box-shadow: 0 8px 32px var(--r3-glass-shadow);
    }

    .transformation-flow__stage {
      display: flex;
      flex-direction: column;
      gap: var(--r3-space-md);
    }

    .transformation-flow__label {
      font-size: var(--r3-text-sm);
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      text-align: center;
      padding-bottom: var(--r3-space-sm);
      border-bottom: 2px solid var(--r3-color-border);
    }

    .transformation-flow__stage--old .transformation-flow__label {
      color: var(--r3-color-text-muted);
    }

    .transformation-flow__stage--new .transformation-flow__label {
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .transformation-flow__items {
      display: flex;
      flex-direction: column;
      gap: var(--r3-space-sm);
    }

    .transformation-flow__arrow {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--r3-space-sm);
      padding: 0 var(--r3-space-md);
    }

    .transformation-flow__arrow svg {
      animation: pulse-arrow 2s ease-in-out infinite;
    }

    @keyframes pulse-arrow {
      0%, 100% {
        opacity: 0.7;
        transform: translateX(0);
      }
      50% {
        opacity: 1;
        transform: translateX(5px);
      }
    }

    .arrow-path {
      stroke-dasharray: 100;
      stroke-dashoffset: 100;
      animation: draw-arrow 2s ease-out infinite;
    }

    @keyframes draw-arrow {
      0% {
        stroke-dashoffset: 100;
      }
      100% {
        stroke-dashoffset: 0;
      }
    }

    .transformation-flow__arrow-text {
      font-size: var(--r3-text-xs);
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      white-space: nowrap;
    }

    @media (max-width: 968px) {
      :scope {
        grid-template-columns: 1fr;
        gap: var(--r3-space-lg);
      }

      .transformation-flow__arrow {
        flex-direction: row;
        padding: var(--r3-space-md) 0;
      }

      .transformation-flow__arrow svg {
        transform: rotate(90deg);
      }
    }
  }

  /* ----- Overdose Counter ----- */
  @scope (.overdose-counter) {
    :scope {
      padding: var(--r3-space-xl);
      background: var(--r3-glass-bg);
      backdrop-filter: blur(12px);
      border: 1px solid rgba(236, 72, 153, 0.3);
      border-radius: var(--r3-radius-lg);
      box-shadow: 0 8px 32px var(--r3-glass-shadow);
      display: flex;
      flex-direction: column;
      gap: var(--r3-space-lg);
      position: relative;
      max-block-size: 90vh;
      /* Browser support: Firefox 3+ (moz), Safari 6+ (webkit), Chrome 46+, Edge 79+ */
      min-block-size: -moz-fit-content;
      min-block-size: -webkit-fit-content;
      min-block-size: fit-content;
      /* Prevent intersection observer from adding unwanted inline styles */
      opacity: 1 !important;
      transform: none !important;
    }

    :scope::before {
      content: "";
      position: absolute;
      inset: 0;
      background: radial-gradient(circle at top right, rgba(236, 72, 153, 0.08), transparent 50%);
      pointer-events: none;
    }

    .overdose-counter__header {
      text-align: center;
      position: relative;
      z-index: 1;
    }

    .overdose-counter__title {
      font-size: clamp(1.5rem, 3cqi, 2rem);
      font-weight: 700;
      color: var(--r3-color-text-primary);
      margin-block-end: var(--r3-space-xs);
      line-height: 1.2;
    }

    .overdose-counter__subtitle {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    .overdose-counter__display {
      text-align: center;
      padding: var(--r3-space-md);
      background: rgba(10, 10, 15, 0.5);
      border-radius: var(--r3-radius-md);
      border: 1px solid rgba(236, 72, 153, 0.2);
      position: relative;
      z-index: 1;
    }

    .overdose-counter__number {
      font-size: clamp(2.5rem, 6cqi, 4rem);
      font-weight: 800;
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      line-height: 1;
      margin-block-end: var(--r3-space-xs);
      font-family: var(--r3-font-heading);
      transition: all 0.5s ease;
    }

    .overdose-counter__label {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
      text-transform: uppercase;
      letter-spacing: 0.15em;
      font-weight: 600;
      margin-block-end: var(--r3-space-xs);
    }

    .overdose-counter__time {
      font-size: var(--r3-text-xs);
      color: var(--r3-color-accent);
      font-style: italic;
      font-weight: 500;
    }

    .overdose-counter__grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: var(--r3-space-lg);
      padding: var(--r3-space-xl);
      background: rgba(10, 10, 15, 0.3);
      border-radius: var(--r3-radius-md);
      position: relative;
      z-index: 1;
      /* Browser support: Firefox 3+ (moz), Safari 6+ (webkit), Chrome 46+, Edge 79+ */
      min-block-size: -moz-fit-content;
      min-block-size: -webkit-fit-content;
      min-block-size: fit-content;
      /* 3x3 grid should fit without scrolling in most cases */
      overflow-x: hidden;
    }

    .overdose-counter__figure {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border-radius: var(--r3-radius-md);
      padding: var(--r3-space-sm);
      transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
      position: relative;
      background: rgba(139, 92, 246, 0.08);
      border: 1px solid rgba(139, 92, 246, 0.2);
      cursor: pointer;
      min-block-size: 100px;
    }

    .overdose-counter__person {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--r3-space-xs);
      inline-size: 100%;
    }

    .overdose-counter__icon {
      font-size: clamp(1.5rem, 4cqi, 2rem);
      margin-block-end: var(--r3-space-xs);
      transition: all 0.4s ease;
    }

    .overdose-counter__figure svg {
      inline-size: clamp(2rem, 6cqi, 3rem);
      block-size: clamp(2rem, 6cqi, 3rem);
      fill: var(--r3-color-purple);
      transition: all 0.6s ease;
      filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.3));
    }

    .overdose-counter__label {
      text-align: center;
      transition: all 0.4s ease;
    }

    .overdose-counter__name {
      font-size: var(--r3-text-sm);
      font-weight: 600;
      color: var(--r3-color-text-primary);
      margin-block-end: 2px;
    }

    .overdose-counter__role {
      font-size: var(--r3-text-xs);
      color: var(--r3-color-text-muted);
      line-height: 1.3;
    }

    /* Alive state - vibrant and colorful */
    .overdose-counter__figure--alive {
      background: rgba(139, 92, 246, 0.12);
      border-color: rgba(139, 92, 246, 0.4);
      animation: pulseAlive 3s ease-in-out infinite;
    }

    .overdose-counter__figure--alive svg {
      fill: var(--r3-color-purple);
      opacity: 1;
    }

    @keyframes pulseAlive {
      0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
      }
      50% {
        box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
      }
    }

    /* Hover state for alive figures */
    .overdose-counter__figure--hover {
      transform: scale(1.05);
      background: rgba(139, 92, 246, 0.2);
      border-color: var(--r3-color-purple);
      box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
    }

    .overdose-counter__figure--hover .overdose-counter__icon {
      transform: scale(1.2);
    }

    /* Lost state - dramatic disappearing effect */
    .overdose-counter__figure--lost {
      background: rgba(10, 10, 15, 0.8);
      border-color: rgba(236, 72, 153, 0.6);
      animation: disappear 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
      cursor: default;
    }

    .overdose-counter__figure--lost::before {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(139, 92, 246, 0.2));
      border-radius: var(--r3-radius-md);
      opacity: 0;
      animation: fadeInOverlay 0.8s ease forwards;
    }

    .overdose-counter__figure--lost::after {
      content: "✕";
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      font-size: clamp(2rem, 8cqi, 4rem);
      font-weight: 700;
      color: var(--r3-color-accent);
      opacity: 0;
      animation: fadeInCross 0.6s ease 0.4s forwards;
      text-shadow: 0 0 12px rgba(236, 72, 153, 0.8);
    }

    .overdose-counter__figure--lost .overdose-counter__icon,
    .overdose-counter__figure--lost svg,
    .overdose-counter__figure--lost .overdose-counter__label {
      opacity: 0.2;
      filter: grayscale(100%);
    }

    .overdose-counter__figure--lost .overdose-counter__name {
      text-decoration: line-through;
      color: var(--r3-color-text-muted);
    }

    @keyframes disappear {
      0% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
      }
      50% {
        opacity: 0.8;
        transform: scale(0.95) rotateY(90deg);
      }
      100% {
        opacity: 0.6;
        transform: scale(0.9) rotateY(180deg);
      }
    }

    @keyframes fadeInOverlay {
      to {
        opacity: 1;
      }
    }

    @keyframes fadeInCross {
      0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
      }
      50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
      }
      100% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
      }
    }

    .overdose-counter__stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: var(--r3-space-md);
      position: relative;
      z-index: 1;
    }

    .overdose-counter__stat {
      text-align: center;
      padding: var(--r3-space-sm);
      background: rgba(10, 10, 15, 0.3);
      border-radius: var(--r3-radius-md);
      border: 1px solid var(--r3-color-border);
      transition: all var(--r3-transition-base);
    }

    .overdose-counter__stat:hover {
      border-color: var(--r3-color-accent);
      background: rgba(236, 72, 153, 0.05);
    }

    .overdose-counter__stat-value {
      font-size: var(--r3-text-2xl);
      font-weight: 700;
      color: var(--r3-color-accent);
      margin-block-end: var(--r3-space-xs);
      font-family: var(--r3-font-heading);
    }

    .overdose-counter__stat-label {
      font-size: var(--r3-text-xs);
      color: var(--r3-color-text-muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    .overdose-counter__footer {
      text-align: center;
      padding-block-start: var(--r3-space-md);
      border-block-start: 1px solid var(--r3-color-border);
      position: relative;
      z-index: 1;
      display: flex;
      flex-direction: column;
      gap: var(--r3-space-xs);
    }

    .overdose-counter__source {
      font-size: var(--r3-text-xs);
      color: var(--r3-color-text-muted);
      margin: 0;
    }

    .overdose-counter__cta {
      font-size: var(--r3-text-base);
      font-weight: 600;
      color: var(--r3-color-text-primary);
      font-style: italic;
      margin: 0;
      line-height: 1.5;
    }

    .overdose-counter__cta-action {
      font-size: var(--r3-text-lg);
      font-weight: 700;
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      margin: 0;
      margin-block-start: var(--r3-space-xs);
    }

    @media (max-width: 768px) {
      :scope {
        padding: var(--r3-space-xl);
      }

      .overdose-counter__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--r3-space-md);
        padding: var(--r3-space-md);
      }

      .overdose-counter__stats {
        grid-template-columns: 1fr;
      }

      .overdose-counter__icon {
        font-size: 1.25rem;
      }

      .overdose-counter__figure svg {
        inline-size: 2rem;
        block-size: 2rem;
      }
    }

    @media (max-width: 480px) {
      .overdose-counter__grid {
        grid-template-columns: 1fr;
        gap: var(--r3-space-sm);
      }

      .overdose-counter__role {
        font-size: 0.65rem;
      }
    }
  }

  /* ----- Transform Item ----- */
  @scope (.transform-item) {
    :scope {
      display: flex;
      align-items: center;
      gap: var(--r3-space-sm);
      padding: var(--r3-space-sm) var(--r3-space-md);
      border-radius: var(--r3-radius-md);
      transition: all var(--r3-transition-base);
      opacity: 0;
      animation: fade-in-up 0.6s ease-out forwards;
    }

    @keyframes fade-in-up {
      from {
        opacity: 0;
        transform: translateY(10px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    :scope:nth-child(1) {
      animation-delay: 0.1s;
    }

    :scope:nth-child(2) {
      animation-delay: 0.2s;
    }

    :scope:nth-child(3) {
      animation-delay: 0.3s;
    }

    :scope:nth-child(4) {
      animation-delay: 0.4s;
    }

    .transform-item--fade {
      background: rgba(113, 113, 122, 0.1);
      border: 1px solid rgba(113, 113, 122, 0.2);
    }

    .transform-item--rise {
      background: rgba(236, 72, 153, 0.1);
      border: 1px solid rgba(236, 72, 153, 0.3);
    }

    .transform-item--rise:hover {
      background: rgba(236, 72, 153, 0.15);
      border-color: var(--r3-color-accent);
      transform: translateX(4px);
    }

    .transform-item__icon {
      font-size: var(--r3-text-lg);
      flex-shrink: 0;
    }

    .transform-item__text {
      font-size: var(--r3-text-sm);
      font-weight: 500;
    }

    .transform-item--fade .transform-item__text {
      color: var(--r3-color-text-muted);
    }

    .transform-item--rise .transform-item__text {
      color: var(--r3-color-text-secondary);
    }
  }

  /* ----- Stat Card ----- */
  @scope (.stat-card) {
    :scope {
      padding: var(--r3-space-lg);
      text-align: center;
    }

    .stat-card__value {
      font-size: var(--r3-text-4xl);
      font-weight: 700;
      color: var(--r3-color-accent);
      line-height: 1;
      margin-bottom: var(--r3-space-xs);
    }

    .stat-card__value--alert {
      color: var(--r3-color-alert);
    }

    .stat-card__label {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
    }
  }

  /* ----- Feature Card ----- */
  @scope (.feature-card) {
    :scope {
      padding: var(--r3-space-lg);
      transition: transform var(--r3-transition-base), box-shadow var(--r3-transition-base);
    }

    :scope:hover {
      transform: translateY(-4px);
      box-shadow:
        0 12px 40px var(--r3-glass-shadow),
        0 0 0 1px rgba(236, 72, 153, 0.2);
    }

    .feature-card__icon {
      width: 48px;
      height: 48px;
      margin-bottom: var(--r3-space-md);
      padding: var(--r3-space-sm);
      background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
      border-radius: var(--r3-radius-md);
      color: var(--r3-color-text-primary);
    }

    .feature-card__title {
      font-size: var(--r3-text-lg);
      margin-bottom: var(--r3-space-sm);
    }

    .feature-card__text {
      font-size: 1rem;
      line-height: 1.6;
    }
  }

  /* ----- Section Header ----- */
  @scope (.section-header) {
    :scope {
      text-align: center;
      max-width: 700px;
      margin-inline: auto;
      margin-bottom: var(--r3-space-xl);
    }

    .section-header__tag {
      display: inline-block;
      font-size: var(--r3-text-sm);
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--r3-color-accent);
      margin-bottom: var(--r3-space-sm);
    }

    .section-header__title {
      margin-bottom: var(--r3-space-md);
    }

    .section-header__text {
      font-size: var(--r3-text-lg);
      color: var(--r3-color-text-muted);
    }
  }

  /* ----- Button ----- */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--r3-space-sm);
    padding: var(--r3-space-sm) var(--r3-space-lg);
    font-weight: 600;
    font-size: var(--r3-text-base);
    border-radius: var(--r3-radius-full);
    border: none;
    cursor: pointer;
    transition: all var(--r3-transition-fast);
  }

  .btn--primary {
    background: linear-gradient(135deg, var(--r3-color-accent), var(--r3-color-purple));
    color: var(--r3-color-text-primary);
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.3);
  }

  .btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(236, 72, 153, 0.4);
  }

  .btn--secondary {
    background: transparent;
    color: var(--r3-color-text-primary);
    border: 1px solid var(--r3-color-border);
  }

  .btn--secondary:hover {
    border-color: var(--r3-color-accent);
    color: var(--r3-color-accent);
    background: rgba(236, 72, 153, 0.05);
  }

  .btn:active {
    transform: translateY(0);
  }

  .btn:focus-visible {
    outline: 2px solid var(--r3-color-accent);
    outline-offset: 2px;
  }

  /* ----- Timeline ----- */
  @scope (.timeline) {
    :scope {
      position: relative;
    }

    .timeline__line {
      position: absolute;
      top: 24px;
      left: 24px;
      right: 24px;
      height: 2px;
      background: var(--r3-color-border);
    }

    @media (max-width: 768px) {
      .timeline__line {
        display: none;
      }
    }

    .timeline__items {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
      gap: var(--r3-space-md);
      position: relative;
    }

    .timeline__item {
      padding: var(--r3-space-lg);
      padding-top: calc(var(--r3-space-lg) + 24px);
      position: relative;
    }

    .timeline__dot {
      position: absolute;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 16px;
      height: 16px;
      background: var(--r3-color-surface-elevated);
      border: 3px solid var(--r3-color-border);
      border-radius: 50%;
    }

    .timeline__item--active .timeline__dot {
      background: var(--r3-color-accent);
      border-color: var(--r3-color-accent);
      box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.3);
    }

    .timeline__phase {
      font-size: var(--r3-text-xs);
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--r3-color-accent);
      margin-bottom: var(--r3-space-xs);
    }

    .timeline__title {
      font-size: var(--r3-text-lg);
      margin-bottom: var(--r3-space-sm);
    }

    .timeline__list {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
    }

    .timeline__list li {
      margin-bottom: var(--r3-space-xs);
      padding-left: var(--r3-space-md);
      position: relative;
    }

    .timeline__list li::before {
      content: '→';
      position: absolute;
      left: 0;
      color: var(--r3-color-accent);
    }
  }

  /* ----- Funding Card ----- */
  @scope (.funding-card) {
    :scope {
      padding: var(--r3-space-xl);
      text-align: center;
      background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(139, 92, 246, 0.1));
      border-color: var(--r3-color-accent);
    }

    .funding-card__label {
      font-size: var(--r3-text-sm);
      font-weight: 700;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      color: var(--r3-color-accent);
      margin-bottom: var(--r3-space-sm);
    }

    .funding-card__amount {
      font-size: var(--r3-text-hero);
      font-weight: 700;
      color: var(--r3-color-text-primary);
      line-height: 1;
      margin-bottom: var(--r3-space-sm);
    }

    .funding-card__runway {
      font-size: var(--r3-text-lg);
      color: var(--r3-color-text-muted);
    }
  }

  /* ----- Progress Bar ----- */
  .progress {
    margin-bottom: var(--r3-space-md);
  }

  .progress__header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--r3-space-xs);
    font-size: var(--r3-text-sm);
  }

  .progress__label {
    color: var(--r3-color-text-secondary);
  }

  .progress__value {
    color: var(--r3-color-accent);
    font-weight: 600;
  }

  .progress__bar {
    height: 8px;
    background: var(--r3-color-surface);
    border-radius: var(--r3-radius-full);
    overflow: hidden;
  }

  .progress__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--r3-color-accent), var(--r3-color-purple));
    border-radius: var(--r3-radius-full);
    transition: width var(--r3-transition-slow);
  }

  /* ----- Footer ----- */
  @scope (.footer) {
    :scope {
      padding: var(--r3-space-xl) 0;
      background: var(--r3-color-surface-elevated);
      border-top: 1px solid var(--r3-color-border);
    }

    .footer__inner {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: var(--r3-space-md);
    }

    .footer__brand {
      display: flex;
      align-items: center;
      gap: var(--r3-space-sm);
      font-family: var(--r3-font-heading);
      font-size: var(--r3-text-lg);
      font-weight: 700;
      letter-spacing: -0.02em;
    }

    .footer__brand svg {
      color: var(--r3-color-accent);
    }

    .footer__links {
      display: flex;
      gap: var(--r3-space-md);
    }

    .footer__link {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
      transition: color var(--r3-transition-fast);
    }

    .footer__link:hover {
      color: var(--r3-color-accent);
    }

    .footer__copy {
      width: 100%;
      text-align: center;
      padding-top: var(--r3-space-lg);
      margin-top: var(--r3-space-lg);
      border-top: 1px solid var(--r3-color-border);
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
    }
  }

  /* ----- Impact Card ----- */
  @scope (.impact-card) {
    :scope {
      padding: var(--r3-space-lg);
      text-align: center;
      position: relative;
      overflow: hidden;
    }

    :scope::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 4px;
      background: linear-gradient(90deg, var(--r3-color-accent), var(--r3-color-purple));
    }

    .impact-card__value {
      font-size: var(--r3-text-3xl);
      font-weight: 700;
      color: var(--r3-color-accent);
      margin-bottom: var(--r3-space-xs);
    }

    .impact-card__label {
      font-size: var(--r3-text-sm);
      color: var(--r3-color-text-muted);
    }
  }
}

/* ============================================
   LAYER: Utilities
   ============================================ */
@layer utilities {
  .text-center { text-align: center; }
  .text-accent { color: var(--r3-color-accent); }
  .text-alert { color: var(--r3-color-alert); }
  .text-muted { color: var(--r3-color-text-muted); }

  .mt-sm { margin-top: var(--r3-space-sm); }
  .mt-md { margin-top: var(--r3-space-md); }
  .mt-lg { margin-top: var(--r3-space-lg); }
  .mt-xl { margin-top: var(--r3-space-xl); }

  .mb-sm { margin-bottom: var(--r3-space-sm); }
  .mb-md { margin-bottom: var(--r3-space-md); }
  .mb-lg { margin-bottom: var(--r3-space-lg); }
  .mb-xl { margin-bottom: var(--r3-space-xl); }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Fade-in animation */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .fade-in {
    animation: fadeIn 0.6s ease forwards;
  }

  /* Smooth scrolling */
  html {
    scroll-padding-top: 80px;
  }

  /* Responsive typography adjustments */
  @media (max-width: 768px) {
    .hero__actions {
      flex-direction: column;
      width: 100%;
    }

    .btn {
      width: 100%;
      justify-content: center;
    }

    .section-header {
      text-align: left;
    }
  }

  @media (max-width: 480px) {
    .container {
      padding-inline: var(--r3-space-sm);
    }

    .grid {
      gap: var(--r3-space-md);
    }

    .glass {
      border-radius: var(--r3-radius-md);
    }
  }
}
