/* ============================================================
   TroTrace — Clinical Blue Design System v2
   ------------------------------------------------------------
   Brand: deep navy (#0b1f3a) + royal blue (#2563eb) + sky (#0ea5e9)
   Surface: cool clinical white (#f8fafc)
   Voice: precise, modern, medical-grade UI
   ============================================================ */

:root {
  /* --- Brand tokens (mirror Tailwind config) --- */
  --ink-950: #060f1d;
  --ink-900: #0b1f3a;
  --ink-800: #14304f;
  --ink-700: #1e4068;
  --ink-600: #2c5282;
  --ink-50:  #f0f5fa;

  --accent-700: #1d4ed8;
  --accent-600: #2563eb;
  --accent-500: #3b82f6;
  --accent-400: #60a5fa;
  --accent-100: #dbeafe;
  --accent-50:  #eff6ff;

  --sky-500: #0ea5e9;
  --sky-400: #38bdf8;

  --surface:    #f8fafc;
  --surface-card: #ffffff;
  --hairline:   rgba(11, 31, 58, 0.08);
  --hairline-strong: rgba(11, 31, 58, 0.14);

  /* --- Elevation --- */
  --elev-1: 0 1px 2px rgba(11, 31, 58, 0.04), 0 1px 3px rgba(11, 31, 58, 0.06);
  --elev-2: 0 4px 8px -2px rgba(11, 31, 58, 0.06), 0 2px 4px -1px rgba(11, 31, 58, 0.04);
  --elev-3: 0 12px 24px -8px rgba(11, 31, 58, 0.10), 0 4px 8px -2px rgba(11, 31, 58, 0.06);
  --elev-4: 0 24px 48px -12px rgba(11, 31, 58, 0.18), 0 8px 16px -4px rgba(11, 31, 58, 0.08);

  /* --- Motion --- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 0.15s;
  --dur-base: 0.25s;
  --dur-slow: 0.5s;

  /* --- Radii --- */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
}

/* ============================================================
   Base
   ============================================================ */
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--surface);
  color: #0f172a;
}

body.font-arabic {
  font-family: 'Tajawal', system-ui, sans-serif;
}

video {
  background: #000;
  object-fit: cover;
  display: block;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Universal focus ring — keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   Language toggle pills
   ============================================================ */
.lang-btn {
  background: transparent;
  color: #475569;
  border: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.lang-btn:hover {
  background: var(--accent-50);
  color: var(--ink-900);
}
.lang-btn-active {
  background: var(--ink-900);
  color: #ffffff;
  border-color: var(--ink-900);
}
.lang-btn-active:hover {
  background: var(--ink-800);
  color: #ffffff;
}

/* ============================================================
   Hero CTA — primary button glow + lift
   ============================================================ */
.cta-primary {
  position: relative;
  isolation: isolate;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.cta-primary::before {
  content: '';
  position: absolute;
  inset: -6px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.25), transparent 65%);
  border-radius: 9999px;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.cta-primary:hover::before { opacity: 1; }
.cta-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-3);
}
.cta-primary:active {
  transform: translateY(0);
  box-shadow: var(--elev-1);
}

/* ============================================================
   Hero mark — refined static profile + animated trace
   ============================================================ */
.hero-mark {
  filter: drop-shadow(0 16px 36px rgba(11, 31, 58, 0.18))
          drop-shadow(0 4px 8px rgba(11, 31, 58, 0.08));
  transition: transform var(--dur-slow) var(--ease-out);
}
.hero-mark:hover { transform: translateY(-3px) scale(1.01); }

.hero-trace {
  animation: trace-flow 6s var(--ease-in-out) infinite;
}
@keyframes trace-flow {
  from { transform: translateX(-2%); }
  50%  { transform: translateX(2%); }
  to   { transform: translateX(-2%); }
}

/* ============================================================
   Record-button pulse ring (idle state)
   ============================================================ */
.record-pulse:not(:disabled) {
  animation: pulse-ring 2.4s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  70%  { box-shadow: 0 0 0 18px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ============================================================
   Scroll-reveal fade
   ============================================================ */
.reveal-pre {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease-out),
              transform 0.7s var(--ease-out);
}
.reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Step + feature card lift
   ============================================================ */
.step-card,
.feature-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.step-card:hover,
.feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--elev-3);
}

/* ============================================================
   Smooth in-page anchor scrolling
   ============================================================ */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

/* ============================================================
   Premium typography polish on display headlines
   ============================================================ */
.font-display {
  font-feature-settings: "ss01", "kern", "ss02";
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* ============================================================
   Comparison table
   ============================================================ */
.compare-row {
  transition: background var(--dur-base) var(--ease-out);
}
.compare-row:hover {
  background: rgba(37, 99, 235, 0.05);
}

/* ============================================================
   Testimonial figure subtle lift
   ============================================================ */
figure.reveal {
  transition: transform var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
figure.reveal:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: var(--elev-2);
}

/* ============================================================
   Reduced motion: disable infinite-loop animations
   ------------------------------------------------------------
   The closing-CTA glow that used to live here as
   a[href="#analyze"].bg-gold-600 was removed when the analyze
   anchor migrated to /record.html — its glow effect is now
   carried by an inline box-shadow on the CTA itself.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .hero-trace,
  .record-pulse:not(:disabled),
  #limbDiagram rect[fill]:not([fill="transparent"]) {
    animation: none !important;
  }
  html { scroll-behavior: auto; }
}

/* ============================================================
   Result panel
   ============================================================ */
#resultPanel {
  animation: result-fade-in 0.5s var(--ease-out);
}
@keyframes result-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#verdictHeadline {
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* ============================================================
   Limb diagram highlight pulse
   ============================================================ */
#limbDiagram rect[fill]:not([fill="transparent"]) {
  animation: limb-pulse 1.6s var(--ease-in-out) infinite alternate;
}
@keyframes limb-pulse {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

/* ============================================================
   Verdict badges — flat pills
   ============================================================ */
.badge-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}
.badge-coral { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #dcfce7; color: #14532d; }
.badge-red   { background: #fecaca; color: #7f1d1d; }
.badge-blue  { background: var(--accent-100); color: var(--accent-700); }

/* ============================================================
   Raw-data pre block (debug toggle)
   ============================================================ */
#rawJson {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.5;
}

/* ============================================================
   Subtle gradient hairline divider — premium section breaks
   ============================================================ */
.hairline-divider {
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--hairline-strong) 20%,
    var(--hairline-strong) 80%,
    transparent
  );
  border: 0;
}

/* ============================================================
   Glass nav (sticky header) — refined backdrop
   ============================================================ */
.glass-nav {
  background: rgba(248, 250, 252, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--hairline);
}

/* ============================================================
   Eyebrow with leading status indicator dot
   ------------------------------------------------------------
   Linear / Stripe pattern: small 6px circle pulsing softly,
   followed by an uppercase letter-spaced label. Signals "live".
   ============================================================ */
.eyebrow-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-700);
}
.eyebrow-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-600);
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5);
  animation: dot-pulse 2s var(--ease-in-out) infinite;
}
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(37, 99, 235, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0   rgba(37, 99, 235, 0); }
}

/* ============================================================
   Numbered section marker (01 / 02 / 03) — editorial style
   ============================================================ */
.section-marker {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-700);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.section-marker::after {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--accent-600);
  opacity: 0.4;
}

/* ============================================================
   Pipe divider — vertical separator for inline strips
   (stats row, trust attribution row)
   ============================================================ */
.pipe-divider {
  width: 1px;
  height: 32px;
  background: var(--hairline-strong);
  align-self: center;
}

/* ============================================================
   Premium card — subtle elevated tier with hairline border
   ============================================================ */
.premium-card {
  background: var(--surface-card);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-1);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.premium-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--elev-3);
}

/* ============================================================
   Editorial pull-quote — for testimonials + about page
   ============================================================ */
.pull-quote {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: #334155;
  letter-spacing: -0.005em;
  font-weight: 400;
}
.pull-quote::before {
  content: '"';
  display: block;
  font-size: 36px;
  color: var(--accent-600);
  line-height: 0.7;
  margin-bottom: 10px;
  font-weight: 500;
}

/* ============================================================
   Trust strip — refined attribution row with pipe separators
   ============================================================ */
.trust-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
}
.trust-strip > * {
  padding: 0 28px;
  position: relative;
}
.trust-strip > *:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 28px;
  background: var(--hairline-strong);
}

/* ============================================================
   Closing CTA on dark navy — premium depth + soft glow
   ============================================================ */
.closing-cta-dark {
  position: relative;
  isolation: isolate;
  background: var(--ink-900);
  overflow: hidden;
}
.closing-cta-dark::before {
  content: '';
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.18), transparent 60%);
  z-index: 0;
  pointer-events: none;
}
.closing-cta-dark > * { position: relative; z-index: 1; }

/* ============================================================
   Display headline scale — clamps for fluid type
   ============================================================ */
.display-hero {
  font-size: clamp(40px, 8vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.024em;
  font-weight: 800;
  text-wrap: balance;
}
.display-section {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-wrap: balance;
}

/* ============================================================
   Shimmer underline for inline links inside body copy
   ============================================================ */
.link-shimmer {
  position: relative;
  color: var(--accent-700);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out);
}
.link-shimmer::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform-origin: right;
  transform: scaleX(0.4);
  opacity: 0.6;
  transition: transform var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out);
}
.link-shimmer:hover { color: var(--ink-900); }
.link-shimmer:hover::after {
  transform-origin: left;
  transform: scaleX(1);
  opacity: 1;
}
