/**
 * Shared testimonial UI for static sales pages (Branch Writing, Nested Notes, etc.).
 *
 * Requires first: that page’s variables.css (--color-accent, --color-accent-rgb,
 * --color-primary-bg-rgb). Markup lives under #__next for shadow overrides.
 *
 * Not used by /ai (separate testimonial components).
 *
 * Hydration: /testimonial-sales-page/js/youtube-testimonial-mount.js
 * API: /api/public/branch-writing-youtube-comment (per-product filters apply server-side).
 */

/* ---------- DB quote cards (.bw-testimonial-db) ---------- */

.bw-testimonial-db {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1.375rem;
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(
    145deg,
    rgba(var(--color-primary-bg-rgb), 0.92) 0%,
    rgba(var(--color-primary-bg-rgb), 0.88) 100%
  );
  border: 1px solid rgba(var(--color-accent-rgb), 0.22);
  border-radius: 18px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: visible;
}

.bw-testimonial-db::before {
  content: '\201C';
  position: absolute;
  top: 0.08rem;
  left: 0.45rem;
  font-size: clamp(3.35rem, 2.25rem + 3.5vw, 4.75rem);
  line-height: 0.88;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  color: rgba(var(--color-accent-rgb), 0.38);
  pointer-events: none;
  z-index: 0;
}

.bw-testimonial-db__header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding-left: 0.25rem;
  position: relative;
  z-index: 1;
}

.bw-testimonial-db__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.bw-testimonial-db__name {
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.bw-testimonial-db__quote {
  color: rgba(226, 232, 240, 0.95);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.55;
  margin: 0;
  padding-left: 0.125rem;
  white-space: pre-line;
  position: relative;
  z-index: 1;
}

.bw-testimonial-db__quote mark {
  background: rgba(var(--color-accent-rgb), 0.18);
  color: var(--color-accent);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
}

/* No profile image: cool off-white + subtle paper grain (noise + fiber lines) */
.bw-testimonial-db.bw-testimonial--no-photo {
  --tsp-paper-base-a: color-mix(in srgb, var(--color-accent) 10%, #f8fafc 90%);
  --tsp-paper-base-b: color-mix(in srgb, var(--color-accent) 14%, #edf4fa 86%);
  overflow: visible;
  background-color: color-mix(in srgb, var(--color-accent) 12%, #f7fafc 88%);
  background-image:
    radial-gradient(ellipse 120% 70% at 50% -5%, rgba(255, 255, 255, 0.65), transparent 52%),
    repeating-linear-gradient(
      95deg,
      rgba(15, 23, 42, 0.022) 0,
      transparent 0.5px,
      transparent 5px
    ),
    repeating-linear-gradient(
      8deg,
      transparent 0,
      transparent 6px,
      rgba(var(--color-accent-rgb), 0.04) 6px,
      rgba(var(--color-accent-rgb), 0.04) 6.5px,
      transparent 6.5px,
      transparent 14px
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)' opacity='0.35'/%3E%3C/svg%3E"),
    linear-gradient(155deg, var(--tsp-paper-base-a) 0%, var(--tsp-paper-base-b) 100%);
  background-size: auto, auto, auto, 160px 160px, 100% 100%;
  background-blend-mode: normal, multiply, soft-light, overlay, normal;
  border: 1px solid rgba(var(--color-accent-rgb), 0.28);
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(var(--color-accent-rgb), 0.16),
    inset 0 1px 0 rgba(252, 254, 255, 0.98),
    inset 0 0 80px rgba(255, 255, 255, 0.12);
}

.bw-testimonial-db.bw-testimonial--no-photo::before {
  color: #3d5266;
  top: -2.4rem;
  left: -1.2rem;
  font-size: clamp(11rem, 9rem + 8vw, 16rem);
  line-height: 0.66;
  text-shadow:
    0 1px 0 rgba(252, 254, 255, 1),
    0 1px 3px rgba(15, 23, 42, 0.05);
}

.bw-testimonial-db.bw-testimonial--no-photo .bw-testimonial-db__name {
  color: #0f172a;
}

.bw-testimonial-db.bw-testimonial--no-photo .bw-testimonial-db__quote {
  color: #334155;
}

.bw-testimonial-db.bw-testimonial--no-photo .bw-testimonial-db__quote mark {
  background: color-mix(in srgb, rgb(var(--color-accent-rgb)) 40%, #cbd5e1 60%);
  color: #0a0f18;
  font-weight: 600;
  border-radius: 3px;
  padding: 0.06em 0.2em;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.youtube-comment-text {
  white-space: pre-line;
}

@media (min-width: 640px) {
  .bw-testimonial-db {
    padding: 1.625rem 1.625rem 1.5rem;
    border-radius: 20px;
  }

  .bw-testimonial-db::before {
    top: 0.05rem;
    left: 0.4rem;
  }

  .bw-testimonial-db__quote {
    font-size: 1rem;
    line-height: 1.6;
  }
}

.bw-testimonial-load-error {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.125rem;
  border-radius: 14px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(30, 30, 30, 0.92);
  color: rgba(252, 165, 165, 0.95);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ---------- Mount layout (stacked embeds) ---------- */

.bw-inline-007--hero-band .bw-youtube-comment-mount {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.bw-inline-007 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  overflow: visible;
}

.bw-inline-007 > .bw-youtube-comment-mount ~ .bw-youtube-comment-mount {
  margin-top: 0;
}

.bw-youtube-comment-mount {
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  overflow: visible;
}

@media (min-width: 640px) {
  .bw-youtube-comment-mount {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
  }
}

/* Async-hydrated cards: fade + lift in (youtube-testimonial-mount.js) */
.bw-testimonial-reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
}

.bw-testimonial-reveal.bw-testimonial-reveal--in {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .bw-testimonial-reveal {
    opacity: 1;
    transform: none;
  }

  .bw-testimonial-reveal.bw-testimonial-reveal--in {
    transition: none;
  }

  #__next .youtube-comment.bw-testimonial-reveal,
  #__next .youtube-comment.bw-testimonial-reveal.bw-testimonial-reveal--in {
    transition: box-shadow 220ms ease, filter 220ms ease;
  }
}

.bw-inline-008 {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 28px;
}

/* Injected by mount script for YouTube-style row */
.bw-inline-009 {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  align-self: center;
}

.bw-inline-010 {
  width: 20px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
}

.bw-inline-010 path:first-of-type {
  fill: #fff !important;
}

.bw-inline-010 path:last-of-type {
  fill: #000 !important;
}

/* ---------- YouTube-style cards (.youtube-comment) ---------- */

#__next .youtube-comment {
  border-radius: 5px !important;
  -webkit-border-radius: 5px !important;
  -moz-border-radius: 5px !important;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.48),
    0 2px 6px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 0 0 1px color-mix(in srgb, var(--color-accent) 18%, transparent),
    0 0 9px color-mix(in srgb, var(--color-accent) 26%, transparent),
    0 0 18px color-mix(in srgb, var(--color-accent) 12%, transparent) !important;
}

#__next .youtube-comment.bw-testimonial--no-photo {
  --tsp-paper-base-a: color-mix(in srgb, var(--color-accent) 10%, #f8fafc 90%);
  --tsp-paper-base-b: color-mix(in srgb, var(--color-accent) 14%, #edf4fa 86%);
  background-color: color-mix(in srgb, var(--color-accent) 12%, #f7fafc 88%) !important;
  background-image:
    radial-gradient(ellipse 120% 70% at 50% -5%, rgba(255, 255, 255, 0.65), transparent 52%),
    repeating-linear-gradient(
      95deg,
      rgba(15, 23, 42, 0.022) 0,
      transparent 0.5px,
      transparent 5px
    ),
    repeating-linear-gradient(
      8deg,
      transparent 0,
      transparent 6px,
      rgba(var(--color-accent-rgb), 0.04) 6px,
      rgba(var(--color-accent-rgb), 0.04) 6.5px,
      transparent 6.5px,
      transparent 14px
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)' opacity='0.35'/%3E%3C/svg%3E"),
    linear-gradient(155deg, var(--tsp-paper-base-a) 0%, var(--tsp-paper-base-b) 100%) !important;
  background-size: auto, auto, auto, 160px 160px, 100% 100% !important;
  background-blend-mode: normal, multiply, soft-light, overlay, normal !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid rgba(var(--color-accent-rgb), 0.28) !important;
  box-shadow:
    0 8px 26px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(var(--color-accent-rgb), 0.16),
    0 0 10px rgba(var(--color-accent-rgb), 0.11),
    inset 0 1px 0 rgba(252, 254, 255, 0.98),
    inset 0 0 72px rgba(255, 255, 255, 0.1) !important;
}

#__next .youtube-comment.bw-testimonial--no-photo .youtube-comment-username,
#__next .youtube-comment.bw-testimonial--no-photo .youtube-comment-text {
  color: #0f172a !important;
}

#__next .youtube-comment.bw-testimonial--no-photo .youtube-comment-text mark {
  background: color-mix(in srgb, rgb(var(--color-accent-rgb)) 40%, #cbd5e1 60%);
  color: #0a0f18;
  font-weight: 600;
  border-radius: 3px;
  padding: 0.06em 0.2em;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

#__next .youtube-comment.bw-testimonial--no-photo:hover {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(var(--color-accent-rgb), 0.18),
    0 0 12px rgba(var(--color-accent-rgb), 0.08),
    inset 0 1px 0 rgba(252, 254, 255, 0.98),
    inset 0 0 72px rgba(255, 255, 255, 0.1) !important;
}

.youtube-comment,
#__next .youtube-comment {
  transition: box-shadow 220ms ease, filter 220ms ease;
}

#__next .youtube-comment.bw-testimonial-reveal.bw-testimonial-reveal--in {
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms ease,
    filter 220ms ease;
}

.youtube-comment:hover,
#__next .youtube-comment:hover {
  box-shadow: none !important;
  filter: none !important;
}

@media screen and (max-width: 767px) {
  .youtube-comment {
    max-width: 100% !important;
    padding: 18px 16px !important;
    border-radius: 5px !important;
  }

  .bw-youtube-comment-mount {
    margin-top: 1rem !important;
    margin-bottom: 1rem !important;
  }
}
