/* ============================================================
   CoreAI Glass — shared visual layer for every public page.
   Loaded AFTER each page's inline styles so its overrides win.

   What it does:
   1. Rebalances the palette: keeps the warm cream canvas and
      counters it with deep plum ink + a teal "opposite" accent.
   2. Apple-style liquid glass on cards, nav, chips and buttons.
   3. Styles for fx.js: water-wave canvas, ink ripples, wave-hit
      element reactions, scroll reveals and ambient orbs.
   ============================================================ */

:root {
  /* Canvas stays warm cream — only the foreground gets rebalanced */
  --ink: #271320;                 /* deep plum ink — max contrast on cream */
  --ink-soft: #6E4F60;            /* secondary text, ~6:1 on cream */
  --text-primary: var(--ink);
  --text-secondary: var(--ink-soft);
  --text-main: var(--ink);        /* app.html variable names */
  --text-muted: var(--ink-soft);

  /* Opposite pole: teal/cyan balances the warm pink–purple brand */
  --contrast: #0F766E;
  --contrast-bright: #14B8A6;
  --contrast-soft: rgba(20, 184, 166, 0.14);

  /* Apple glass tokens */
  --glass-bg: rgba(255, 255, 255, 0.52);
  --glass-bg-strong: rgba(255, 255, 255, 0.74);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-edge: rgba(45, 27, 40, 0.08);
  --glass-blur: 18px;
  --glass-shadow:
    0 8px 32px rgba(80, 30, 56, 0.10),
    0 1px 2px rgba(80, 30, 56, 0.06);
  --glass-inner:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.25);
}

::selection {
  background: rgba(20, 184, 166, 0.25);
  color: var(--ink);
}

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

/* ------------------------------------------------------------
   1 · Liquid glass surfaces
   The recipe: translucent white fill, backdrop blur + saturate,
   bright top edge, soft plum shadow.

   Two tiers for performance: real backdrop blur only on the few
   singleton surfaces; repeated grid/list items get the same
   translucent fill + edges WITHOUT backdrop-filter (hundreds of
   blur layers would tank scrolling). On the flat cream canvas
   the two are visually near-identical, and waves/orbs still
   shimmer through the translucent fill.
   ------------------------------------------------------------ */

/* Tier A — singleton surfaces: full Apple glass with backdrop blur */
.fx-glass,
#nav-component nav,
body > nav,
.hero-badge,
.web-app-link,
.search-box,
.cta-box,
.calc-card,
.tool-banner,
.file-drop-zone,
.result-container,
.legal-summary,
.legal-toc,
.compare-table {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-inner);
}

/* Tier B — repeated cards/chips: blur-free glass (cheap in grids) */
.stat-item,
.provider-card,
.model-list-card,
.pricing-card-mini,
.model-chip,
.feature-badge,
.model-card,
.spec-card,
.faq-item,
.tool-card,
.related-tool-card,
.how-step {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-inner);
}

/* Stronger glass where readability matters */
#nav-component nav,
body > nav,
.result-container,
.compare-table,
.calc-card {
  background: var(--glass-bg-strong);
}

/* Fixed nav keeps its own layout — only the surface changes */
#nav-component nav,
body > nav {
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid var(--glass-edge);
  box-shadow: 0 8px 32px rgba(80, 30, 56, 0.07);
}

/* Glass cards respond to hover with lift + teal-tinged glow */
.provider-card:hover,
.model-list-card:hover,
.model-card:hover,
.tool-card:hover,
.related-tool-card:hover,
.pricing-card-mini:hover {
  background: var(--glass-bg-strong);
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 16px 48px rgba(80, 30, 56, 0.14),
    0 2px 8px rgba(20, 184, 166, 0.10),
    var(--glass-inner);
}

/* ------------------------------------------------------------
   2 · Buttons — brand gradient gets a glass shine, secondary
   buttons become full glass with a teal hover pole.
   ------------------------------------------------------------ */
.btn-primary,
.nav-cta,
.cta-btn,
.btn-generate {
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 28px rgba(219, 39, 119, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 6px rgba(120, 8, 60, 0.18);
}

.btn-primary:hover,
.nav-cta:hover,
.cta-btn:hover,
.btn-generate:hover {
  box-shadow:
    0 14px 44px rgba(219, 39, 119, 0.38),
    0 4px 12px rgba(147, 51, 234, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-secondary,
.btn-glass,
.btn-reset,
.btn-copy {
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
}

.btn-secondary,
.btn-glass,
.filter-btn,
.pagination-btn,
.btn-reset,
.btn-copy {
  /* filter/pagination buttons appear in long rows — no backdrop blur there */
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 10px rgba(80, 30, 56, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

.btn-secondary:hover,
.btn-glass:hover,
.filter-btn:hover,
.pagination-btn:hover,
.btn-reset:hover,
.btn-copy:hover {
  background: var(--glass-bg-strong);
  border-color: var(--contrast-bright);
  color: var(--contrast);
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* Active filter chips flip to the teal pole for clear state contrast */
.filter-btn.active,
.filter-chip.active {
  background: var(--contrast-soft);
  border-color: var(--contrast-bright);
  color: var(--contrast);
}

/* Legal pages: heading gradient was white-on-cream (invisible) — re-ink it */
.legal-header h1 {
  background: linear-gradient(135deg, #271320 0%, #DB2777 60%, #0F766E 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ------------------------------------------------------------
   3 · fx.js hooks
   ------------------------------------------------------------ */

/* Water-wave canvas sits just above the page bg, below all content */
#fx-waves {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Ambient drifting orbs — pink, violet and the teal counterweight */
.fx-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.fx-orbs i {
  position: absolute;
  display: block;
  width: 42vmax;
  height: 42vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
  animation: fx-orb-drift 26s ease-in-out infinite;
}

.fx-orbs i:nth-child(1) {
  top: -18vmax;
  left: -10vmax;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.16), transparent 65%);
}

.fx-orbs i:nth-child(2) {
  bottom: -20vmax;
  right: -12vmax;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.12), transparent 65%);
  animation-delay: -9s;
  animation-duration: 32s;
}

.fx-orbs i:nth-child(3) {
  top: 30%;
  left: 55%;
  width: 30vmax;
  height: 30vmax;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.10), transparent 65%);
  animation-delay: -17s;
  animation-duration: 38s;
}

@keyframes fx-orb-drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(6vmax, -4vmax, 0) scale(1.08); }
  66%      { transform: translate3d(-4vmax, 5vmax, 0) scale(0.94); }
}

/* Ink ripple sprayed inside the pressed element (fx.js appends the span) */
.fx-ink {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.65) 0%,
    rgba(236, 72, 153, 0.28) 35%,
    rgba(20, 184, 166, 0.14) 60%,
    transparent 72%
  );
  transform: scale(0);
  animation: fx-ink-out 700ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fx-ink-out {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* Wave-front reaction: nearby glass briefly glows as the ripple passes.
   Glow only — no transform — so absolutely-placed elements never shift. */
.fx-wave-hit {
  border-color: rgba(20, 184, 166, 0.55) !important;
  box-shadow:
    0 10px 36px rgba(13, 148, 136, 0.18),
    0 8px 32px rgba(80, 30, 56, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
  filter: brightness(1.04) saturate(1.12);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

/* Scroll reveal — fx.js adds .fx-reveal then .fx-in when visible,
   so content stays visible if JS never runs */
.fx-reveal {
  opacity: 0;
  transform: translateY(22px);
}

.fx-reveal.fx-in {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.7s ease,
    transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .fx-orbs i { animation: none; }
  .fx-ink { animation-duration: 1ms; }
  .fx-reveal { opacity: 1; transform: none; }
}
