/* ============================================================================
   TheWChat — Brand Theme (single source of truth)
   ----------------------------------------------------------------------------
   ALL brand color, gradient, radius, shadow and motion values live here as
   CSS custom properties. Change a value ONCE here and it propagates across the
   entire site (public + auth). No component hardcodes a hex value.

   Tailwind (loaded via CDN in the shared <head> partial) is configured to READ
   these variables, so utilities like `bg-brand-500` / `text-brand-600` resolve
   to the tokens below — no duplication between CSS and Tailwind config.

   The channel triplets (`--brand-500` = "37 99 235") are stored WITHOUT the
   rgb() wrapper on purpose: that lets Tailwind compose them with opacity, e.g.
   `bg-brand-500/20`. Use `rgb(var(--brand-500))` when writing plain CSS here.
   ============================================================================ */

:root {
  /* ── Brand scale (R G B channels, space-separated) ──────────────────────
     To re-brand the whole site, edit ONLY this scale. Everything derives
     from it. Tuned to the TheWChat logo hue (500 = #2747f0, the exact blue
     of the "W" chat-bubble mark in static/img/wchat_favicon.png). */
  --brand-50:  240 242 254;
  --brand-100: 220 226 253;
  --brand-200: 182 192 250;
  --brand-300: 138 156 247;
  --brand-400:  91 115 244;
  --brand-500:  39  71 240;   /* logo blue — the "W" mark */
  --brand-600:  37  66 220;   /* primary — buttons, links, focus */
  --brand-700:  34  59 192;
  --brand-800:  31  51 160;
  --brand-900:  29  44 130;

  /* ── Ink / surface neutrals (slate) ─────────────────────────────────── */
  --ink-950:  2  6 23;        /* deepest — dark hero, footer */
  --ink-900: 15 23 42;
  --ink-800: 30 41 59;
  --ink-700: 51 65 85;
  --ink-600: 71 85 105;
  --ink-500: 100 116 139;
  --ink-400: 148 163 184;
  --ink-300: 203 213 225;
  --ink-200: 226 232 240;
  --ink-100: 241 245 249;
  --ink-50:  248 250 252;

  /* ── Semantic accents (kept small + intentional) ────────────────────── */
  --accent:     139  92 246;  /* violet — pairs with brand in gradients */
  --success:     34 197  94;
  --warning:    245 158  11;
  --danger:     239  68  68;

  /* ── Composed tokens (derive from the scale above) ──────────────────── */
  --brand-gradient: linear-gradient(135deg,
      rgb(var(--brand-600)) 0%, rgb(var(--accent)) 100%);
  --hero-gradient: linear-gradient(160deg,
      rgb(var(--ink-950)) 0%, rgb(var(--ink-900)) 45%, rgb(var(--ink-950)) 100%);
  --brand-ring: 0 0 0 4px rgb(var(--brand-500) / 0.30);

  /* ── Shape & elevation ──────────────────────────────────────────────── */
  --radius-sm: 0.5rem;
  --radius:    0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --shadow-card:   0 1px 3px rgb(var(--ink-900) / 0.06),
                   0 10px 30px -12px rgb(var(--ink-900) / 0.10);
  --shadow-lift:   0 20px 45px -18px rgb(var(--ink-900) / 0.22);
  --shadow-brand:  0 14px 34px -12px rgb(var(--brand-600) / 0.45);

  /* ── Motion ─────────────────────────────────────────────────────────── */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur:  0.35s;
}

/* ============================================================================
   Base element defaults — set once, no per-page overrides needed.
   ============================================================================ */
html { scroll-behavior: smooth; }
/* Kill stray horizontal overflow from decorative bleeds (device spreads,
   arcs) — `clip` keeps position:sticky working, unlike `hidden`. */
html, body { overflow-x: clip; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
[x-cloak] { display: none !important; }  /* Alpine flash guard — only allowed !important */

::selection { background: rgb(var(--brand-600) / 0.18); }

/* Consistent focus ring for interactive elements (accessibility). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--brand-ring);
  border-radius: var(--radius-sm);
}

/* ============================================================================
   Reusable brand components — semantic classes, NOT utility soup.
   These compose the tokens above so templates stay clean and any restyle
   happens in one place. Prefixed `tw-` to avoid ANY collision with Tailwind
   utility class names (no override wars).
   ============================================================================ */

/* Surfaces --------------------------------------------------------------- */
.tw-gradient-brand { background: var(--brand-gradient); }
.tw-gradient-hero  { background: var(--hero-gradient); }

/* Light hero — clean white top with soft brand washes pooling in the lower
   corners (reference-style). Uses the brand hue so it re-tints with the theme. */
.tw-gradient-hero-light {
  background:
    radial-gradient(45% 60% at 2% 78%,   rgb(var(--accent)    / 0.22), transparent 70%),
    radial-gradient(45% 60% at 98% 78%,  rgb(var(--brand-400) / 0.24), transparent 70%),
    radial-gradient(85% 50% at 50% 115%, rgb(var(--brand-200) / 0.50), transparent 75%),
    linear-gradient(180deg, #ffffff 0%, #ffffff 28%, rgb(var(--brand-50)) 72%, rgb(var(--brand-100) / 0.8) 100%);
}

.tw-glass {
  background: rgb(255 255 255 / 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgb(255 255 255 / 0.10);
}

/* Faint dotted grid used behind dark sections. */
.tw-grid-dots {
  background-image: radial-gradient(rgb(var(--brand-400) / 0.14) 1px, transparent 1px);
  background-size: 26px 26px;
}

/* Buttons — ONE system for the whole site. ------------------------------
   Two variants with "pushable" 3D press physics (adapted from the layered
   front/edge/shadow technique into a single-element box-shadow version so
   no extra markup is needed):
     .tw-btn-primary — brand gradient face on a darker edge
     .tw-btn-light   — white face + brand border, for dark areas / CTA pairs
   Legacy aliases .tw-btn-ghost / .tw-btn-outline map to the light variant. */
.tw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 600; line-height: 1; border-radius: 0.5rem;
  padding: 0.875rem 1.5rem; cursor: pointer; white-space: nowrap;
  will-change: transform;
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1),
    box-shadow 600ms cubic-bezier(0.3, 0.7, 0.4, 1), filter 250ms ease;
  -webkit-tap-highlight-color: transparent;
}
.tw-btn-sm { padding: 0.625rem 1.125rem; font-size: 0.875rem; }

.tw-btn-primary {
  background: var(--brand-gradient); color: #fff;
  box-shadow: 0 4px 0 rgb(var(--brand-800)),
              0 8px 16px -4px rgb(var(--brand-900) / 0.45);
}
.tw-btn-primary:hover {
  filter: brightness(108%); transform: translateY(-2px);
  box-shadow: 0 6px 0 rgb(var(--brand-800)),
              0 12px 20px -4px rgb(var(--brand-900) / 0.45);
  transition-duration: 250ms; transition-timing-function: cubic-bezier(0.3, 0.7, 0.4, 1.5);
}
.tw-btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgb(var(--brand-800)),
              0 3px 6px -2px rgb(var(--brand-900) / 0.45);
  transition-duration: 34ms;
}

.tw-btn-light, .tw-btn-ghost, .tw-btn-outline {
  background: #fff; color: rgb(var(--brand-700));
  border: 1px solid rgb(var(--brand-300));
  box-shadow: 0 4px 0 rgb(var(--brand-300)),
              0 8px 16px -5px rgb(var(--brand-900) / 0.30);
}
.tw-btn-light:hover, .tw-btn-ghost:hover, .tw-btn-outline:hover {
  transform: translateY(-2px); background: rgb(var(--brand-50));
  box-shadow: 0 6px 0 rgb(var(--brand-300)),
              0 12px 20px -5px rgb(var(--brand-900) / 0.30);
  transition-duration: 250ms; transition-timing-function: cubic-bezier(0.3, 0.7, 0.4, 1.5);
}
.tw-btn-light:active, .tw-btn-ghost:active, .tw-btn-outline:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgb(var(--brand-300)),
              0 3px 6px -3px rgb(var(--brand-900) / 0.30);
  transition-duration: 34ms;
}

/* Dark variant (store badges, dark CTAs) — same press physics, black edge. */
.tw-btn-dark {
  background: rgb(var(--ink-950)); color: #fff; will-change: transform;
  box-shadow: 0 4px 0 #000, 0 8px 16px -4px rgb(var(--ink-900) / 0.5);
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1),
    box-shadow 600ms cubic-bezier(0.3, 0.7, 0.4, 1), background-color 250ms ease;
}
.tw-btn-dark:hover {
  transform: translateY(-2px); background: rgb(var(--ink-800));
  box-shadow: 0 6px 0 #000, 0 12px 20px -4px rgb(var(--ink-900) / 0.5);
  transition-duration: 250ms; transition-timing-function: cubic-bezier(0.3, 0.7, 0.4, 1.5);
}
.tw-btn-dark:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000, 0 3px 6px -2px rgb(var(--ink-900) / 0.5);
  transition-duration: 34ms;
}

@media (prefers-reduced-motion: reduce) {
  .tw-btn, .tw-btn:hover, .tw-btn:active { transform: none; transition: none; }
}

/* Universal 3D edge for small controls, avatars & chips — same depth
   language as the buttons. .tw-3d works on any fill (translucent dark edge
   reads as a deeper shade of the element's own color); .tw-3d-brand gives
   solid-brand elements their proper brand-800 edge. */
.tw-3d {
  box-shadow: 0 2px 0 rgb(var(--ink-900) / 0.18),
              0 4px 6px -2px rgb(var(--ink-900) / 0.18);
}
.tw-3d-brand {
  box-shadow: 0 2px 0 rgb(var(--brand-800)),
              0 5px 8px -2px rgb(var(--brand-900) / 0.45);
}

/* Opaque icon tile for dark timeline lists — visually identical to a
   brand-500/15 tint on ink-900, but SOLID so the connector line behind
   it can't show through the icon. */
.tw-tile-dark { background: color-mix(in srgb, rgb(var(--brand-500)) 16%, rgb(var(--ink-900))); }
.group\/pt:hover .tw-tile-dark { background: color-mix(in srgb, rgb(var(--brand-500)) 32%, rgb(var(--ink-900))); }

/* Shine sweep for primary CTAs (opt-in via .tw-shine). */
.tw-shine { position: relative; overflow: hidden; }
.tw-shine::before {
  content: ''; position: absolute; inset: 0 auto 0 -75%; width: 50%;
  background: linear-gradient(120deg, transparent, rgb(255 255 255 / 0.35), transparent);
  transform: skewX(-25deg); transition: left 0.7s var(--ease); pointer-events: none;
}
.tw-shine:hover::before { left: 125%; }

/* Cards ------------------------------------------------------------------ */
.tw-card {
  background: #fff; border: 1px solid rgb(var(--ink-200));
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}
.tw-lift { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.tw-lift:hover { transform: translateY(-6px); box-shadow: var(--shadow-lift); }

/* Eyebrow + heading accent ---------------------------------------------- */
.tw-eyebrow {
  display: block; color: rgb(var(--brand-600)); font-weight: 600;
  font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.14em;
}
.tw-underline { position: relative; display: inline-block; }
.tw-underline::after {
  content: ''; position: absolute; left: 50%; bottom: -0.65rem; width: 2.25rem;
  height: 3px; border-radius: 999px; background: var(--brand-gradient);
  transform: translateX(-50%);
}

/* Text gradient (for the highlighted word in headings). */
.tw-text-gradient {
  background: linear-gradient(90deg, rgb(var(--brand-400)), rgb(var(--accent)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Chrome: scroll progress, nav shadow, back-to-top --------------------- */
#scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--brand-gradient); z-index: 100;
  transition: width 0.1s ease-out; pointer-events: none;
}
nav.tw-scrolled { box-shadow: 0 6px 24px -10px rgb(var(--ink-900) / 0.14); }

#back-to-top {
  position: fixed; bottom: 1.75rem; left: 1.75rem; z-index: 90;
  width: 3rem; height: 3rem; border-radius: 999px;
  background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-brand);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
    visibility var(--dur) var(--ease);
}
#back-to-top.tw-visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* Smooth bottom fade for light-hero sections → next white section.
   Tall + eased stops so the blend has no visible band. */
.tw-fade-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; height: 11rem;
  pointer-events: none;
  background: linear-gradient(180deg,
    transparent 0%,
    rgb(255 255 255 / 0.25) 30%,
    rgb(255 255 255 / 0.60) 55%,
    rgb(255 255 255 / 0.88) 78%,
    #ffffff 100%);
}

/* Marquee (industry trust band) — soft, wide edge fade; pauses on hover. */
.tw-marquee { overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
.tw-marquee-track { display: flex; gap: 3.5rem; width: max-content; align-items: center;
  animation: tw-marquee 38s linear infinite; }
.tw-marquee:hover .tw-marquee-track { animation-play-state: paused; }
@keyframes tw-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Feature hero panel — hemispheric orb glow behind the icon: bright core,
   soft dome rings radiating outward, base dissolving to white at the bottom. */
.tw-panel-glow {
  background:
    /* bright core right behind the icon */
    radial-gradient(circle 90px at 50% 17%, rgb(255 255 255 / 0.45), transparent 100%),
    /* faint ring edge of the dome */
    radial-gradient(circle 190px at 50% 17%, transparent 78%, rgb(255 255 255 / 0.22) 86%, transparent 96%),
    /* mid dome */
    radial-gradient(circle 190px at 50% 17%, rgb(var(--accent) / 0.75) 0%, rgb(var(--accent) / 0.35) 60%, transparent 100%),
    /* outer hemisphere bloom */
    radial-gradient(circle 320px at 50% 17%, rgb(var(--brand-400) / 0.9) 0%, transparent 100%),
    /* base wash → white at bottom */
    linear-gradient(180deg,
      rgb(var(--brand-600)) 0%,
      rgb(var(--brand-500)) 50%,
      rgb(var(--brand-300)) 76%,
      rgb(var(--brand-100)) 90%,
      #ffffff 100%);
}

/* ── Bento hover demos (features section) ──────────────────────────────
   Elements inside a .group card that "come alive" on hover: reveals,
   typing dots, call rings, growing bars, ticks colorizing, toggles. */
.tw-reveal { opacity: 0; transform: translateY(6px) scale(0.97);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease); }
.group:hover .tw-reveal { opacity: 1; transform: none; }
.tw-reveal-d1 { transition-delay: 0.08s; }
.tw-reveal-d2 { transition-delay: 0.2s; }
.tw-reveal-d3 { transition-delay: 0.34s; }

@keyframes tw-typing { 0%,60%,100% { opacity:.25; transform:translateY(0); }
  30% { opacity:1; transform:translateY(-2px); } }
.tw-typing span { width:4px; height:4px; border-radius:999px; display:inline-block; }
.group:hover .tw-typing span { animation: tw-typing 1s infinite; }
.tw-typing span:nth-child(2) { animation-delay:.15s; }
.tw-typing span:nth-child(3) { animation-delay:.3s; }

@keyframes tw-ring { from { box-shadow:0 0 0 0 rgb(var(--brand-500)/.45); }
  to { box-shadow:0 0 0 16px transparent; } }
.group:hover .tw-ring { animation: tw-ring 1.3s ease-out infinite; }

@keyframes tw-grow { from { transform:scaleY(.25); } }
.group:hover .tw-grow { transform-origin:bottom; animation: tw-grow .7s var(--ease) both; }
.group:hover .tw-grow:nth-child(2) { animation-delay:.06s; }
.group:hover .tw-grow:nth-child(3) { animation-delay:.12s; }
.group:hover .tw-grow:nth-child(4) { animation-delay:.18s; }
.group:hover .tw-grow:nth-child(5) { animation-delay:.24s; }
.group:hover .tw-grow:nth-child(6) { animation-delay:.3s; }
.group:hover .tw-grow:nth-child(7) { animation-delay:.36s; }

.tw-tick { color: rgb(var(--ink-300)); transition: color .4s var(--ease); }
.group:hover .tw-tick { color: rgb(var(--brand-500)); }
.tw-online { background: rgb(var(--ink-300)); transition: background .4s var(--ease); }
.group:hover .tw-online { background: rgb(var(--success)); }

/* Toggle that flips ON when the card is hovered. */
.tw-demo-toggle { width:2rem; height:1.125rem; border-radius:999px;
  background: rgb(var(--ink-200)); position:relative; transition: background .35s var(--ease);
  box-shadow: 0 2px 0 rgb(var(--ink-900) / 0.12); }
.tw-demo-toggle::after { content:''; position:absolute; top:2px; left:2px;
  width:.875rem; height:.875rem; border-radius:999px; background:#fff;
  box-shadow:0 1px 2px rgb(var(--ink-900)/.2); transition: transform .35s var(--ease); }
.group:hover .tw-demo-toggle { background: rgb(var(--brand-500)); }
.group:hover .tw-demo-toggle::after { transform: translateX(0.875rem); }

@media (prefers-reduced-motion: reduce) {
  .group:hover .tw-typing span, .group:hover .tw-ring, .group:hover .tw-grow { animation: none; }
}

/* Device realism helpers (hero mockups). */
.tw-screen-glare { position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: linear-gradient(115deg, rgb(255 255 255 / 0.13) 0%, rgb(255 255 255 / 0.04) 26%, transparent 44%); }
.tw-ground-shadow { position: absolute; left: 5%; right: 5%; bottom: -18px; height: 24px;
  background: radial-gradient(50% 100% at 50% 0%, rgb(var(--ink-900) / 0.30), transparent 75%);
  filter: blur(6px); border-radius: 50%; pointer-events: none; }

.tw-float { animation: tw-float 6s ease-in-out infinite; }
@keyframes tw-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Respect reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tw-marquee-track, .tw-float { animation: none !important; }
}
