:root {
    --bg: #ffffff;
    --bg-alt: #f6f7fb;
    --text: #1a1d24;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2956d6;
    --accent-dark: #1e3fa3;
    --badge-bg: #eef2ff;
    --badge-fg: #1e3fa3;
    --tag-bg: #f1f5f9;
    --tag-fg: #334155;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(20,30,60,.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
                 "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.muted { color: var(--muted); }
.link { color: var(--accent); }

/* Header */
.site-header {
    border-bottom: 1px solid var(--border);
    background: #fff;
    position: sticky; top: 0; z-index: 10;
}
.site-header .container {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px;
}
.brand { font-weight: 700; font-size: 22px; color: var(--text); letter-spacing: -.01em; }
.brand-mark span { color: var(--accent); }
.nav a {
    color: var(--text);
    margin-left: 18px;
    font-weight: 500;
}
.nav a:hover { color: var(--accent); text-decoration: none; }

/* Hero / landing */
.hero {
    background: linear-gradient(180deg, #f7f9ff 0%, #ffffff 100%);
    padding: 64px 0 48px;
    border-bottom: 1px solid var(--border);
}
.hero h1 {
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0 0 18px;
    max-width: 760px;
}
.hero .lede {
    font-size: 18px;
    max-width: 680px;
    color: #2c2f3a;
    margin: 0 0 28px;
}
.cta-row { margin: 0; }

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }

/* Features */
.features { padding: 48px 0; }
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 24px;
}
.feature h3 { margin: 0 0 8px; font-size: 18px; }
.feature p  { margin: 0; color: var(--muted); }

/* Featured / search list */
.featured { padding: 32px 0 64px; }
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 18px;
}
.section-head h2 { margin: 0; font-size: 22px; }

.page-head {
    padding: 32px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}
.page-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.01em; }

/* Video card */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.card {
    display: flex; flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #c7d2fe;
    text-decoration: none;
}
.card-thumb {
    position: relative;
    aspect-ratio: 16/9;
    background: #e5e7eb;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb-placeholder {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #dbe3ff, #c7d2fe);
}
.card-duration {
    position: absolute; right: 8px; bottom: 8px;
    background: rgba(0,0,0,.78); color: #fff;
    padding: 2px 8px; border-radius: 4px;
    font-size: 12px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.card-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.35; color: var(--text); }
.card-desc {
    margin: 0; font-size: 14px; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; }

/* Badges and tags */
.badge {
    background: var(--badge-bg); color: var(--badge-fg);
    padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    text-transform: lowercase;
}
.tag {
    background: var(--tag-bg); color: var(--tag-fg);
    padding: 2px 9px; border-radius: 999px;
    font-size: 12px;
}

/* Video page */
.video-page { padding: 24px 0 64px; }
.player-wrap {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16/9;
    margin-bottom: 18px;
}
.player-wrap video { width: 100%; height: 100%; display: block; }

.video-head h1 { margin: 8px 0 6px; font-size: 26px; letter-spacing: -.01em; }
.video-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }

.video-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
}
@media (max-width: 800px) {
    .video-grid { grid-template-columns: 1fr; }
}

.video-main { min-width: 0; }

.sub-controls,
.sub-prefs {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    background: var(--bg-alt);
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.sub-controls-label { margin-right: 6px; }
.sub-controls-label--gap { margin-left: 14px; }

.sub-btn,
.sub-pref-btn {
    appearance: none;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .12s, background .12s, color .12s;
}
.sub-btn:hover,
.sub-pref-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.sub-btn.is-active,
.sub-pref-btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.sub-btn.is-active:hover,
.sub-pref-btn.is-active:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #fff;
}

/* Color swatches: small round chip showing the preview color */
.sub-color-swatch {
    width: 28px; height: 28px;
    padding: 0;
    background: var(--sw, #fff);
    border: 2px solid var(--border);
    border-radius: 50%;
}
.sub-color-swatch:hover { border-color: var(--accent); }
.sub-color-swatch.is-active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--accent);
    background: var(--sw, #fff);
    color: transparent;
}

/* Custom subtitle overlay rendered by JS on top of the player.
   The native cue display is suppressed (track.mode = 'hidden') so we
   can fully control width, wrapping, font-size and color. */
.player-wrap { position: relative; }
.custom-subs {
    position: absolute;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%);
    width: max-content;          /* shrink to fit, then clamp via max-width */
    max-width: 80%;
    text-align: center;
    pointer-events: none;
    z-index: 5;
    line-height: 1.3;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
                 "Helvetica Neue", Arial, sans-serif;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}
.custom-subs:empty { display: none; }
.custom-subs .cue-line {
    display: inline-block;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    margin: 2px 0;
    white-space: pre-wrap;       /* preserve cue \n + wrap long lines */
    word-break: normal;
    overflow-wrap: anywhere;
    max-width: 100%;             /* never exceed parent's 80% */
}

/* Size & color preferences — same classes also live on the <video>
   element so ::cue can apply during fullscreen native rendering. */
.custom-subs.sub-size-medium .cue-line { font-size: 1.05rem; }
.custom-subs.sub-size-big    .cue-line { font-size: 1.45rem; }
.custom-subs.sub-size-xl     .cue-line { font-size: 1.95rem; }

.custom-subs.sub-color-white  .cue-line { color: #ffffff; }
.custom-subs.sub-color-yellow .cue-line { color: #ffe066; }
.custom-subs.sub-color-cyan   .cue-line { color: #7be0ff; }
.custom-subs.sub-color-green  .cue-line { color: #9af59a; }

/* Native ::cue fallback (only visible in fullscreen, where the overlay
   can't render because only the fullscreened element is shown). */
video::cue { background: rgba(0, 0, 0, 0.62); }
video.sub-size-medium::cue { font-size: 1.0em; }
video.sub-size-big::cue    { font-size: 1.4em; }
video.sub-size-xl::cue     { font-size: 1.9em; }
video.sub-color-white::cue  { color: #ffffff; }
video.sub-color-yellow::cue { color: #ffe066; }
video.sub-color-cyan::cue   { color: #7be0ff; }
video.sub-color-green::cue  { color: #9af59a; }

.lede { font-size: 17px; color: #2c2f3a; }
.desc-long { color: #2c2f3a; }
.desc-long p { margin: 0 0 14px; }

.video-side .side-block {
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.video-side h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.video-side .tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 60px;
    padding: 24px 0;
    color: var(--muted);
    font-size: 14px;
}
