/*
 * /tools/series-maker («سریال‌ساز»), «قسمت اول»: the page is a series of six episodes, on top of showcase.css.
 * The first and the last episode sit on a dark film in both themes (light text, gold accent, like a title card);
 * the four between follow the site theme through var(--panel*), var(--stroke), var(--text), var(--muted) and
 * var(--purple*).
 */
.sc--series-maker { --sl-gold: #f3c97c; --sl-ink: #0b0a10; --sl-paper: #f4f1ec; }

/* ---------- The season bar: one bar per episode, filled as it is read ---------- */
.sl-season {
    position: sticky; top: var(--header-h, 74px); z-index: 12;
    padding: 8px var(--sc-gutter); background: color-mix(in srgb, var(--bg) 88%, transparent);
    /* avoid-ai-design-ignore: K3 (a real layer: the bar over scrolling content, like the site header) */
    backdrop-filter: blur(14px); border-bottom: 1px solid var(--stroke);
}
.sl-season ol { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.sl-season a { display: block; padding-block: 4px 2px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.8; border-radius: 6px; }
.sl-season a:hover, .sl-season a[aria-current] { color: var(--text); }
.sl-season-bar { display: block; height: 4px; overflow: hidden; border-radius: 9999px; background: color-mix(in srgb, var(--text) 16%, transparent); }
.sl-season-bar i { display: block; height: 100%; width: calc(var(--read, 0) * 100%); border-radius: inherit; background: var(--purple); }
.sl-season-name { display: block; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-season-no { color: var(--purple-soft); }
html[data-theme=light] .sl-season-no { color: var(--purple-strong); }

/* ---------- Episode labels and the «ادامه دارد…» cards ---------- */
.sl-ep { scroll-margin-top: calc(var(--header-h, 74px) + 52px); }
.sl-ep-no { margin: 0 0 6px; color: var(--purple-soft); font-size: 14px; font-weight: 800; }
html[data-theme=light] .sl-ep-no { color: var(--purple-strong); }
.sl-cliff {
    margin: 28px 0 0; padding: 16px 20px 18px;
    border: 1px solid var(--stroke); border-radius: 14px; background: var(--panel-2);
    color: var(--text); font-size: 15px; line-height: 1.9;
}
/* Speaks like the phone's end card: «ادامه دارد…» is the card's headline line. */
.sl-cliff span { display: block; margin-block-end: 2px; color: var(--sl-gold); font-size: 22px; font-weight: 800; line-height: 1.6; }
html[data-theme=light] .sl-cliff span { color: var(--purple-strong); }

/* ---------- Episode 1: the hero, a phone playing the sample ---------- */
.sl-hero { position: relative; isolation: isolate; overflow: hidden; color: var(--sl-paper); background: radial-gradient(120% 90% at 20% 30%, #2a1b32 0%, var(--sl-ink) 62%); }
.sl-hero .crumbs, .sl-hero .crumbs a, .sl-hero .crumbs li + li::before { color: rgba(244, 241, 236, .78); }
.sl-hero .crumbs [aria-current] { color: var(--sl-paper); }
.sl-hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: clamp(24px, 4vw, 64px); align-items: center; padding-block: clamp(20px, 4vw, 48px) clamp(40px, 6vw, 72px); }
.sl-hero .sl-ep-no { color: var(--sl-gold); }
.sl-hero h1 { margin: 0; font-size: clamp(30px, 4.6vw, 52px); font-weight: 800; line-height: 1.4; }
/* avoid-ai-design-ignore: C6 (the showcase pages' title accent, gold here) */
.sl-hero h1 .sc-grad, .sl-yours .sc-grad { display: block; background: linear-gradient(100deg, #f3c97c, #e98a5a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sl-lead { margin: 12px 0 22px; font-size: 17px; line-height: 1.95; color: rgba(244, 241, 236, .86); }
.sl-hero-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.sl-hero .sc-btn, .sl-yours .sc-btn { background: var(--sl-gold); color: #1a1206; }
.sl-hero .sc-btn:hover, .sl-yours .sc-btn:hover { background: #f7d796; color: #1a1206; }
.sl-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--sl-gold); font-weight: 700; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }
.sl-link:hover { color: #f7d796; }
.sl-hero :focus-visible, .sl-yours :focus-visible { outline-color: var(--sl-gold); }
.sl-cliff--hero { margin-top: 32px; background: rgba(255, 255, 255, .06); border-color: rgba(244, 241, 236, .16); color: rgba(244, 241, 236, .9); }
.sl-cliff--hero span, html[data-theme=light] .sl-cliff--hero span { color: var(--sl-gold); }

.sl-phone { margin: 0; justify-self: center; width: min(100%, 320px); }
.sl-phone-screen {
    position: relative; aspect-ratio: 9 / 16; overflow: hidden; border: 8px solid #1d1a24; border-radius: 36px;
    background: #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 30px 70px rgba(0, 0, 0, .6);
}
.sl-phone-screen video { display: block; width: 100%; height: 100%; object-fit: cover; }
.sl-phone figcaption { margin-top: 12px; text-align: center; font-size: 13px; line-height: 1.8; color: rgba(244, 241, 236, .74); }

.sl-reel { position: absolute; inset: 0; }
.sl-reel-frame { position: absolute; inset: 0; opacity: 0; transition: opacity 600ms var(--sc-ease); }
.sl-reel-frame.is-on { opacity: 1; }
.sl-reel-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sl-reel-frame.is-on img { animation: sl-push 3.6s linear both; }
.sl-reel.is-paused .sl-reel-frame img { animation-play-state: paused; }
@keyframes sl-push { from { transform: scale(1); } to { transform: scale(1.07); } }
.sl-reel-bars { position: absolute; inset-block-start: 10px; inset-inline: 12px; z-index: 3; display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sl-reel-bars li { flex: 1; height: 3px; overflow: hidden; border-radius: 9999px; background: rgba(255, 255, 255, .3); }
.sl-reel-bars i { display: block; height: 100%; width: 0; background: #fff; }
.sl-reel-bars .is-done i { width: 100%; }
.sl-reel-bars .is-now i { animation: sl-fill 3.4s linear both; }
.sl-reel.is-paused .sl-reel-bars .is-now i { animation-play-state: paused; }
@keyframes sl-fill { from { width: 0; } to { width: 100%; } }
.sl-reel-tag { position: absolute; inset-block-start: 22px; inset-inline-start: 12px; z-index: 3; padding: 2px 10px; border-radius: 9999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.9; }

/* The narrator's words, drawn the way the episode video burns them in (EpisodeCaptions): bold white, a dark
   outline, centred above the bottom fifth of the frame. */
.sl-phone-screen, .sl-frame { container-type: inline-size; }
.sl-sub {
    position: absolute; inset-inline: 8%; inset-block-end: 18%; z-index: 2; margin: 0; text-align: center;
    color: #fff; font-size: clamp(14px, 6.2cqi, 19px); font-weight: 800; line-height: 1.6;
    text-shadow: 0 0 2px #101010, 0 0 2px #101010, 0 0 3px #101010, 0 1px 2px rgba(0, 0, 0, .6);
}

.sl-reel-end { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; gap: 4px; text-align: center; background: rgba(8, 7, 12, .86); opacity: 0; transition: opacity 400ms var(--sc-ease); }
.sl-reel-end.is-on { opacity: 1; }
.sl-reel-end p { margin: 0; }
.sl-reel-end-ep { color: rgba(244, 241, 236, .78); font-size: 14px; font-weight: 700; }
.sl-reel-end-next { color: var(--sl-gold); font-size: 26px; font-weight: 800; line-height: 1.6; }
.sl-reel-play {
    position: absolute; inset-block-end: 14px; inset-inline-end: 12px; z-index: 4; display: grid; place-items: center;
    inline-size: 44px; block-size: 44px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
    transition: background-color 120ms var(--sc-ease);
}
.sl-reel-play:hover { background: rgba(0, 0, 0, .75); }
.sl-reel-play:active { transform: scale(.94); }
.sl-reel-play .sl-i-play, .sl-reel.is-paused .sl-reel-play .sl-i-pause { display: none; }
.sl-reel.is-paused .sl-reel-play .sl-i-play { display: block; }
.sl-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }

/* ---------- Episodes 2 to 4: the sample project ---------- */
.sl-chip { display: inline-block; padding: 2px 10px; border-radius: 9999px; background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--text); font-size: 12px; font-weight: 700; line-height: 1.9; }
.sc--series-maker .sc-lead { margin-block-end: 24px; }

.sl-episodes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 16px; margin: 0; padding: 0; list-style: none; }
.sl-episode { display: grid; grid-template-rows: auto 1fr; overflow: hidden; border: 1px solid var(--stroke); border-radius: 16px; background: var(--panel); }
.sl-episode img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.sl-episode-body { padding: 14px 16px 16px; }
.sl-episode h3, .sl-card h3 { margin: 8px 0 4px; font-size: 18px; font-weight: 800; line-height: 1.6; }
.sl-episode p, .sl-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.9; }
.sl-hook { margin-top: 10px !important; padding-top: 10px; border-top: 1px dashed var(--stroke); color: var(--text) !important; }
.sl-hook span { font-weight: 700; color: var(--purple-soft); }
html[data-theme=light] .sl-hook span { color: var(--purple-strong); }
.sl-more-eps { display: grid; place-items: center; min-width: 96px; padding: 12px; border: 1.5px dashed var(--stroke); border-radius: 16px; color: var(--muted); font-weight: 700; writing-mode: vertical-rl; }
.sl-more-line { display: none; margin: 4px 0 0; color: var(--muted); font-weight: 700; }

.sl-cast { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.sl-places { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0 0; padding: 0; list-style: none; }
.sl-card { padding: 12px 12px 16px; border: 1px solid var(--stroke); border-radius: 16px; background: var(--panel); }
.sl-card img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; margin-bottom: 10px; border-radius: 12px; }
.sl-card--wide img { aspect-ratio: 16 / 9; }

.sl-shots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.sl-shot { overflow: hidden; border: 1px solid var(--stroke); border-radius: 16px; background: var(--panel); }
.sl-shot img { display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; object-fit: cover; }
.sl-shot-body { padding: 12px 14px 14px; }
.sl-shot-body p { margin: 0 0 6px; font-size: 14px; line-height: 1.9; }
.sl-shot-meta { color: var(--muted); font-size: 13px !important; }
.sl-line { padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }

/* ---------- Episode 5: narrator and subtitles ---------- */
.sl-voice { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.sl-facts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.sl-facts li { position: relative; padding-inline-start: 22px; font-size: 15px; line-height: 1.9; }
.sl-facts li::before { content: ""; position: absolute; inset-inline-start: 0; inset-block-start: .7em; width: 10px; height: 10px; border-radius: 3px; background: var(--purple); }
.sl-frame { position: relative; margin: 0; justify-self: center; width: min(100%, 300px); }
.sl-frame img { display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 20px; background: var(--panel-2); }
.sl-frame .sl-sub { inset-block-end: auto; inset-block-start: 66%; }
.sl-frame figcaption { margin-top: 10px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }

/* ---------- Episode 6: the story box on the writer's desk ---------- */
.sl-yours { position: relative; isolation: isolate; overflow: hidden; padding-block: clamp(48px, 6vw, 84px); color: var(--sl-paper); background: var(--sl-ink); }
.sl-yours-bg { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; opacity: .38; }
.sl-yours::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(11, 10, 16, .96) 10%, rgba(11, 10, 16, .7)); }
.sl-yours .sl-ep-no { color: var(--sl-gold); }
.sl-yours .sc-h2 { color: var(--sl-paper); }
.sl-yours-in { max-width: 860px; margin-inline: auto; }
.sl-aside { margin: 16px 0 0; font-size: 14px; line-height: 1.9; color: rgba(244, 241, 236, .78); }
.sl-aside a { color: var(--sl-gold); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

.sl-box { display: grid; gap: 12px; padding: 16px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 20px; background: rgba(20, 18, 28, .82); }
.sl-file-input { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sl-zone {
    display: flex; align-items: center; gap: 14px; min-height: 92px; padding: 14px 16px; border: 1.5px dashed rgba(255, 255, 255, .32);
    border-radius: 14px; cursor: pointer; transition: border-color 180ms var(--sc-ease), background-color 180ms var(--sc-ease);
}
.sl-zone:hover, .sl-box.is-over .sl-zone { border-color: var(--sl-gold); background: rgba(243, 201, 124, .07); }
.sl-file-input:focus-visible + .sl-zone { outline: 2px solid var(--sl-gold); outline-offset: 2px; }
.sl-zone-icon { flex: none; display: grid; place-items: center; inline-size: 52px; block-size: 52px; border-radius: 12px; background: rgba(243, 201, 124, .14); color: var(--sl-gold); }
.sl-zone-text { min-inline-size: 0; }
.sl-zone-title { display: block; font-size: 16px; font-weight: 700; line-height: 1.8; overflow-wrap: anywhere; }
.sl-zone-sub { display: block; font-size: 13px; line-height: 1.8; color: rgba(244, 241, 236, .74); }
.sl-paste summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; color: rgba(244, 241, 236, .9); }
/* Physical edges on purpose, so the chevron points down and up in RTL. rtl-ignore-next */
.sl-paste summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-inline-start: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform 180ms var(--sc-ease); }
.sl-paste[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.sl-textarea {
    box-sizing: border-box; width: 100%; margin-top: 4px; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 12px;
    background: rgba(0, 0, 0, .28); color: var(--sl-paper); font: inherit; font-size: 15px; line-height: 1.9; resize: vertical;
}
.sl-textarea::placeholder { color: rgba(244, 241, 236, .5); }
.sl-textarea:focus-visible { outline: 2px solid var(--sl-gold); outline-offset: 1px; }
.sl-go { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.sl-yours .sc-btn[aria-busy=true] { opacity: .7; pointer-events: none; }
.sl-note { flex: 1 1 220px; margin: 0; font-size: 13px; line-height: 1.8; color: rgba(244, 241, 236, .74); }
.sl-note.is-error { color: #ff9b8f; }

@media (max-width: 991px) {
    .sl-hero-grid, .sl-voice { grid-template-columns: 1fr; }
    .sl-phone { width: min(78%, 300px); }
    .sl-episodes { grid-template-columns: 1fr; }
    .sl-episode { grid-template-columns: 38% 1fr; grid-template-rows: auto; }
    /* The text sets the row's height; the portrait pictures only fill it. */
    .sl-episode img { block-size: 0; min-block-size: 100%; aspect-ratio: auto; }
    .sl-more-eps { writing-mode: horizontal-tb; min-height: 52px; }
    .sl-shots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    /* Six names do not fit: numbers only, the episode being read keeps its name. */
    .sl-season-name { font-size: 0; }
    .sl-season a { display: flex; flex-direction: column; justify-content: center; min-height: 44px; }
    .sl-season-no { font-size: 13px; }
    .sl-season a[aria-current] .sl-season-name { font-size: 11px; overflow: visible; text-overflow: clip; }
}
@media (max-width: 767px) {
    /* Phone: the sample plays in the first screen; episode 1's «ادامه دارد…» comes after it, as on the phone itself. */
    .sl-hero-grid { gap: 20px; padding-block: 12px 40px; }
    .sl-hero-copy { display: contents; }
    /* «ساخت سریال با هوش مصنوعی» stays on one line down to 360px, so «مصنوعی» is never left alone below it. */
    .sl-hero h1 { font-size: clamp(24px, 6.6vw, 34px); }
    .sl-hero .sl-lead { margin-block-end: 4px; }
    .sl-hero-go { order: 1; }
    .sl-phone { order: 2; width: min(70%, 264px); }
    .sl-cliff--hero { order: 3; margin-top: 0; }

    /* Episodes, faces and places become swipe rows, like a season rail: one card in view, the next one peeking. */
    .sl-episodes, .sl-cast, .sl-places {
        display: grid; grid-auto-flow: column; grid-template-columns: none; gap: 12px;
        margin-inline: -16px; padding: 2px 16px 10px; scroll-padding-inline: 16px;
        overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
    }
    .sl-episodes::-webkit-scrollbar, .sl-cast::-webkit-scrollbar, .sl-places::-webkit-scrollbar { display: none; }
    .sl-episodes > *, .sl-cast > *, .sl-places > * { scroll-snap-align: start; }
    .sl-episodes { grid-auto-columns: 80%; }
    .sl-cast { grid-auto-columns: 58%; }
    .sl-places { grid-auto-columns: 84%; margin-top: 4px; }
    .sl-episode { display: flex; flex-direction: column; }
    .sl-episode img { block-size: auto; min-block-size: 0; aspect-ratio: 16 / 10; }
    /* A whole swipe for one line of text is a waste: on the phone the count is a line under the row. */
    .sl-more-eps { display: none; }
    .sl-more-line { display: block; }
    .sl-episodes:focus-visible, .sl-cast:focus-visible, .sl-places:focus-visible { outline: 2px solid var(--purple); outline-offset: -2px; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .sl-zone, .sl-paste summary::after, .sl-reel-frame, .sl-reel-end, .sl-reel-play { transition: none; }
    .sl-reel-frame.is-on img, .sl-reel-bars .is-now i { animation: none; }
    .sl-reel-bars .is-now i { width: 100%; }
}

/* Large phones and small tablets: two cards side by side instead of one very large card. */
@media (min-width: 576px) and (max-width: 767px) {
    .sl-episodes { grid-auto-columns: 46%; }
    .sl-cast { grid-auto-columns: 36%; }
    .sl-places { grid-auto-columns: 60%; }
}
