/*
 * ============================================================
 * TESTIMONIALS — homepage "رضایت مشتری" section
 * A row of circular story avatars (css below) + a single shared full-
 * screen story viewer (markup lives once in index.html, content swapped
 * by js/testimonials.js). This component's "own small visual personality"
 * comes from its shape language (circles, segmented progress bars, a
 * per-testimonial ring color) rather than any new type system.
 *
 * The ring color is one of five tones defined below, scoped to this
 * component only (never added to css/tokens.css — this palette has no
 * other use on the site) — a dark-teal family anchored on #264D59, plus
 * one restrained warm complementary tone, deliberately controlled, never
 * a free/rainbow palette. js/testimonials.js assigns one, deterministically,
 * by hashing each testimonial's own id — every testimonial keeps the same
 * color forever regardless of list order, and the row is automatically a
 * coordinated set for 2 testimonials or 50, with nothing for an admin to
 * configure per person.
 * ============================================================
 */

:root {
    --ring-teal:            #2F6E73;
    --ring-teal-soft:       rgba(47, 110, 115, 0.18);
    --ring-deep-teal:       #264D59;
    --ring-deep-teal-soft:  rgba(38, 77, 89, 0.2);
    --ring-blue-green:      #3B6B63;
    --ring-blue-green-soft: rgba(59, 107, 99, 0.18);
    --ring-navy:            #1D3A47;
    --ring-navy-soft:       rgba(29, 58, 71, 0.2);
    --ring-sand:            #A9825A;
    --ring-sand-soft:       rgba(169, 130, 90, 0.18);
}
[data-theme="dark"] {
    /* Same family, lifted a touch so each still reads as distinctly
       colored against the theme's very dark navy surfaces instead of
       collapsing toward black. */
    --ring-teal:       #3E8A8F;
    --ring-deep-teal:  #35707F;
    --ring-blue-green: #4F857B;
    --ring-navy:       #2E5164;
    --ring-sand:       #C79A68;
}

.testimonials-section {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 24px 72px;
}

/* ---- Avatar row ----
   A horizontal row, never a card grid, at every width — see the responsive
   block at the bottom of this file for how spacing/size adapt. Controlled
   horizontal scroll (native, momentum-enabled, snap-assisted) is the one
   and only overflow strategy from desktop down to mobile — it's also
   exactly the native "swipe through stories" gesture this component's
   Instagram-story-viewer model is already built on, so it reads as
   intentional at every breakpoint rather than "content got cut off." */
.testimonial-avatars {
    display: flex;
    /* flex-start would be the initial value anyway, but stating it
       explicitly is the point: every item is top-anchored on purpose (see
       .testimonial-avatar-name below for why one item can be visually
       taller than another without ever moving any ring), never stretched
       to a shared row height. */
    align-items: flex-start;
    /* "safe" is the operative word: centers the row when it's narrower
       than the container (the "keep a few testimonials centered, not
       shoved to one side" requirement) but automatically falls back to
       start-alignment the moment content actually overflows, so nothing
       ever becomes unreachable at the scroll-start edge the way plain
       `center` can with an overflowing flex row. */
    justify-content: safe center;
    gap: 22px;
    overflow-x: auto;
    padding: 10px 4px 18px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.testimonial-avatars::-webkit-scrollbar { display: none; }

.testimonial-avatar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Tighter than the footer's team-member cards (10px, around a much
       larger 62px avatar + two lines of text) — at this component's
       smaller, denser scale a tighter gap is what actually reads as "the
       name belongs to this circle" instead of a caption floating
       independently underneath it. */
    gap: 9px;
    width: 100px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    scroll-snap-align: start;
}
.testimonial-avatar-ring {
    /* One of five controlled ring tokens — see this file's own header
       comment. Solid, not a conic-gradient sweep: a restrained flat ring
       reads as "this person's own color" without a busier, more decorative
       multi-stop gradient competing with the photo it frames — the calmer
       choice the "premium/restrained" direction calls for. --ring-soft
       backs the hover/active glow below. Defaults to the first palette
       tone; js/testimonials.js's `data-accent` below picks one of the
       other four.
       A real `border` draws the ring — not a background-color circle with
       a second, separately-sized inner circle stacked on top of it. Two
       concentric circles built from independently-sized elements is a
       fragile pattern (their sizes have to resolve in perfect agreement
       for the ring to stay centered on the photo); a border is drawn by
       the browser as a single uniform band around this element's own
       edge, so it is architecturally impossible for the ring to end up
       off-center from the photo it frames — there is only one circle. */
    --ring-color: var(--ring-teal);
    --ring-soft: var(--ring-teal-soft);
    display: block;
    box-sizing: border-box;
    position: relative;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 3px solid var(--ring-color);
    /* The small breathing-room gap between the ring and the photo —
       this element's own padding + background, not a second nested
       circle. */
    padding: 2.5px;
    background-color: var(--bg-base);
    /* A restrained shadow even at rest (not only on hover) — tinted with
       the anchor tone rather than a generic gray, so it reads as this
       ring's own soft cast shadow instead of a bolted-on generic card
       elevation. */
    box-shadow: 0 3px 10px rgba(38, 77, 89, 0.16);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;
}
.testimonial-avatar[data-accent="deep-teal"]  .testimonial-avatar-ring { --ring-color: var(--ring-deep-teal); --ring-soft: var(--ring-deep-teal-soft); }
.testimonial-avatar[data-accent="blue-green"] .testimonial-avatar-ring { --ring-color: var(--ring-blue-green); --ring-soft: var(--ring-blue-green-soft); }
.testimonial-avatar[data-accent="navy"]       .testimonial-avatar-ring { --ring-color: var(--ring-navy); --ring-soft: var(--ring-navy-soft); }
.testimonial-avatar[data-accent="sand"]       .testimonial-avatar-ring { --ring-color: var(--ring-sand); --ring-soft: var(--ring-sand-soft); }

/* Subtle hover enhancement, interaction-only (never a continuous/looping
   animation) — a light lift plus a soft glow tinted with this avatar's own
   ring color. Transform/shadow only, so nothing here ever reflows a
   neighboring item. */
.testimonial-avatar:hover .testimonial-avatar-ring,
.testimonial-avatar:focus-visible .testimonial-avatar-ring {
    transform: translateY(-2px);
    box-shadow: 0 0 0 6px var(--ring-soft), 0 6px 16px rgba(38, 77, 89, 0.2);
}
/* The currently-open testimonial in the story viewer — see
   js/testimonials.js's setActiveAvatar(). Slightly larger (scale, not a
   width/height change, so — like hover — it never moves any other item)
   plus a stronger persistent glow and a bolder name, clearly distinct from
   the momentary hover state above. */
.testimonial-avatar.is-active .testimonial-avatar-ring {
    transform: scale(1.08);
    box-shadow: 0 0 0 5px var(--ring-soft), 0 8px 20px rgba(38, 77, 89, 0.24);
}
.testimonial-avatar.is-active .testimonial-avatar-name {
    color: var(--ring-color);
    font-weight: 800;
}
@media (prefers-reduced-motion: reduce) {
    .testimonial-avatar-ring { transition: box-shadow 0.2s ease; }
    .testimonial-avatar:hover .testimonial-avatar-ring,
    .testimonial-avatar:focus-visible .testimonial-avatar-ring,
    .testimonial-avatar.is-active .testimonial-avatar-ring { transform: none; }
}
.testimonial-avatar-media {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    /* Neutral, not a gradient — this only ever shows once a real photo
       fails to cover it (a plain-initials fallback, see
       .testimonial-avatar-initial), and a clean neutral surface is what
       "not a face, not a decoration" actually calls for. */
    background-color: var(--color-surface-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
}
.testimonial-avatar-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.testimonial-avatar-initial {
    color: var(--ink-soft);
    font-family: var(--font-display-fa);
    font-weight: 800;
    font-size: 20px;
}

/* ---- Content-type badge ----
   A small, subtle corner indicator (text/image/video/audio — js/
   testimonials.js's TYPE_ICONS) reusing the ring's own accent color via
   the inherited --ring-color custom property, so it reads as "part of
   this avatar" rather than a separately-colored sticker. Decorative
   (aria-hidden in the markup) — the avatar button's own aria-label
   already names the person; this is a supplementary visual cue only. */
.testimonial-avatar-type {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--color-surface);
    border: 2px solid var(--bg-base);
    color: var(--ring-color);
    display: flex;
    align-items: center;
    justify-content: center;
    /* A hint of its own shadow rather than a heavier border — keeps this
       reading as a small floating badge, not a competing second circle. */
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.testimonial-avatar.is-active .testimonial-avatar-type,
.testimonial-avatar:hover .testimonial-avatar-type,
.testimonial-avatar:focus-visible .testimonial-avatar-type { transform: scale(1.08); }
@media (prefers-reduced-motion: reduce) {
    .testimonial-avatar-type { transition: none; }
    .testimonial-avatar.is-active .testimonial-avatar-type,
    .testimonial-avatar:hover .testimonial-avatar-type,
    .testimonial-avatar:focus-visible .testimonial-avatar-type { transform: none; }
}
.testimonial-avatar-type svg { width: 10px; height: 10px; }
.testimonial-avatar-name {
    /* Explicit, not inherited: this is an identity label (same role as the
       team-member names in the footer's h4, css/footer.css), not a run of
       body copy — even though --font-display-fa and --font-body currently
       resolve to the same family, naming the intent here is what keeps
       this correct if that ever changes. */
    font-family: var(--font-display-fa);
    font-size: 13px;
    font-weight: 700;
    /* The single biggest fix here: full --ink (the same primary text color
       the footer's team-card h4 uses), not --ink-soft. --ink-soft is a
       tertiary/de-emphasized tone — reasonable for a caption, wrong for a
       person's own name, which is exactly what read as "weak" before. */
    color: var(--ink);
    line-height: 1.3;
    text-align: center;
    max-width: 100%;
    /* Wraps to up to two lines instead of truncating with an ellipsis — a
       real Persian full name (e.g. "علیرضا قنادیان") should stay fully
       readable, never cut off mid-word. min-height reserves that same
       two-line space for EVERY item regardless of how many lines its own
       name actually needs, so a short one-word name and a long two-word
       one still leave their avatar rings sitting at identical heights —
       the "every item occupies the same logical vertical space" fix,
       done structurally rather than with a per-item margin correction. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: 2.6em;
    transition: color 0.3s ease, font-weight 0.3s ease;
    /* No letter-spacing adjustment on purpose: Kalameh is a joining Perso-
       Arabic script, and any nonzero letter-spacing breaks the visual
       connection between adjacent letterforms — correct here even though
       Latin-style headline type would normally tighten tracking at this
       weight. */
}

/* ---- Story viewer overlay ---- */
.testimonial-viewer {
    position: fixed;
    inset: 0;
    /* Above the floating header pill (z-index:1000) and back-to-top button
       (900) — the story viewer must always be the topmost layer while open. */
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.testimonial-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 30, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.testimonial-viewer-stage {
    position: relative;
    z-index: 1;
    width: min(420px, 94vw);
    height: min(760px, 92vh);
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: scale(0.94);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}
.testimonial-viewer.is-open .testimonial-viewer-stage { transform: scale(1); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .testimonial-viewer-stage { transition: opacity 0.15s ease; transform: none; }
}

.testimonial-viewer-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    gap: 5px;
}
.testimonial-viewer-progress-seg {
    flex: 1;
    height: 3px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.28);
    overflow: hidden;
}
.testimonial-viewer-progress-seg-fill {
    height: 100%;
    width: 0%;
    background: #FFFFFF;
    border-radius: var(--radius-pill);
}
.testimonial-viewer-progress-seg.is-done .testimonial-viewer-progress-seg-fill { width: 100%; }
.testimonial-viewer-progress-seg.is-active .testimonial-viewer-progress-seg-fill {
    animation: testimonialSegFill var(--seg-duration, 5s) linear forwards;
}
@keyframes testimonialSegFill { from { width: 0%; } to { width: 100%; } }
@media (prefers-reduced-motion: reduce) {
    .testimonial-viewer-progress-seg.is-active .testimonial-viewer-progress-seg-fill { animation: none; width: 55%; }
}

.testimonial-viewer-head {
    position: absolute;
    top: 22px;
    left: 12px;
    right: 12px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.testimonial-viewer-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.testimonial-viewer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--grad-btn-start), var(--grad-btn-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
    font-family: var(--font-display-fa);
    overflow: hidden;
}
.testimonial-viewer-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.testimonial-viewer-identity-text { display: flex; flex-direction: column; min-width: 0; }
.testimonial-viewer-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #FFFFFF;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.testimonial-viewer-meta {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.testimonial-viewer-close {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.28);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.testimonial-viewer-close:hover { background: rgba(0, 0, 0, 0.45); }
.testimonial-viewer-close svg { width: 17px; height: 17px; }

.testimonial-viewer-body {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--primary-navy-dark, #111A2E), var(--primary-navy));
    overflow: hidden;
}
.testimonial-viewer-body img.testimonial-page-image,
.testimonial-viewer-body video.testimonial-page-video {
    animation: testimonialPageIn 0.4s ease both;
}
.testimonial-viewer-body img.testimonial-page-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* object-fit:contain (not cover, unlike the image page above) — a video's
   aspect ratio is whatever the student happened to record, and cropping
   into it the way a curated photo can tolerate risks cutting the person
   out of their own frame. Letterboxed against this same panel's own navy
   gradient (not black) so the bars stay on-brand rather than reading as a
   broken player. */
.testimonial-viewer-body video.testimonial-page-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}
@media (prefers-reduced-motion: reduce) {
    .testimonial-viewer-body img.testimonial-page-image,
    .testimonial-viewer-body video.testimonial-page-video { animation: none; }
}
@keyframes testimonialPageIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: scale(1); } }

.testimonial-page-caption {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 20px 20px 26px;
    background: linear-gradient(0deg, rgba(0,0,0,0.72), transparent);
    color: #FFFFFF;
    font-size: 14px;
    line-height: 1.9;
    text-align: right;
}

.testimonial-text-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 32px;
    text-align: center;
}
.testimonial-text-page p {
    color: #FFFFFF;
    font-family: var(--font-display-fa);
    font-size: 19px;
    font-weight: 600;
    line-height: 2;
}

/* ---- Custom audio player (no native controls anywhere) ---- */
.testimonial-audio-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 40px;
}
.testimonial-audio-art {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--grad-btn-start), var(--grad-btn-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.testimonial-audio-art svg { width: 44px; height: 44px; }
.testimonial-audio-art.is-playing { animation: testimonialAudioPulse 1.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
    .testimonial-audio-art.is-playing { animation: none; }
}
@keyframes testimonialAudioPulse {
    0%, 100% { box-shadow: 0 20px 40px rgba(0,0,0,0.3), 0 0 0 0 rgba(255,255,255,0.18); }
    50% { box-shadow: 0 20px 40px rgba(0,0,0,0.3), 0 0 0 14px rgba(255,255,255,0); }
}
.testimonial-audio-player { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.testimonial-audio-controls { display: flex; align-items: center; gap: 12px; }
.testimonial-audio-playbtn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #FFFFFF;
    color: var(--primary-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.testimonial-audio-playbtn svg { width: 18px; height: 18px; }
.testimonial-audio-seek {
    flex: 1;
    height: 4px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
    cursor: pointer;
}
.testimonial-audio-seek-fill { height: 100%; width: 0%; background: #FFFFFF; border-radius: var(--radius-pill); }
.testimonial-audio-time { font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,0.7); text-align: center; }

/* ---- Invisible tap zones for prev/next (mirrors Instagram's screen-side tap navigation, independent of RTL reading direction) ---- */
.testimonial-viewer-tap {
    position: absolute;
    top: 60px;
    bottom: 0;
    width: 34%;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}
.testimonial-viewer-tap.is-prev { left: 0; }
.testimonial-viewer-tap.is-next { right: 0; }
/* Video pages get a real native control bar at the very bottom (see
   js/testimonials.js's renderVideoPage()) — pull the tap zones' bottom
   edge up above it, js/testimonials.js toggles this class per active
   page, so the controls stay reachable instead of sitting under an
   invisible nav button. */
.testimonial-viewer.is-video-page .testimonial-viewer-tap { bottom: 46px; }

/* ---- Desktop: generous row spacing (not a card grid — see this file's
   header comment) with a subtle active-state enhancement already handled
   above via :hover/:focus-visible. ---- */
@media (min-width: 992px) {
    .testimonial-avatars { gap: 38px; padding: 10px 4px 20px; }
}

@media (max-width: 640px) {
    .testimonials-section { padding: 32px 16px 56px; }
    .testimonial-viewer-stage { width: 100vw; height: 100vh; border-radius: 0; }
}

.testimonial-all { margin: 22px 0 0; text-align: center; }
.testimonial-all-link { font-size: 14px; font-weight: 800; color: var(--accent-gold); text-decoration: none; }
.testimonial-all-link:hover { text-decoration: underline; text-underline-offset: 5px; }
