/* ==========================================================================
   Single page comments — "Timeline" (comments design 4)
   A glowing rail joins the composer and every thread; threads are grouped by age.
   Markup: partials/single/anime/comments.php
   ========================================================================== */

.atv-tl {
    --tl-surface: rgba(255, 255, 255, 0.035);
    --tl-surface-2: rgba(255, 255, 255, 0.06);
    --tl-sunken: rgba(10, 11, 15, 0.4);
    --tl-line: rgba(255, 255, 255, 0.07);
    --tl-line-2: rgba(255, 255, 255, 0.12);
    --tl-text: #ffffff;
    --tl-text-2: #d8dbe2;
    --tl-muted: #8b92a1;
    --tl-ring: #16181f;
    --tl-accent: #f5b942;
    --tl-purple: #8b5cf6;
    --tl-danger: #ef7070;
    --tl-av: 48px;

    position: relative;
    padding: 30px 32px;
    border-radius: 28px;
    background: radial-gradient(600px 260px at 100% 0%, rgba(245, 185, 66, 0.08), transparent 70%), rgba(255, 255, 255, 0.02);
    border: 1px solid var(--tl-line);
    direction: rtl;
    color: var(--tl-text-2);
    font-size: 14px;
    line-height: 1.75;
}
#animetvApp.day .atv-tl {
    --tl-surface: #ffffff;
    --tl-surface-2: #f1f3f8;
    --tl-sunken: #f7f8fb;
    --tl-line: rgba(15, 23, 42, 0.08);
    --tl-line-2: rgba(15, 23, 42, 0.14);
    --tl-text: #0f172a;
    --tl-text-2: #334155;
    --tl-muted: #64748b;
    --tl-ring: #f4f6fb;
    background: radial-gradient(600px 260px at 100% 0%, rgba(245, 185, 66, 0.1), transparent 70%), #ffffff;
}
.atv-tl *,
.atv-tl *::before,
.atv-tl *::after {
    box-sizing: border-box;
}

/* ---------- Head ---------- */
.atv-tl-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-bottom: 26px;
}
.atv-tl .atv-tl-head h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--tl-text);
}
.atv-tl-count {
    font-size: 13px;
    color: var(--tl-muted);
}
.atv-tl-sort {
    margin-right: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--tl-muted);
}

/* ---------- Rail & nodes ---------- */
.atv-tl-flow {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.atv-tl-threads {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.atv-tl-thread {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.atv-tl-thread.is-cm-hidden {
    display: none;
}
.atv-tl-rail {
    position: absolute;
    right: calc(var(--tl-av) / 2 - 1px);
    top: 10px;
    bottom: 10px;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg, rgba(245, 185, 66, 0.8), rgba(139, 92, 246, 0.6) 60%, rgba(139, 92, 246, 0));
}
.atv-tl-node {
    position: relative;
    display: flex;
    gap: 18px;
}
.atv-tl-dot {
    position: relative;
    z-index: 1;
    width: var(--tl-av);
    flex-shrink: 0;
    padding-top: 4px;
    display: flex;
    justify-content: center;
}
.atv-tl-dot a {
    display: block;
}
.atv-tl-dot img,
.atv-tl-dot-empty {
    display: block;
    width: var(--tl-av);
    height: var(--tl-av);
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--tl-ring);
    box-shadow: 0 0 0 2px var(--tl-line-2);
}
.atv-tl-dot-empty {
    display: grid;
    place-items: center;
    background: var(--tl-surface-2);
    color: var(--tl-muted);
    box-shadow: 0 0 0 2px var(--tl-line-2);
}
.atv-tl-dot.is-admin img,
.is-composer .atv-tl-dot img {
    box-shadow: 0 0 0 2px var(--tl-accent), 0 0 22px rgba(245, 185, 66, 0.6);
}
.atv-tl-dot.is-vip img {
    box-shadow: 0 0 0 2px var(--tl-purple), 0 0 18px rgba(139, 92, 246, 0.5);
}
.atv-tl-dot.is-team img {
    box-shadow: 0 0 0 2px rgba(245, 185, 66, 0.6);
}

/* Age group markers */
.atv-tl-group {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 18px;
}
.atv-tl-group-dot {
    width: var(--tl-av);
    display: flex;
    justify-content: center;
}
.atv-tl-group-dot i {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tl-accent);
    box-shadow: 0 0 0 4px rgba(245, 185, 66, 0.18), 0 0 18px rgba(245, 185, 66, 0.8);
}
.atv-tl-group b {
    height: 28px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid rgba(245, 185, 66, 0.3);
    background: rgba(245, 185, 66, 0.1);
    color: #f5b942;
    font-size: 12px;
    font-weight: 700;
}
.atv-tl-group.is-old .atv-tl-group-dot i {
    background: var(--tl-purple);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18), 0 0 18px rgba(139, 92, 246, 0.8);
}
.atv-tl-group.is-old b {
    border-color: rgba(139, 92, 246, 0.35);
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}
#animetvApp.day .atv-tl-group b {
    color: #9a6200;
}
#animetvApp.day .atv-tl-group.is-old b {
    color: #6d28d9;
}

/* ---------- Cards ---------- */
.atv-tl-card {
    flex: 1;
    min-width: 0;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--tl-surface);
    border: 1px solid var(--tl-line);
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.atv-tl-node:not(.is-composer) .atv-tl-card:hover {
    transform: translateX(-4px);
    border-color: var(--tl-line-2);
    box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}
#animetvApp.day .atv-tl-node:not(.is-composer) .atv-tl-card:hover {
    box-shadow: 0 18px 40px -26px rgba(15, 23, 42, 0.35);
}
.atv-tl-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}
.atv-tl .atv-tl-name {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--tl-text);
    text-decoration: none;
}
.atv-tl a.atv-tl-name:hover {
    color: var(--tl-accent);
}
.atv-tl-time {
    font-size: 12px;
    color: var(--tl-muted);
}
.atv-tl-role {
    height: 20px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 800;
}
.atv-tl-role.is-admin {
    background: linear-gradient(180deg, #ffc964, #f0ab22);
    color: #1c1503;
    box-shadow: 0 0 12px rgba(245, 185, 66, 0.45);
}
.atv-tl-role.is-team {
    border: 1px solid rgba(245, 185, 66, 0.5);
    color: #f5b942;
}
.atv-tl-role.is-vip {
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid rgba(139, 92, 246, 0.45);
    color: #c4b5fd;
}
#animetvApp.day .atv-tl-role.is-team {
    color: #9a6200;
}
#animetvApp.day .atv-tl-role.is-vip {
    color: #6d28d9;
}
.atv-tl-text {
    margin-top: 6px;
    font-size: 14.5px;
    line-height: 2;
    color: var(--tl-text-2);
    overflow-wrap: anywhere;
}

/* Spoiler: blurred in place until opened */
.atv-tl-spoil {
    position: relative;
    margin-top: 6px;
}
.atv-tl-spoil .atv-tl-text {
    margin-top: 0;
    transition: filter 0.35s;
}
.atv-tl-spoil.is-locked {
    cursor: pointer;
}
.atv-tl-spoil.is-locked .atv-tl-text {
    filter: blur(6px);
    user-select: none;
}
.atv-tl-spoil-cover {
    position: absolute;
    inset: 0;
    margin: auto;
    width: max-content;
    max-width: 100%;
    height: 34px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid rgba(239, 112, 112, 0.45);
    background: rgba(22, 24, 31, 0.85);
    color: #fca5a5;
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: 0 0 24px -6px rgba(239, 112, 112, 0.55);
}
#animetvApp.day .atv-tl-spoil-cover {
    background: rgba(255, 255, 255, 0.92);
    color: #b91c1c;
}
.atv-tl-spoil.is-locked:focus-visible {
    outline: 2px solid var(--tl-accent);
    outline-offset: 4px;
    border-radius: 10px;
}

/* Replies */
.atv-tl-reply {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--tl-sunken);
    border: 1px solid var(--tl-line);
}
.atv-tl-reply.is-admin,
.atv-tl-reply.is-team {
    background: linear-gradient(135deg, rgba(245, 185, 66, 0.12), rgba(245, 185, 66, 0.03));
    border-color: rgba(245, 185, 66, 0.28);
}
.atv-tl-reply > img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.atv-tl-reply.is-admin > img {
    box-shadow: 0 0 14px rgba(245, 185, 66, 0.5);
}
.atv-tl-reply-body {
    flex: 1;
    min-width: 0;
}
.atv-tl-reply .atv-tl-name {
    font-size: 13.5px;
}
.atv-tl-reply .atv-tl-text {
    margin-top: 2px;
}

/* Actions */
.atv-tl-acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}
.atv-tl-acts.is-small {
    margin-top: 6px;
}
.atv-tl .atv-tl-pill {
    height: 30px;
    margin: 0;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid var(--tl-line-2);
    background: transparent;
    color: var(--tl-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.atv-tl .atv-tl-pill:hover {
    border-color: rgba(245, 185, 66, 0.5);
    color: var(--tl-text);
}
.atv-tl-acts.is-small .atv-tl-pill {
    height: 26px;
    padding: 0 9px;
}

/* ---------- Composer ---------- */
.atv-tl-composer {
    background: var(--tl-sunken);
    border-color: var(--tl-line-2);
    transition: border-color 0.25s, box-shadow 0.25s;
    scroll-margin-top: 110px; /* keeps the form clear of the fixed header when a reply button focuses it */
}
.atv-tl-composer:focus-within {
    border-color: rgba(245, 185, 66, 0.55);
    box-shadow: 0 0 0 4px rgba(245, 185, 66, 0.1), 0 0 40px -12px rgba(245, 185, 66, 0.5);
}
.atv-tl-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.atv-tl .atv-tl-composer textarea {
    display: block;
    width: 100%;
    min-height: 64px;
    max-height: 260px;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    box-shadow: none;
    resize: none;
    field-sizing: content; /* grows with the text where supported; scrolls past max-height elsewhere */
    scroll-margin-top: 150px;
    color: var(--tl-text);
    font: inherit;
    font-size: 14.5px;
    line-height: 2;
}
.atv-tl .atv-tl-composer textarea::placeholder {
    color: var(--tl-muted);
}
.atv-tl-compose-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.atv-tl .atv-tl-check {
    height: 32px;
    margin: 0;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    border: 1px solid var(--tl-line-2);
    color: var(--tl-text-2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.atv-tl .atv-tl-check input {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    border-radius: 5px;
    border: 1.5px solid var(--tl-line-2);
    background: transparent;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}
.atv-tl .atv-tl-check input:checked {
    border-color: #f5b942;
    background: #f5b942;
}
.atv-tl .atv-tl-check.is-spoil input:checked {
    border-color: #ef7070;
    background: #ef7070;
}
.atv-tl .atv-tl-check input:checked::after {
    content: "";
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 4px;
    height: 8px;
    border: solid #1c1503;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.atv-tl .atv-tl-check input:focus-visible {
    outline: 2px solid var(--tl-accent);
    outline-offset: 2px;
}
.atv-tl-check:has(input:checked) {
    border-color: rgba(245, 185, 66, 0.55);
    color: var(--tl-text);
}
.atv-tl-check.is-spoil:has(input:checked) {
    border-color: rgba(239, 112, 112, 0.55);
}
.atv-tl .atv-tl-send {
    margin-right: auto;
    height: 40px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffc964, #f0ab22);
    color: #1c1503;
    font: inherit;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 26px -10px rgba(245, 185, 66, 0.8);
    transition: transform 0.2s;
}
.atv-tl .atv-tl-send:hover {
    transform: translateY(-1px);
}
.atv-tl-replying {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(245, 185, 66, 0.1);
    border: 1px solid rgba(245, 185, 66, 0.3);
    font-size: 12.5px;
    color: var(--tl-text-2);
}
.atv-tl-replying strong {
    color: var(--tl-text);
}
.atv-tl .atv-tl-replying button {
    margin-right: auto;
    border: 0;
    background: transparent;
    color: var(--tl-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

/* ---------- Empty & load more ---------- */
.atv-tl-empty {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.atv-tl-empty strong {
    font-size: 14.5px;
    color: var(--tl-text);
}
.atv-tl-empty span {
    font-size: 13px;
    color: var(--tl-muted);
}
.atv-tl-more {
    align-items: center;
}
.atv-tl .atv-tl-more-btn {
    height: 44px;
    margin: 0;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border-radius: 999px;
    border: 1px solid var(--tl-line-2);
    background: var(--tl-surface);
    color: var(--tl-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.atv-tl .atv-tl-more-btn:hover {
    border-color: rgba(245, 185, 66, 0.5);
    box-shadow: 0 0 24px -8px rgba(245, 185, 66, 0.5);
}
.atv-tl-more-badge {
    font-size: 12px;
    color: var(--tl-muted);
    font-weight: 600;
}

.atv-tl a:focus-visible,
.atv-tl button:focus-visible {
    outline: 2px solid var(--tl-accent);
    outline-offset: 2px;
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
    .atv-tl {
        --tl-av: 38px;
        padding: 20px 14px;
        border-radius: 22px;
    }
    .atv-tl-node,
    .atv-tl-group {
        gap: 10px;
    }
    .atv-tl-card {
        padding: 13px 12px;
    }
    /* Replies: small avatar beside the name, text runs the full width of the reply box */
    .atv-tl-reply {
        display: grid;
        grid-template-columns: 26px minmax(0, 1fr);
        align-items: center;
        column-gap: 8px;
        padding: 10px;
    }
    .atv-tl-reply > img {
        width: 26px;
        height: 26px;
    }
    .atv-tl-reply-body {
        display: contents;
    }
    .atv-tl-reply .atv-tl-text,
    .atv-tl-reply .atv-tl-spoil,
    .atv-tl-reply .atv-tl-acts {
        grid-column: 1 / -1;
    }
    .atv-tl .atv-tl-send {
        width: 100%;
        margin-right: 0;
    }
    .atv-tl-sort {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atv-tl-card,
    .atv-tl-spoil .atv-tl-text {
        transition: none;
    }
}
