/* ──────────────────────────────────────────────────────────────────────────
   polish.css, site-wide visual polish layer
   Loaded on every public page after styles.css. All motion is gated behind
   prefers-reduced-motion so users who opt out get a calm, static page.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Reading progress bar (injected by page.js on article-style pages) ───── */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #d6a21e, #f0c75e, #d6a21e);
  background-size: 200% 100%;
  z-index: 9999;
  pointer-events: none;
  transition: width 80ms linear;
}

/* ── Back-to-top button (injected by page.js) ────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(214, 162, 30, 0.45);
  background: rgba(13, 35, 64, 0.88);
  color: #f0c75e;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  z-index: 900;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: rgba(21, 101, 192, 0.92);
}

/* ── Smooth anchor scrolling + heading offsets ───────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
h2[id],
h3[id] {
  scroll-margin-top: 90px;
}

@media (prefers-reduced-motion: no-preference) {
  /* ── Unified card hover physics ──────────────────────────────────────── */
  .card,
  .related-card,
  .trust-item,
  .nm-stat-card,
  .quick-fact {
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.28s ease,
      border-color 0.28s ease;
  }
  .card:hover,
  .related-card:hover,
  .nm-stat-card:hover {
    transform: translateY(-5px);
    box-shadow:
      0 14px 32px rgba(13, 35, 64, 0.14),
      0 0 0 1px rgba(214, 162, 30, 0.28);
  }
  .trust-item:hover {
    transform: translateY(-4px) scale(1.02);
  }

  /* ── Staggered cascade for revealed grids ────────────────────────────── */
  .card-grid > *,
  .related-grid > *,
  .trust-grid > *,
  .nm-stat-grid > *,
  .feature-grid > * {
    transition-delay: 0ms;
  }
  .card-grid > *:nth-child(2),
  .related-grid > *:nth-child(2),
  .trust-grid > *:nth-child(2),
  .nm-stat-grid > *:nth-child(2),
  .feature-grid > *:nth-child(2) {
    transition-delay: 90ms;
  }
  .card-grid > *:nth-child(3),
  .related-grid > *:nth-child(3),
  .trust-grid > *:nth-child(3),
  .nm-stat-grid > *:nth-child(3),
  .feature-grid > *:nth-child(3) {
    transition-delay: 180ms;
  }
  .card-grid > *:nth-child(4),
  .related-grid > *:nth-child(4),
  .trust-grid > *:nth-child(4),
  .nm-stat-grid > *:nth-child(4),
  .feature-grid > *:nth-child(4) {
    transition-delay: 270ms;
  }
  .card-grid > *:nth-child(n + 5),
  .related-grid > *:nth-child(n + 5),
  .nm-stat-grid > *:nth-child(n + 5),
  .feature-grid > *:nth-child(n + 5) {
    transition-delay: 340ms;
  }

  /* ── Section heading accent: gold bar grows in on reveal ─────────────── */
  main h2.h2-accent {
    position: relative;
    padding-bottom: 10px;
  }
  main h2.h2-accent::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    border-radius: 2px;
    background: linear-gradient(90deg, #d6a21e, rgba(214, 162, 30, 0.25));
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
  }
  main h2.h2-accent.accent-in::after {
    width: 56px;
  }

  /* ── CTA button sheen ────────────────────────────────────────────────── */
  .btn-gold,
  .cta .btn,
  .page-cta .btn {
    position: relative;
    overflow: hidden;
  }
  .btn-gold::before,
  .cta .btn::before,
  .page-cta .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 50%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.55s ease;
    pointer-events: none;
  }
  .btn-gold:hover::before,
  .cta .btn:hover::before,
  .page-cta .btn:hover::before {
    left: 130%;
  }

  /* ── Animated underline for in-article links ─────────────────────────── */
  main p > a:not(.btn),
  main li > a:not(.btn) {
    background-image: linear-gradient(90deg, currentColor, currentColor);
    background-repeat: no-repeat;
    background-size: 0% 1.5px;
    background-position: 0 100%;
    transition: background-size 0.3s ease;
    text-decoration: none;
  }
  main p > a:not(.btn):hover,
  main li > a:not(.btn):hover {
    background-size: 100% 1.5px;
  }

  /* ── Table row hover tint ────────────────────────────────────────────── */
  main table tbody tr {
    transition: background-color 0.2s ease;
  }
  main table tbody tr:hover {
    background-color: rgba(21, 101, 192, 0.05);
  }

  /* ── Homepage hero aurora: slow drifting gradient glow ───────────────── */
  .hero {
    position: relative;
    overflow: hidden;
  }
  .hero::before {
    content: '';
    position: absolute;
    inset: -40%;
    background:
      radial-gradient(40% 35% at 25% 30%, rgba(214, 162, 30, 0.13), transparent 70%),
      radial-gradient(35% 40% at 75% 65%, rgba(21, 101, 192, 0.18), transparent 70%),
      radial-gradient(30% 30% at 55% 20%, rgba(240, 199, 94, 0.08), transparent 70%);
    animation: aurora-drift 26s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
  }
  .hero > * {
    position: relative;
    z-index: 1;
  }
  @keyframes aurora-drift {
    0% {
      transform: translate3d(-4%, -3%, 0) rotate(0deg) scale(1);
    }
    50% {
      transform: translate3d(3%, 4%, 0) rotate(2deg) scale(1.06);
    }
    100% {
      transform: translate3d(-2%, 2%, 0) rotate(-2deg) scale(1.03);
    }
  }
}

/* Reduced motion: keep everything visible and calm */
@media (prefers-reduced-motion: reduce) {
  .read-progress,
  .back-to-top {
    transition: none;
  }
}
