/* ───────────────────────────────────────────────────────────
   Teachers carousel — shared by the landing page (index.html)
   and the /teachers manager preview. Rendered by
   js/teachers-section.js. Tokens fall back to the landing palette
   so the component also looks right outside styles.css.
   ─────────────────────────────────────────────────────────── */
.tch {
    --tch-primary: var(--primary, #6366f1);
    --tch-text: var(--text-main, #0f172a);
    --tch-muted: var(--text-muted, #64748b);
    --tch-card-w: 272px;
    --tch-gap: 24px;
    --tch-bleed: 24px; /* matches .container side padding */
    position: relative;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

@media (max-width: 768px) {
    .tch {
        --tch-card-w: min(76vw, 300px);
        --tch-gap: 14px;
        --tch-bleed: 16px;
    }
}

.tch-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* bleed to the screen edge so cards slide off-screen, not into a hard border */
    margin: 0 calc(-1 * var(--tch-bleed));
    padding: 12px var(--tch-bleed) 28px;
    scroll-padding: 0 var(--tch-bleed);
}

.tch-viewport::-webkit-scrollbar {
    display: none;
}

.tch-track {
    display: flex;
    gap: var(--tch-gap);
    align-items: flex-start;
    width: max-content;
    margin: 0 auto; /* centres the row when everything fits */
}

/* ── Expanded ("show all") mode ───────────────────────────── */
.tch.is-grid .tch-viewport {
    overflow: visible;
    scroll-snap-type: none;
}

.tch.is-grid .tch-track {
    display: grid;
    width: auto;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 28px var(--tch-gap);
}

@media (max-width: 520px) {
    .tch.is-grid .tch-track {
        grid-template-columns: 1fr 1fr;
        gap: 18px 12px;
    }

    .tch.is-grid .tch-desc {
        -webkit-line-clamp: 3;
        font-size: 0.85rem;
    }

    .tch.is-grid .tch-body {
        padding: 12px 4px 0;
    }

    .tch.is-grid .tch-play {
        width: 46px;
        height: 46px;
    }
}

/* ── Card ─────────────────────────────────────────────────── */
.tch-card {
    flex: 0 0 var(--tch-card-w);
    width: var(--tch-card-w);
    scroll-snap-align: start;
    text-align: left;
    color: var(--tch-text);
}

.tch.is-grid .tch-card {
    width: auto;
}

.tch-media {
    position: relative;
    aspect-ratio: 4 / 5;
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(160deg, #e0e7ff, #f1f5f9);
    box-shadow: 0 10px 30px -12px rgba(31, 38, 135, 0.28);
    isolation: isolate;
    transition: transform 0.35s var(--ease-fluid, ease), box-shadow 0.35s var(--ease-fluid, ease);
}

@media (hover: hover) {
    .tch-card:hover .tch-media {
        transform: translateY(-4px);
        box-shadow: 0 18px 40px -14px rgba(31, 38, 135, 0.38);
    }
}

.tch-poster,
.tch-media video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    border: 0;
}

.tch-media video {
    background: #000;
    z-index: 2;
}

.tch-media::after {
    /* soft bottom shade so the duration chip always reads */
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 30%;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.35), transparent);
    z-index: 1;
    pointer-events: none;
}

.tch-play {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tch-play-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--tch-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    transition: transform 0.25s var(--ease-bounce, ease);
}

.tch-play-icon svg {
    width: 22px;
    height: 22px;
    margin-left: 3px;
}

.tch-play:hover .tch-play-icon,
.tch-play:focus-visible .tch-play-icon {
    transform: scale(1.1);
}

.tch-play:focus-visible {
    outline: 3px solid var(--tch-primary);
    outline-offset: -3px;
    border-radius: 24px;
}

.tch-duration {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 1;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.tch-body {
    padding: 16px 6px 0;
}

.tch-name {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--tch-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tch-flag {
    font-size: 1.15em;
    line-height: 1;
}

.tch-tagline {
    margin-top: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tch-primary);
}

.tch-desc {
    margin: 8px 0 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--tch-muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
}

.tch-card.is-open .tch-desc {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    display: block;
}

.tch-more {
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--tch-primary);
    cursor: pointer;
}

.tch-more[hidden] {
    display: none;
}

/* ── Arrows ───────────────────────────────────────────────── */
.tch-nav {
    position: absolute;
    /* vertically centred on the video, not the whole card */
    top: calc(12px + var(--tch-card-w) * 5 / 8);
    transform: translateY(-50%);
    z-index: 5;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #fff;
    color: var(--tch-text);
    box-shadow: 0 8px 24px rgba(31, 38, 135, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.tch-nav:hover {
    transform: translateY(-50%) scale(1.06);
}

.tch-nav svg {
    width: 20px;
    height: 20px;
}

.tch-prev {
    left: -20px;
}

.tch-next {
    right: -20px;
}

.tch-nav:disabled {
    opacity: 0;
    pointer-events: none;
}

.tch:not(.has-overflow) .tch-nav,
.tch.is-grid .tch-nav {
    display: none;
}

@media (max-width: 768px), (hover: none) {
    .tch-nav {
        display: none;
    }
}

/* ── Footer: progress + show-all ──────────────────────────── */
.tch-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 4px;
}

.tch:not(.has-overflow):not(.is-grid) .tch-footer {
    display: none;
}

.tch-progress {
    position: relative;
    width: min(220px, 40vw);
    height: 4px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.15);
    overflow: hidden;
}

.tch-progress-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
    background: var(--tch-primary);
    transition: left 0.1s linear, width 0.1s linear;
}

.tch.is-grid .tch-progress {
    display: none;
}

.tch-toggle {
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: rgba(255, 255, 255, 0.7);
    color: var(--tch-primary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.tch-toggle:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* ── Loading skeleton ─────────────────────────────────────── */
.tch-skeleton .tch-media {
    animation: tch-pulse 1.4s ease-in-out infinite;
    box-shadow: none;
}

.tch-skeleton .tch-line {
    height: 14px;
    border-radius: 7px;
    background: #e2e8f0;
    margin-top: 12px;
    animation: tch-pulse 1.4s ease-in-out infinite;
}

@keyframes tch-pulse {
    50% {
        opacity: 0.55;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tch-viewport {
        scroll-behavior: auto;
    }

    .tch-media,
    .tch-skeleton .tch-media,
    .tch-skeleton .tch-line {
        transition: none;
        animation: none;
    }
}
