/* ============================================================
   Tangled Group, Inc - spec-4 (2026 UI pass over spec-3 content)
   Pure Tailwind (browser build v4). Design tokens live in the
   inline <style type="text/tailwindcss"> @theme block on each
   page. This file holds what utilities cannot express: base
   tuning, film grain, aurora/grid backdrops, gradient text,
   spotlight cards, board FLIP transitions, and motion.
   Theme: dark default, .dark class, localStorage("tg-theme").

   Crisp 2026 edge system (kept in sync across the inline
   utilities on every page):
   - Light hairlines:  #d5dde8 (cards) / #c2ccda (controls)
     on #f6f8fc; light cards get a 1px static shadow.
   - Dark hairlines:   white 10-15% (no longer 6-8%); cards
     add an inset 1px top highlight ("machined" edge).
   - Radius: 12px (rounded-xl) on cards/surfaces, 32px CTA
     retired; pills stay for buttons/chips.
   - Ink tiers light:  #0f172a / #2a3852 / #334155 / #52617a.
     Ink tiers dark:   #f4f8fd / #c6d0e1 / #a8b3c6 / #8494ab.
   - Primary: light #256cb0 (AA on white), dark links #4db3f0;
     .btn-primary buttons: light blue+white / dark bright
     blue + dark ink text (high contrast).
   ============================================================ */

/* ---------- base ---------- */
html {
  scroll-behavior: smooth;
}
body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
::selection {
  background: rgba(37, 108, 176, 0.3);
}
.dark ::selection {
  background: rgba(77, 179, 240, 0.5);
}
:focus-visible {
  outline: 2px solid #256cb0;
  outline-offset: 2px;
  border-radius: 6px;
}
.dark :focus-visible {
  outline-color: #4db3f0;
}

/* ---------- diagram palette (SVG <text>/<rect> fills reference these) ---------- */
:root {
  --primary: #256cb0;
  --primary-soft: #e8f2fd;
  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-muted: #52617a;
  --line-strong: #c2ccda;
  --surface: #ffffff;
}
.dark {
  /* Tailwind token overrides: crisp 2026 tiers (dark-first) */
  --color-primary: #4db3f0;
  --color-primary-strong: #8ecdf6;
  --primary: #4db3f0;
  --primary-soft: rgba(52, 152, 219, 0.12);
  --ink: #f4f8fd;
  --ink-soft: #a8b3c6;
  --ink-muted: #8494ab;
  --line-strong: rgba(255, 255, 255, 0.24);
  --surface: #0d1220;
}

/* ---------- active nav link (app.js sets aria-current="page") ---------- */
nav a[aria-current="page"] {
  font-weight: 600;
  background-color: #e6ebf3;
  color: #0f172a;
}
.dark nav a[aria-current="page"] {
  background-color: rgba(255, 255, 255, 0.09);
  color: #f4f8fd;
}

/* ---------- skip link (accessibility) ---------- */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 200;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  text-decoration: none;
}
.dark .skip-link {
  background: #f4f8fd;
  color: #0f172a;
}
.skip-link:focus {
  top: 1rem;
}

/* ---------- primary buttons (per-theme machined blue) ----------
   Light: deep AA blue + white text. Dark: bright blue + dark ink text
   (high-contrast, crisp) with a tight blue glow. */
.btn-primary {
  background-color: var(--color-primary);
}
.dark .btn-primary {
  background-color: #2f8fe0;
  color: #08131f;
  box-shadow: 0 6px 20px -8px rgba(77, 179, 240, 0.55);
}

/* ---------- film grain (fixed, above content, imperceptible) ---------- */
.noise {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
.dark .noise {
  opacity: 0.035;
}

/* ---------- hero backdrop: aurora + grid ----------
   Note: the hero <section> is pulled up with mt-[-68px] sm:mt-[-72px]
   (its height = header height: pt-3/pt-4 + h-14) so this backdrop
   starts at the very top of the viewport, behind the floating nav
   pill. Each page's hero content top padding is increased by the
   same amount (pt-[148px]/[164px], sm:pt-[184px]/[200px]) so the
   visible content does not shift. Keep the two in sync. */
.hero-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(48rem 24rem at 50% -12%, rgba(37, 108, 176, 0.24), transparent 60%),
    radial-gradient(32rem 20rem at 82% 6%, rgba(99, 102, 241, 0.16), transparent 56%),
    radial-gradient(32rem 20rem at 14% 12%, rgba(56, 189, 248, 0.13), transparent 56%);
}
.dark .hero-glow {
  background:
    radial-gradient(48rem 24rem at 50% -12%, rgba(52, 152, 219, 0.30), transparent 60%),
    radial-gradient(32rem 20rem at 82% 6%, rgba(99, 102, 241, 0.20), transparent 56%),
    radial-gradient(32rem 20rem at 14% 12%, rgba(56, 189, 248, 0.16), transparent 56%);
}
.hero-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(100, 116, 139, 0.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(100, 116, 139, 0.22) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(46rem 22rem at 50% 0%, black 0%, transparent 66%);
  mask-image: radial-gradient(46rem 22rem at 50% 0%, black 0%, transparent 66%);
  opacity: 0.75;
}

/* ---------- CTA card backdrop (light: soft mesh + grid + hairline) ----------
   Light theme blends with the #f6f8fc page; dark theme keeps the deep-slate card. */
.cta-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(46rem 22rem at 18% -12%, rgba(37, 108, 176, 0.18), transparent 62%),
    radial-gradient(40rem 22rem at 85% 118%, rgba(99, 102, 241, 0.14), transparent 62%),
    radial-gradient(30rem 16rem at 72% -18%, rgba(56, 189, 248, 0.12), transparent 60%);
}
.dark .cta-glow {
  background:
    radial-gradient(640px 260px at 18% -10%, rgba(52, 152, 219, 0.45), transparent 70%),
    radial-gradient(640px 260px at 85% 115%, rgba(99, 102, 241, 0.35), transparent 70%);
}
.cta-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(100, 116, 139, 0.13) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(100, 116, 139, 0.13) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(42rem 22rem at 50% 0%, black 0%, transparent 78%);
  mask-image: radial-gradient(42rem 22rem at 50% 0%, black 0%, transparent 78%);
}
.dark .cta-grid {
  display: none;
}
.cta-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 4%, rgba(37, 108, 176, 0.8) 30%, rgba(99, 102, 241, 0.6) 70%, transparent 96%);
}
.dark .cta-line {
  display: none;
}

/* ---------- gradient text ---------- */
.grad-text {
  background: linear-gradient(97deg, #1264c4 0%, #256cb0 45%, #5b5fe8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.dark .grad-text {
  background: linear-gradient(97deg, #6fc9f7 0%, #4db3f0 45%, #9aa1f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- glass surface ---------- */
.glass {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(19, 28, 48, 0.14);
}
.dark .glass {
  background: rgba(10, 14, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ---------- header scrolled state (app.js toggles the class) ---------- */
#tg-header.header-scrolled .header-shell {
  box-shadow: 0 12px 32px -20px rgba(2, 6, 23, 0.32), 0 2px 8px -4px rgba(2, 6, 23, 0.12);
}
.dark #tg-header.header-scrolled .header-shell {
  box-shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ---------- hero board - FLIP transitions (app.js) ---------- */
.board-task {
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.board-task .task-dot {
  transition: background-color 0.45s ease;
}

/* ---------- floating badges (index hero) ---------- */
@keyframes tg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.float-badge {
  animation: tg-float 7s ease-in-out infinite;
}
.float-badge-slow {
  animation-duration: 9s;
  animation-delay: 1.2s;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}

/* ===================== responsive: sticky table column =====================
   Comparison tables use .cmp-table: border-collapse BREAKS position:sticky
   on table cells in WebKit (and strands row borders there), so the table
   is border-separate and row dividers live on cells, not on <tr>. */
.cmp-table {
  border-collapse: separate;
  border-spacing: 0;
}
.cmp-table > tbody > tr + tr > th,
.cmp-table > tbody > tr + tr > td {
  border-top: 1px solid #dbe2ec;
}
.dark .cmp-table > tbody > tr + tr > th,
.dark .cmp-table > tbody > tr + tr > td {
  border-top-color: rgba(255, 255, 255, 0.10);
}
.col-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #ffffff;
  box-shadow: 1px 0 0 0 #c9d3e2;
}
.col-sticky-thead {
  background: #f6f8fc;
}
.dark .col-sticky {
  background: #11151d;
  box-shadow: 1px 0 0 0 rgba(255, 255, 255, 0.10);
}
/* exact match of thead row bg (white/2% over the white/3% dark card) */
.dark .col-sticky-thead {
  background: #161a22;
}

/* ===================== responsive: horizontal scroll affordance ===================== */
.scroll-fade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3.5rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95));
  z-index: 2;
}
.dark .scroll-fade {
  background: linear-gradient(90deg, transparent, rgba(17, 21, 29, 0.95));
}
.scroll-fade.is-on {
  opacity: 1;
}

.table-scroll,
.diag-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}
.table-scroll::-webkit-scrollbar,
.diag-scroll::-webkit-scrollbar {
  height: 8px;
}
.table-scroll::-webkit-scrollbar-thumb,
.diag-scroll::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}
.table-scroll::-webkit-scrollbar-track,
.diag-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* horizontal scroll progress (visible affordance in both themes) */
.scroll-progress {
  position: relative;
  height: 3px;
  margin: 10px 16px 0;
  border-radius: 999px;
  background: rgba(203, 213, 225, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.dark .scroll-progress {
  background: rgba(148, 163, 184, 0.18);
}
.scroll-progress.is-on {
  opacity: 1;
}
.scroll-progress > span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10%;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.6);
  transition: none;
}
.dark .scroll-progress > span {
  background: rgba(148, 163, 184, 0.45);
}
