/* PT Pro animations.css — v1
 * Loaded on: index.html, pt-dashboard.html, messages.html, client.html
 * CSP: same-origin 'self' — no external dependencies.
 * Never use eval or inline event handlers in this file.
 */

/* ─────────────────────────────────────────────────────────────
   0a. GLOBAL FOCUS-VISIBLE — low specificity baseline
   Pages with stricter rules (pt-dashboard, book) win via specificity.
   Closes WCAG 2.1 SC 2.4.7 on pages that previously had none.
   ───────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid #D4FF47;
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #D4FF47;
  outline-offset: 2px;
}

/* Prevent CLS from typing-dots row before JS attaches */
.typing-dots { min-height: 32px; }

/* ─────────────────────────────────────────────────────────────
   0. REDUCED MOTION — must be first; everything else is additive
   ───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  [data-stagger] > *,
  .lift-card,
  .typing-dot,
  .progress-ring svg circle,
  .hero-float {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  /* Jump progress ring straight to final state */
  .progress-ring svg circle.ring-fill {
    stroke-dashoffset: 0 !important;
  }
  /* PR toast: skip in/out animations; confetti hidden entirely */
  .pr-toast.show {
    animation: prToastIn 0.01s linear forwards, prToastOut 0.01s linear 4.6s forwards;
  }
  .pr-confetti-piece { display: none; }
  /* Count-up jumps to target: handled in animations.js */
}

/* ─────────────────────────────────────────────────────────────
   1. STAGGER REVEAL
   Children of [data-stagger] start invisible and slide up when
   animations.js adds .in-view to the parent container.
   JS sets --stagger-i on each child so delays cascade.
   ───────────────────────────────────────────────────────────── */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.42s cubic-bezier(0.2, 0.9, 0.25, 1),
    transform 0.42s cubic-bezier(0.2, 0.9, 0.25, 1);
  transition-delay: calc(var(--stagger-i, 0) * 80ms);
  /* Prevent FOUC on slow connections: keep space reserved */
  will-change: opacity, transform;
}

[data-stagger="slow"] > * {
  transition-delay: calc(var(--stagger-i, 0) * 140ms);
}

[data-stagger].in-view > * {
  opacity: 1;
  transform: none;
}

/* ─────────────────────────────────────────────────────────────
   2. CARD LIFT — .lift-card
   Add to tiles that should lift on hover/focus. On touch
   devices (@media hover:none) the transform is suppressed so
   taps don't leave cards stuck in a lifted state.
   ───────────────────────────────────────────────────────────── */
.lift-card {
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  will-change: transform;
}

@media (hover: hover) {
  .lift-card:hover,
  .lift-card:focus-within {
    transform: translateY(-3px);
    border-color: rgba(212, 255, 71, 0.28);
    box-shadow:
      0 8px 28px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(212, 255, 71, 0.1);
  }
}

/* ─────────────────────────────────────────────────────────────
   3. TYPING DOTS — .typing-dots
   Three pulsing dots. Pure CSS animation.
   aria-label and role="status" must be set in HTML.
   ───────────────────────────────────────────────────────────── */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: typingBounce 1.1s ease-in-out infinite;
  opacity: 0.55;
}

.typing-dot:nth-child(1) { animation-delay: 0ms; }
.typing-dot:nth-child(2) { animation-delay: 200ms; }
.typing-dot:nth-child(3) { animation-delay: 400ms; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.55; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Typing indicator message bubble wrapper (in chat UI) */
.typing-indicator-bubble {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 0;
}

.typing-indicator-bubble .typing-dots {
  background: rgba(255, 255, 255, 0.07);
  border: 0.5px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  color: #A1A1AA;
}

/* Landing page chat preview bubbles */
.chat-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: rgba(15, 15, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  max-width: 320px;
  margin: 0 auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.chat-preview-bubble {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-preview-bubble.outgoing {
  flex-direction: row-reverse;
}

.chat-preview-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.chat-preview-text {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
  max-width: 200px;
  font-family: 'DM Sans', sans-serif;
}

.chat-preview-bubble.incoming .chat-preview-text {
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  color: #F4F4F5;
  border-bottom-left-radius: 4px;
}

.chat-preview-bubble.outgoing .chat-preview-text {
  background: #D4FF47;
  color: #070709;
  border-bottom-right-radius: 4px;
}

/* Typing dots inside chat preview */
.chat-preview-bubble .typing-dots {
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  color: #A1A1AA;
  padding: 9px 13px;
}

/* ─────────────────────────────────────────────────────────────
   4. PROGRESS RING — .progress-ring
   JS renders the SVG inside; this file handles layout + label.
   ───────────────────────────────────────────────────────────── */
.progress-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.progress-ring svg {
  display: block;
  overflow: visible;
}

.progress-ring .ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-linecap: round;
}

.progress-ring .ring-fill {
  fill: none;
  stroke: #D4FF47;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-ring .ring-num {
  font-family: 'Bebas Neue', 'DM Sans', sans-serif;
  font-size: 22px;
  fill: #F4F4F5;
  text-anchor: middle;
  dominant-baseline: middle;
}

.progress-ring .ring-pct {
  font-size: 11px;
  fill: #A1A1AA;
  text-anchor: middle;
  dominant-baseline: middle;
}

.progress-ring-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #A1A1AA;
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────
   5. HERO FLOAT — .hero-float
   Gentle vertical drift for the hero product preview image/card.
   Suppressed on touch devices to avoid distracting mobile users.
   ───────────────────────────────────────────────────────────── */
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

@media (hover: hover) {
  .hero-float {
    animation: heroFloat 4.5s ease-in-out infinite;
    will-change: transform;
  }
}

/* ─────────────────────────────────────────────────────────────
   6. STREAK HEATMAP — 12-week contribution grid
   JS reads data-cells (JSON ISO-date array) and paints cells.
   ───────────────────────────────────────────────────────────── */
.streak-heatmap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.streak-heatmap-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.streak-heatmap-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2, #A1A1AA);
}
.streak-heatmap-stat {
  font-size: 13px;
  color: var(--text2, #A1A1AA);
}
.streak-heatmap-stat strong {
  font-family: 'Bebas Neue', 'DM Sans', sans-serif;
  font-size: 18px;
  color: #D4FF47;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.streak-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}
.streak-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px solid rgba(255, 255, 255, 0.04);
  min-width: 10px;
  transition: transform 0.12s ease, background 0.2s ease;
}
.streak-cell.l1 { background: rgba(212, 255, 71, 0.18); border-color: rgba(212, 255, 71, 0.15); }
.streak-cell.l2 { background: rgba(212, 255, 71, 0.38); border-color: rgba(212, 255, 71, 0.25); }
.streak-cell.l3 { background: rgba(212, 255, 71, 0.65); border-color: rgba(212, 255, 71, 0.35); }
.streak-cell.l4 { background: #D4FF47; border-color: #D4FF47; }
.streak-cell.future { background: transparent; border-color: transparent; }
@media (hover: hover) {
  .streak-cell:not(.future):hover {
    transform: scale(1.35);
    z-index: 2;
  }
}
.streak-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text3, #71717A);
  justify-content: flex-end;
}
.streak-heatmap-legend .streak-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  min-width: 0;
  aspect-ratio: auto;
}

/* Light-theme variant — used on /t.html and any light-background page */
.streak-heatmap.theme-light .streak-cell {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.04);
}
.streak-heatmap.theme-light .streak-cell.l1 { background: rgba(200, 240, 0, 0.18); border-color: rgba(200, 240, 0, 0.15); }
.streak-heatmap.theme-light .streak-cell.l2 { background: rgba(200, 240, 0, 0.4); border-color: rgba(200, 240, 0, 0.25); }
.streak-heatmap.theme-light .streak-cell.l3 { background: rgba(170, 206, 0, 0.7); border-color: rgba(170, 206, 0, 0.45); }
.streak-heatmap.theme-light .streak-cell.l4 { background: #AACE00; border-color: #AACE00; }

/* ─────────────────────────────────────────────────────────────
   7. SPARKLINE + OVERLOAD CHART — SVG line, optional PR markers
   ───────────────────────────────────────────────────────────── */
.sparkline {
  display: block;
  width: 100%;
  height: 32px;
}
.sparkline path.spark-line {
  fill: none;
  stroke: #D4FF47;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sparkline path.spark-fill {
  fill: rgba(212, 255, 71, 0.12);
  stroke: none;
}

.overload-chart {
  width: 100%;
  display: block;
  background: transparent;
}
.overload-chart .axis {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}
.overload-chart .axis-label {
  font-size: 10px;
  fill: var(--text3, #71717A);
  font-family: 'DM Sans', sans-serif;
}
.overload-chart .data-line {
  fill: none;
  stroke: #D4FF47;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.overload-chart .data-fill {
  fill: rgba(212, 255, 71, 0.08);
  stroke: none;
}
.overload-chart .data-dot {
  fill: #D4FF47;
  stroke: #0a0a0c;
  stroke-width: 1.5;
}
.overload-chart .pr-marker {
  fill: #ffd166;
  stroke: #0a0a0c;
  stroke-width: 1.5;
}
.overload-chart .pr-label {
  font-size: 10px;
  font-weight: 700;
  fill: #ffd166;
  text-anchor: middle;
  font-family: 'DM Sans', sans-serif;
}
.overload-empty {
  padding: 22px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text3, #71717A);
  line-height: 1.6;
}

/* Light theme overrides */
.theme-light .overload-chart .axis { stroke: rgba(0, 0, 0, 0.1); }
.theme-light .overload-chart .axis-label { fill: #6B6B72; }
.theme-light .overload-chart .data-line { stroke: #AACE00; }
.theme-light .overload-chart .data-fill { fill: rgba(200, 240, 0, 0.12); }
.theme-light .overload-chart .data-dot { fill: #AACE00; stroke: #fff; }
.theme-light .overload-chart .pr-label { fill: #E8A20F; }

/* ─────────────────────────────────────────────────────────────
   8. PR CELEBRATION — confetti + badge
   ───────────────────────────────────────────────────────────── */
.pr-toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translate(-50%, -30px);
  z-index: 9999;
  background: linear-gradient(135deg, #D4FF47 0%, #AACE00 100%);
  color: #0a0a0c;
  border-radius: 14px;
  padding: 14px 22px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 36px rgba(212, 255, 71, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}
.pr-toast.show {
  animation: prToastIn 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.15) forwards,
             prToastOut 0.4s ease-in 4.6s forwards;
}
.pr-toast .pr-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #0a0a0c;
  color: #D4FF47;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.pr-toast .pr-text { display: flex; flex-direction: column; line-height: 1.25; }
.pr-toast .pr-small { font-size: 10px; font-weight: 800; opacity: 0.65; text-transform: uppercase; letter-spacing: 0.12em; }

@keyframes prToastIn {
  from { opacity: 0; transform: translate(-50%, -30px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes prToastOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -20px); }
}

/* Confetti — each piece is a span positioned + animated by JS via CSS variables */
.pr-confetti-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}
.pr-confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: var(--c, #D4FF47);
  opacity: 0.95;
  animation: confettiFall var(--d, 2.4s) cubic-bezier(0.4, 0, 0.5, 1) forwards,
             confettiSpin 1.1s linear infinite;
  will-change: transform, opacity;
}
@keyframes confettiFall {
  0%   { transform: translate3d(0, -10px, 0) rotate(0deg); opacity: 0.95; }
  90%  { opacity: 0.95; }
  100% { transform: translate3d(var(--x, 0), 100vh, 0) rotate(720deg); opacity: 0; }
}
@keyframes confettiSpin {
  from { filter: brightness(1); }
  to   { filter: brightness(1.15); }
}


/* ─────────────────────────────────────────────────────────────
   9. STAT TILE — used on pt-dashboard with sparkline
   ───────────────────────────────────────────────────────────── */
.stat-tile {
  background: var(--bg2, rgba(20, 20, 24, 0.6));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.stat-tile-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3, #71717A);
}
.stat-tile-value {
  font-family: 'Bebas Neue', 'DM Sans', sans-serif;
  font-size: 30px;
  letter-spacing: 0.02em;
  color: var(--text, #F4F4F5);
  line-height: 1.05;
}
.stat-tile-delta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2, #A1A1AA);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-tile-delta.up { color: #66E08A; }
.stat-tile-delta.down { color: #f87171; }
.stat-tile-spark {
  height: 32px;
  margin-top: 4px;
}
.stat-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ─────────────────────────────────────────────────────────────
   10. BEFORE/AFTER SLIDER — draggable comparison widget
   ───────────────────────────────────────────────────────────── */
.ba-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 14px;
  background: #111;
  user-select: none;
  touch-action: none;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.ba-slider .ba-img-after,
.ba-slider .ba-img-before-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ba-slider .ba-img-after img,
.ba-slider .ba-img-before-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ba-slider .ba-img-before-wrap {
  width: 50%;
  overflow: hidden;
}
.ba-slider .ba-img-before-wrap img {
  width: 200%;
  max-width: 200%;
}
.ba-slider .ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.45);
}
.ba-slider .ba-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #111;
  font-weight: 800;
}
.ba-slider .ba-tag {
  position: absolute;
  top: 12px;
  padding: 4px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  backdrop-filter: blur(6px);
}
.ba-slider .ba-tag.before { left: 12px; }
.ba-slider .ba-tag.after  { right: 12px; }
.ba-slider .ba-knob:focus-visible {
  outline: 2px solid #D4FF47;
  outline-offset: 3px;
}
