/* ============================================================
   VIDEOS (/videos/*, and videos inside posts and pages)
   Markup: inc/videos.php, single-video.php, archive-video.php,
   template-parts/video-card.php. Uses main.css tokens.
   ============================================================ */

/* --- Player: 16:9 for videos, 9:16 for Shorts --- */
.sd-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}
.sd-player--short { aspect-ratio: 9 / 16; }
.sd-player iframe,
.sd-player video,
.sd-player__facade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.sd-player video { object-fit: contain; background: #000; }

.sd-player__facade {
    padding: 0;
    background: #000;
    cursor: pointer;
}
.sd-player__facade img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.2s;
}
.sd-player__facade:hover img,
.sd-player__facade:focus-visible img { opacity: 1; }
.sd-player__facade:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sd-player__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}
.sd-player__play::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -11px 0 0 -7px;
    border-style: solid;
    border-width: 11px 0 11px 18px;
    border-color: transparent transparent transparent var(--bg);
}
.sd-player__facade:hover .sd-player__play,
a:hover .sd-player__play { transform: scale(1.08); }

/* --- Labels shared by the watch page and the index --- */
.sd-watch__label {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 1.25rem;
}

/* --- Watch page --- */
.sd-watch { padding: 7rem 3rem 5rem; }
.sd-watch__stage {
    max-width: 1100px;
    margin: 0 auto;
    scroll-margin-top: 6rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}
.sd-watch--short .sd-watch__stage { max-width: 360px; }

.sd-watch__layout {
    max-width: 1100px;
    margin: 3rem auto 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 4rem;
    align-items: start;
}
.sd-watch__main .section-tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}
.sd-watch__main h1 {
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: 1rem;
}
.sd-watch__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 2rem;
}
.sd-watch__meta a { color: var(--accent); text-decoration: none; }
.sd-watch__meta a:hover { text-decoration: underline; }
.sd-watch__lead {
    font-size: 1.2rem;
    font-weight: 300;
    line-height: 1.6;
    color: var(--gray);
    margin-bottom: 2rem;
}
.sd-watch__body {
    font-size: 1.02rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.82);
}
.sd-watch__body p { margin-bottom: 1.25rem; }
.sd-watch__body h2,
.sd-watch__body h3 { color: var(--fg); margin: 2rem 0 1rem; }
.sd-watch__body a { color: var(--accent); }
.sd-watch__body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--fg);
}

.sd-watch__side { display: grid; gap: 2.5rem; position: sticky; top: 6rem; }

.sd-watch__related-link {
    display: block;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: border-color 0.2s;
}
.sd-watch__related-link:hover { border-color: var(--accent); }
.sd-watch__related-kind {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}
.sd-watch__related-title { color: var(--fg); font-weight: 500; line-height: 1.35; }

.sd-watch__chapters ol { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.sd-watch__chapters a {
    display: flex;
    gap: 0.9rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.88rem;
    line-height: 1.4;
    text-decoration: none;
}
.sd-watch__chapters a:hover { color: var(--accent); }
.sd-watch__time {
    flex: 0 0 3.2rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    padding-top: 0.1rem;
}

.sd-watch__more { max-width: 1100px; margin: 5rem auto 0; }

/* --- Grids (watch page "More videos" and the index) --- */
.sd-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}
.sd-shorts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem 1.5rem;
}

.sd-video-card { display: block; color: var(--fg); text-decoration: none; }
.sd-video-card__thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    margin-bottom: 1rem;
}
.sd-video-card__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.sd-video-card--video:hover .sd-video-card__thumb img { transform: scale(1.03); }
.sd-video-card__duration {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    padding: 0.15rem 0.45rem;
    background: rgba(0, 0, 0, 0.75);
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
}
.sd-video-card--short .sd-player { margin-bottom: 1rem; }
.sd-video-card__text { display: flex; flex-direction: column; gap: 0.4rem; }
.sd-video-card__meta {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}
.sd-video-card__title { font-size: 1.05rem; font-weight: 600; line-height: 1.3; }
.sd-video-card--video:hover .sd-video-card__title { color: var(--accent); }
.sd-video-card__excerpt { font-size: 0.9rem; line-height: 1.55; color: var(--gray); }
.sd-video-card__more {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    margin-top: 0.25rem;
}
.sd-video-card__more:hover { text-decoration: underline; }

/* Featured: the newest episode spans the row, thumbnail beside the text. */
.sd-video-card--featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 3rem;
    align-items: center;
}
.sd-video-card--featured .sd-video-card__thumb { margin-bottom: 0; }
.sd-video-card--featured .sd-video-card__title { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.15; letter-spacing: -0.5px; }
.sd-video-card--featured .sd-video-card__text { gap: 0.9rem; }
.sd-video-card--featured .sd-video-card__excerpt { font-size: 1.05rem; line-height: 1.65; }
.sd-video-card--featured .sd-player__play { width: 84px; height: 84px; margin: -42px 0 0 -42px; }

/* --- Index --- */
.sd-videos__section { padding: 3rem 3rem 0; max-width: 1400px; margin: 0 auto; }
.sd-videos__channel {
    padding-bottom: 5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2rem;
    color: var(--gray);
}

/* --- Inside a post or page: Shorts play in place, videos link out --- */
.sd-related-videos {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0 0 2.5rem;
}
.sd-inline-video { margin: 0; color: var(--fg); text-decoration: none; }
.sd-inline-video--short { width: min(280px, 100%); }
.sd-inline-video figcaption,
.sd-inline-video--link > span:last-child { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.75rem; }
.sd-related-videos .sd-inline-video figcaption { font: inherit; text-transform: none; letter-spacing: normal; text-align: left; color: var(--fg); }
.sd-inline-video__tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}
.sd-inline-video__title { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 600; line-height: 1.35; letter-spacing: normal; text-transform: none; color: var(--fg); }
.sd-inline-video--link {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.25rem;
    align-items: center;
    width: 100%;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}
.sd-inline-video--link:hover { border-color: var(--accent); }
.sd-inline-video--link > span:last-child { margin-top: 0; }
.sd-inline-video__thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.sd-inline-video__thumb img { width: 100%; height: 100%; object-fit: cover; }
.sd-inline-video__thumb .sd-player__play { transform: scale(0.7); }

/* A post's drop cap belongs on its first paragraph, not on the video caption. */
.sd-related-videos p::first-letter { all: unset; }

@media (max-width: 900px) {
    .sd-watch { padding: 6rem 1.25rem 4rem; }
    .sd-watch__layout { grid-template-columns: 1fr; gap: 2.5rem; }
    .sd-watch__side { position: static; }
    .sd-videos__section { padding: 2.5rem 1.25rem 0; }
    .sd-inline-video--link { grid-template-columns: 1fr; }
    .sd-shorts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1rem; }
    .sd-video-card--featured { grid-template-columns: 1fr; gap: 1.25rem; }
    .sd-video-card--featured .sd-video-card__thumb { margin-bottom: 0; }
    .sd-player__play { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
}
