/* ==========================================================================
   PrimeItWorld — TTS Audio Player
   Reference: dark rounded card, large square thumb on the left,
              title + wave on top-right, times, progress, control row.
   Variants: pitw-tts-design-1 (Black default) .. pitw-tts-design-5
   ========================================================================== */

.pitw-tts { margin: 18px 0 22px; font-family: inherit; }
.pitw-tts * { box-sizing: border-box; }

/* Desktop: nicely constrained. Mobile: full width with side breathing. */
.pitw-tts-inner {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 5px;
    border-radius: 10px;
    background: #111214;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 18px 40px -18px rgba(0,0,0,0.55);
    max-width: 560px;
    margin: 0 auto;
}

/* Thumb — square on the left, matches player height */
.pitw-tts-thumb {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #000;
}
.pitw-tts-thumb img { width:100%; height:100%; object-fit:cover; display:block; }

/* Right side */
.pitw-tts-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    padding: 0 2px;
}

/* Top row: title + wave */
.pitw-tts-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 18px;
}
.pitw-tts-title {
    flex: 1 1 auto;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}
.pitw-tts-title-track {
    display: inline-block;
    min-width: 100%;
}
.pitw-tts-title.pitw-tts-title-scroll .pitw-tts-title-track {
    padding-left: 100%;
    animation: pitwTtsTitleMarquee var(--pitw-title-duration, 14s) linear infinite;
}
@keyframes pitwTtsTitleMarquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* Wave — real audio-recorder style: many thin bars, each with its own
   base height and animation delay for an organic waveform look. */
.pitw-tts-wave {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 16px;
    color: currentColor;
    opacity: .95;
}
.pitw-tts-wave span {
    display:block;
    width:2px;
    height:6px;
    border-radius:2px;
    background: currentColor;
    opacity:.55;
    transform-origin: center;
    animation: pitwTtsWave 1.1s ease-in-out infinite;
    animation-play-state: paused;
}
.pitw-tts.pitw-tts-playing .pitw-tts-wave span {
    animation-play-state: running;
    opacity:.95;
}
/* Per-bar base height + delay → organic waveform */
.pitw-tts-wave span:nth-child(1) { height: 40%; animation-delay: 0s; }
.pitw-tts-wave span:nth-child(2) { height: 65%; animation-delay: .08s; }
.pitw-tts-wave span:nth-child(3) { height: 90%; animation-delay: .16s; }
.pitw-tts-wave span:nth-child(4) { height: 55%; animation-delay: .24s; }
.pitw-tts-wave span:nth-child(5) { height: 75%; animation-delay: .32s; }
.pitw-tts-wave span:nth-child(6) { height: 100%; animation-delay: .12s; }
.pitw-tts-wave span:nth-child(7) { height: 45%; animation-delay: .20s; }
.pitw-tts-wave span:nth-child(8) { height: 80%; animation-delay: .28s; }
.pitw-tts-wave span:nth-child(9) { height: 60%; animation-delay: .04s; }
.pitw-tts-wave span:nth-child(10){ height: 92%; animation-delay: .18s; }
.pitw-tts-wave span:nth-child(11){ height: 50%; animation-delay: .26s; }
.pitw-tts-wave span:nth-child(12){ height: 70%; animation-delay: .10s; }
.pitw-tts-wave span:nth-child(13){ height: 35%; animation-delay: .22s; }
.pitw-tts-wave span:nth-child(14){ height: 85%; animation-delay: .06s; }
@keyframes pitwTtsWave {
    0%, 100% { transform: scaleY(.35); }
    50% { transform: scaleY(1.15); }
}

/* Times */
.pitw-tts-times {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    opacity: .85;
    padding: 0 2px;
}

/* Progress */
.pitw-tts-progress {
    position: relative;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
    cursor: pointer;
    overflow: visible;
}
.pitw-tts-progress-bar {
    position:absolute; top:0; bottom:0; left:0;
    width:0%;
    background:#ffffff;
    border-radius:999px;
    transition: width .12s linear;
}
.pitw-tts-progress-bar::after {
    content:'';
    position:absolute; right:-6px; top:50%;
    transform: translateY(-50%);
    width:12px; height:12px; border-radius:50%;
    background:#fff;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}

/* Controls */
.pitw-tts-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding-top: 0;
}
.pitw-tts-controls button {
    background: transparent; border: 0; margin: 0;
    padding: 6px;
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: inherit; cursor: pointer;
    border-radius: 999px;
    transition: transform .15s ease, background .2s ease;
    line-height: 1;
}
.pitw-tts-controls button:hover { background: rgba(255,255,255,.08); }
.pitw-tts-controls button:active { transform: scale(0.94); }
.pitw-tts-controls svg { display:block; }

/* Speed pill */
.pitw-tts-speed { gap:2px; padding: 4px 6px !important; }
.pitw-tts-speed-label {
    font-size: 11px;
    font-weight: 700;
    margin-top: 2px;
    opacity: .9;
}

/* Big play button */
.pitw-tts-play {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    color: #111214 !important;
    box-shadow: 0 8px 20px -6px rgba(255,255,255,0.25);
}
.pitw-tts-play:hover { transform: scale(1.05); background:#ffffff !important; }

/* ============ Design 1 — Black (Default) ============ */
.pitw-tts-design-1 .pitw-tts-inner { background:#111214; color:#fff; }
.pitw-tts-design-1 .pitw-tts-progress-bar { background:#ffffff; }
.pitw-tts-design-1 .pitw-tts-play { background:#ffffff !important; color:#111214 !important; }
.pitw-tts-design-1 .pitw-tts-wave { color:#ffffff; }

/* ============ Design 2 — Crimson ============ */
.pitw-tts-design-2 .pitw-tts-inner {
    background: linear-gradient(135deg,#3b0a12,#7a0f22);
    border-color: rgba(255,255,255,0.08);
}
.pitw-tts-design-2 .pitw-tts-progress-bar { background:#ff3e51; }
.pitw-tts-design-2 .pitw-tts-progress-bar::after { background:#ff3e51; }
.pitw-tts-design-2 .pitw-tts-play { background:#ff3e51 !important; color:#fff !important; box-shadow:0 8px 20px -6px rgba(255,62,81,.55); }
.pitw-tts-design-2 .pitw-tts-wave { color:#ffb3bc; }

/* ============ Design 3 — Emerald ============ */
.pitw-tts-design-3 .pitw-tts-inner {
    background: linear-gradient(135deg,#052e1f,#0b6b45);
    border-color: rgba(255,255,255,0.08);
}
.pitw-tts-design-3 .pitw-tts-progress-bar { background:#34d399; }
.pitw-tts-design-3 .pitw-tts-progress-bar::after { background:#34d399; }
.pitw-tts-design-3 .pitw-tts-play { background:#10b981 !important; color:#062e21 !important; box-shadow:0 8px 20px -6px rgba(16,185,129,.55); }
.pitw-tts-design-3 .pitw-tts-wave { color:#a7f3d0; }

/* ============ Design 4 — Ocean Blue ============ */
.pitw-tts-design-4 .pitw-tts-inner {
    background: linear-gradient(135deg,#0b2447,#19376d);
    border-color: rgba(255,255,255,0.08);
}
.pitw-tts-design-4 .pitw-tts-progress-bar { background:#38bdf8; }
.pitw-tts-design-4 .pitw-tts-progress-bar::after { background:#38bdf8; }
.pitw-tts-design-4 .pitw-tts-play { background:#38bdf8 !important; color:#0b2447 !important; box-shadow:0 8px 20px -6px rgba(56,189,248,.55); }
.pitw-tts-design-4 .pitw-tts-wave { color:#bae6fd; }

/* ============ Design 5 — Violet ============ */
.pitw-tts-design-5 .pitw-tts-inner {
    background: linear-gradient(135deg,#2a0e4a,#5b21b6);
    border-color: rgba(255,255,255,0.08);
}
.pitw-tts-design-5 .pitw-tts-progress-bar { background:#c4b5fd; }
.pitw-tts-design-5 .pitw-tts-progress-bar::after { background:#c4b5fd; }
.pitw-tts-design-5 .pitw-tts-play { background:#a78bfa !important; color:#2a0e4a !important; box-shadow:0 8px 20px -6px rgba(167,139,250,.55); }
.pitw-tts-design-5 .pitw-tts-wave { color:#ddd6fe; }

/* ============ Design 6 — Slate Graphite (screenshot ref) ============ */
.pitw-tts-design-6 .pitw-tts-inner {
    background: linear-gradient(160deg,#2b2f36 0%, #1c1f24 55%, #14161a 100%);
    border-color: rgba(255,255,255,0.09);
    box-shadow: 0 20px 44px -18px rgba(0,0,0,0.7);
}
.pitw-tts-design-6 .pitw-tts-progress-bar { background:#e5e7eb; }
.pitw-tts-design-6 .pitw-tts-progress-bar::after { background:#e5e7eb; }
.pitw-tts-design-6 .pitw-tts-play { background:#f3f4f6 !important; color:#1c1f24 !important; box-shadow:0 8px 20px -6px rgba(243,244,246,.35); }
.pitw-tts-design-6 .pitw-tts-wave { color:#e5e7eb; }

/* Hide the raw json */
.pitw-tts-text { display: none; }

/* Mobile tuning: keep the same composition, just tighter */
@media (max-width: 640px) {
    .pitw-tts { margin: 8px 0 12px; }
    .pitw-tts-inner { gap: 7px; padding: 4px 5px; border-radius: 10px; max-width: 100%; }
    .pitw-tts-thumb { flex-basis: 48px; width: 48px; height: 48px; border-radius: 7px; }
    .pitw-tts-title { font-size: 13px; }
    .pitw-tts-play { width: 30px !important; height: 30px !important; }
    .pitw-tts-controls button { padding: 2px 3px; }
    .pitw-tts-controls svg { width: 16px; height: 16px; }
    .pitw-tts-times { font-size: 10px; }
    .pitw-tts-wave { height: 13px; }
    .pitw-tts-speed-label { font-size: 10px; }
}
@media (max-width: 380px) {
    .pitw-tts-thumb { flex-basis: 54px; width: 54px; height: 54px; }
    .pitw-tts-title { font-size: 13px; }
    .pitw-tts-wave span:nth-child(n+11) { display: none; }
}

/* ==========================================================================
   Floating bottom position — post pages only
   ========================================================================== */
.pitw-tts {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 6px;
    z-index: 9998;
    margin: 0;
    padding: 0 10px;
    pointer-events: none;
}
.pitw-tts .pitw-tts-inner {
    pointer-events: auto;
    margin: 0 auto;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,0.65);
}

/* Mobile: no bottom nav on post pages, so sit near the very bottom */
@media (max-width: 991px) {
    .pitw-tts { bottom: 6px; padding: 0 22px; }
    body.pitw-has-tts-floating { padding-bottom: 80px; }
}
@media (min-width: 992px) {
    .pitw-tts { padding: 0 24px; }
    body.pitw-has-tts-floating { padding-bottom: 96px; }
}

/* Smooth slide-up entrance on post pages */
.pitw-tts {
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.55s cubic-bezier(0.22, 0.9, 0.32, 1),
                opacity 0.45s ease-out;
    will-change: transform, opacity;
}
.pitw-tts.pitw-tts-in {
    transform: translateY(0);
    opacity: 1;
}
