/* ==========================================================================
   AnimeSaturn - anime (series) page: /anime/{slug}-{code}
   Loaded after watch.css, which provides the shared .aw-* blocks (hero,
   details panel, external links, title/genres/synopsis, rails, season
   cards). This file adds the page grid, the episode tiles / range tabs and
   copies of the legacy-hook rules watch.css scopes under #watch-main
   (#w-rating, #w-seasons), re-scoped to #anime-main.
   ========================================================================== */

/* ---- Grid ----------------------------------------------------------------- */

.an-grid {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-top: -3rem;
}

.an-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.an-main {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
}

.an .aw-head { padding-top: 1.75rem; }
.an .aw-genres { margin-top: -14px; }

@media (min-width: 768px) {
    .an-grid {
        grid-template-columns: 240px minmax(0, 1fr);
        gap: 28px;
        align-items: start;
        margin-top: -5rem;
    }
    .an .aw-head { padding-top: 2.5rem; }
}

@media (min-width: 1024px) {
    .an-grid {
        grid-template-columns: 280px minmax(0, 1fr);
        gap: 32px;
    }
}

/* Mobile: small poster beside the title, then the reference order. */
@media (max-width: 767.98px) {
    .an-grid {
        grid-template-columns: 112px minmax(0, 1fr);
        grid-template-areas:
            "poster head"
            "cta cta"
            "adside adside"
            "genres genres"
            "story story"
            "next next"
            "episodes episodes"
            "meta meta"
            "links links"
            "vote vote"
            "seasons seasons"
            "adinline adinline"
            "related related"
            "similar similar";
        gap: 0 14px;
        align-items: start;
        margin-top: -4.75rem;
    }

    .an-side,
    .an-main { display: contents; }

    .an-side > *, .an-main > * { margin-bottom: 18px; min-width: 0; }

    .an .aw-poster { grid-area: poster; }
    .an .aw-head { grid-area: head; align-self: end; padding-top: 0; }
    .an .aw-cta { grid-area: cta; }
    .an .aw-ad--side { grid-area: adside; }
    .an .aw-genres { grid-area: genres; margin-top: 0; }
    .an .aw-story { grid-area: story; }
    .an .an-next { grid-area: next; }
    .an .an-episodes { grid-area: episodes; }
    .an .aw-meta { grid-area: meta; }
    .an .aw-links { grid-area: links; }
    .an .aw-vote { grid-area: vote; }
    .an .an-seasons { grid-area: seasons; }
    .an .an-ad-inline { grid-area: adinline; }
    .an .an-related { grid-area: related; }
    .an .an-similar { grid-area: similar; }
}

/* ---- Next episode --------------------------------------------------------- */

.an-next {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 12px 16px;
    font-size: 13.5px;
}

.an-next__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--aw-brand-text);
}

.an-next__title { font-weight: 700; color: var(--as-ink); }
.an-next__when { color: var(--as-ink-mute); }

.an-next__timer {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--as-ink);
}

/* ---- Episodes ------------------------------------------------------------- */

.an-ep-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 14px;
}

.an-ep-title { margin: 0; }

.an-ep-count {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--as-ink-dim);
}

.an-ep-find {
    position: relative;
    display: flex;
    align-items: center;
}

.an-ep-find svg {
    position: absolute;
    left: 11px;
    color: var(--as-ink-dim);
    pointer-events: none;
}

.an-ep-find input {
    width: 200px;
    -webkit-appearance: none;
    appearance: none;
    height: 36px;
    padding: 0 12px 0 32px;
    border: 1px solid var(--as-border);
    border-radius: var(--as-r-md);
    background: var(--as-soft);
    color: var(--as-ink);
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.an-ep-find input::placeholder { color: var(--as-ink-dim); }
.an-ep-find input:focus { border-color: var(--as-brand); box-shadow: 0 0 0 3px var(--as-brand-ring); }

.an-ep-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.an-ep-tab {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--as-border);
    border-radius: var(--as-r-md);
    background: var(--as-soft);
    color: var(--as-ink-mute);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}

.an-ep-tab:hover { background: var(--as-hover); color: var(--as-ink); }

.an-ep-tab.is-active {
    border-color: var(--as-brand);
    background: var(--as-brand);
    color: #fff;
}

.an-ep-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.an-ep-grid[hidden] { display: none; }

@media (min-width: 480px) { .an-ep-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .an-ep-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .an-ep-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); } }

.an-ep {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border: 1px solid var(--as-border);
    border-radius: var(--as-r-md);
    background: var(--as-soft);
    color: var(--as-ink);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}

/* .an-ep-grid scope: outranks base.css "html:not(.dark) a:hover" (brand text on the brand fill). */
.an-ep-grid .an-ep:hover,
.an-ep-grid .an-ep:focus-visible {
    border-color: var(--as-brand);
    background: var(--as-brand);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.an-ep.is-filler { border-style: dashed; color: var(--as-ink-mute); }

.an-ep.is-found {
    border-color: var(--as-brand);
    box-shadow: 0 0 0 3px var(--as-brand-ring);
}

.an-ep-empty { margin: 0; }

/* Header tools: Sub / Dub segmented switch + search (same look as the watch panel). */
.an-ep-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.an-ep-seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--as-border);
    border-radius: var(--as-r-md);
    background: var(--as-soft);
}

.an-ep-seg__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 12px;
    border: 0;
    border-radius: calc(var(--as-r-md) - 2px);
    background: none;
    color: var(--as-ink-mute);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}

.an-ep-seg__btn:hover { color: var(--as-ink); }
.an-ep-seg__btn.is-active { background: var(--as-brand); color: #fff; }
.an-ep-seg__btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--as-brand-ring); }
.an-ep-seg__ita { font-size: 11px; font-weight: 800; opacity: .85; }

.an-ep.is-off,
.an-ep.is-miss,
.an-ep-tab[hidden] { display: none; }
.an-ep-status { margin: 8px 0 0; }

@media (max-width: 639.98px) {
    .an-ep-tools { flex: 1 1 100%; }
    .an-ep-find { flex: 1 1 180px; }
    .an-ep-find input { width: 100%; height: 38px; }
    /* Phone tap targets: 36px segments in a 38px switch, beside the 38px search. */
    .an-ep-seg { padding: 0; }
    .an-ep-seg__btn { height: 36px; padding: 0 12px; }
}

/* ---- Ads / rails ---------------------------------------------------------- */

.an .an-ad-inline:empty { display: none; }
.an .an-related .as-section,
.an .an-similar { margin-bottom: 0; }

/* ---- Rating (main.js Rating on div#w-rating) - from watch.css ------------ */

#anime-main #w-rating {
    display: block;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    color: inherit;
}

#anime-main #w-rating .stars {
    display: flex;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    white-space: nowrap;
}

#anime-main #w-rating .stars span {
    position: static;
    display: flex;
    flex: 1 1 0;
    justify-content: space-around;
    align-items: center;
    padding: 2px 0;
    font-size: inherit;
    cursor: pointer;
}

#anime-main #w-rating .stars span::before { content: none; }

#anime-main #w-rating .stars span svg {
    flex: 0 1 22px;
    width: 22px;
    max-width: 44%;
    height: auto;
    aspect-ratio: 1;
    color: var(--as-border-strong);
    pointer-events: none; 
    transition: color .12s ease, transform .12s ease;
}

#anime-main #w-rating .stars span.half svg:first-child,
#anime-main #w-rating .stars span.full svg { color: var(--aw-star); }

#anime-main #w-rating .stars span:hover svg { transform: scale(1.12); }

#anime-main #w-rating .message {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    white-space: normal;
    text-align: left;
    color: var(--as-ink-dim);
}

@media (max-width: 767.98px) {
    .aw-vote__title, #anime-main #w-rating .message { text-align: center; }
}

/* ---- Seasons (#w-seasons swiper) - from watch.css ------------------------ */

#anime-main #w-seasons {
    margin: 0;
    overflow: hidden;
}

#anime-main #w-seasons .seasons { display: flex; margin: 0; }

#anime-main #w-seasons .seasons .season {
    flex-shrink: 0;
    width: 220px;
    padding-right: 12px;
}

#anime-main #w-seasons .seasons .season a {
    position: relative;
    display: flex;
    align-items: flex-end;
    height: 112px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--as-border);
    border-radius: var(--as-r-lg);
    background: var(--as-soft);
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}

#anime-main #w-seasons .seasons .season a::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    width: auto;
    height: auto;
    border: 0;
    background: linear-gradient(0deg, rgba(7, 6, 11, .92) 0%, rgba(7, 6, 11, .4) 60%, rgba(7, 6, 11, .15) 100%);
    opacity: 1;
}

#anime-main #w-seasons .seasons .season a::after { content: none; }

#anime-main #w-seasons .seasons .season a:hover { border-color: rgba(134, 61, 186, .6); transform: translateY(-2px); }

#anime-main #w-seasons .seasons .season.active a {
    border-color: var(--as-brand);
    box-shadow: 0 0 0 2px var(--as-brand-ring);
}

#anime-main #w-seasons .season a:hover .aw-season__bg { transform: scale(1.05); }

#anime-main #w-seasons .seasons .season a .name {
    position: relative;
    z-index: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: auto;
    padding: 10px 12px;
    overflow: hidden;
    font-family: var(--aw-display);
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    text-transform: none;
    color: #fff;
}

#anime-main #w-seasons .swiper-pagination {
    position: static;
    margin-top: 10px;
    text-align: left;
}

#anime-main #w-seasons .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background: var(--as-border-strong);
    opacity: 1;
    transition: width .2s, background-color .2s;
}

#anime-main #w-seasons .swiper-pagination-bullet-active { width: 20px; border-radius: 999px; background: var(--as-brand); }

@media (max-width: 767.98px) {
    #anime-main #w-seasons .seasons .season { width: 172px; padding-right: 10px; }
    #anime-main #w-seasons .seasons .season a { height: 96px; }
}

/* ---- Phones: reference type scale + spacing (section-title text-base,
   synopsis text-sm, roomier detail rows with inset separators). ---------- */
@media (max-width: 767.98px) {
    .an .aw-h2,
    .an .an-related .as-sec-title,
    .an .an-similar .as-sec-title { font-size: 16px; }
    .an .aw-shorting .content { font-size: 14px; line-height: 1.65; }

    .an .aw-meta { gap: 8px 12px; padding: 16px; font-size: 14px; }
    .an .aw-meta__row { gap: 6px; }
    .an .aw-meta__k { font-size: 12px; }
    .an .aw-meta__sep { margin: 4px 0; }
}
