@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Figtree:wght@400;500;600;700&display=swap");

:root {
    color-scheme: dark;
    --bg: #14111c;
    --panel: #1e1a2b;
    --panel-2: #29243a;
    --line: #38324d;
    --text: #f4efe8;
    --soft: #d8d2e6;
    --muted: #a39cb8;
    --accent: #e0455b;          /* filmes: cortina de cinema */
    --accent-soft: rgba(224, 69, 91, 0.18);
    --series: #4cc2b0;          /* series */
    --series-soft: rgba(76, 194, 176, 0.16);
    --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --body: "Figtree", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 50% -140px, rgba(224, 69, 91, 0.2), transparent 70%),
        var(--bg);
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--body);
    line-height: 1.5;
}

body.modal-open { overflow: hidden; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.shell {
    width: min(1360px, calc(100% - 40px));
    margin: 0 auto;
    padding: 40px 0 64px;
}

/* ---------- Topo ---------- */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
}

h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(42px, 6vw, 68px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.search {
    display: flex;
    flex: 1 1 320px;
    max-width: 500px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.search input {
    flex: 1;
    min-width: 0;
    padding: 0 18px;
    border: 0;
    outline: 0;
    background: none;
}

.search input::placeholder { color: var(--muted); }

.search button {
    padding: 11px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    transition: filter 0.2s;
}

.search button:hover { filter: brightness(1.12); }

/* ---------- Filtros e resumo ---------- */
.filters {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    vertical-align: middle;
}

.filter {
    padding: 9px 22px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-weight: 600;
    transition: color 0.2s, background 0.2s;
}

.filter:hover { color: var(--text); }

.filter.active {
    background: var(--accent);
    color: #fff;
}

.stats {
    display: inline-flex;
    gap: 22px;
    margin-left: 20px;
    vertical-align: middle;
}

.stats article { display: flex; align-items: baseline; gap: 6px; }
.stats strong { font-family: var(--display); font-size: 24px; font-weight: 700; }
.stats span { color: var(--muted); font-size: 15px; }

.resultHeader {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 26px 0 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.resultHeader p { margin: 0; color: var(--muted); }

.pager {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.pager button {
    padding: 8px 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    font-weight: 600;
    transition: border-color 0.2s, background 0.2s;
}

.pager button:hover:not(:disabled) { border-color: var(--accent); background: var(--panel-2); }
.pager button:disabled { cursor: not-allowed; opacity: 0.4; }

/* ---------- Grade ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 26px 22px;
    transition: opacity 0.2s;
}

.grid.loading { opacity: 0.45; }

.poster-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    outline: none;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.poster-card:hover,
.poster-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.poster-card[data-type="series"]:hover,
.poster-card[data-type="series"]:focus-visible { border-color: var(--series); }

.poster {
    position: relative;
    aspect-ratio: 2 / 3;
    background: linear-gradient(160deg, var(--panel-2), var(--bg));
}

.poster img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poster-card.no-image .poster img { display: none; }

.fallback,
#modalFallback {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    color: var(--muted);
    text-align: center;
}

.no-image .fallback { display: flex; }

/* selo sobre o cartaz */
.poster-card .badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 3px 11px;
    border-radius: 999px;
    background: rgba(20, 17, 28, 0.82);
    backdrop-filter: blur(6px);
    color: #ffb3bd;
    font-size: 12px;
    font-weight: 700;
}

.poster-card[data-type="series"] .badge { color: var(--series); }

.card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 15px 16px;
    text-align: center;
}

.card-body h2 {
    display: -webkit-box;
    min-height: 2.6em;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-family: var(--display);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.meta,
.category {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.meta { color: var(--series); font-weight: 600; }
.meta[hidden] { display: none; }

.category {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
    margin-top: auto;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
}

.category span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.category span:first-child { flex-shrink: 0; }
.category span + span { color: var(--soft); }

.category span + span::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 4px;
    margin: 0 8px 2px 0;
    border-radius: 999px;
    background: var(--accent);
}

.empty {
    grid-column: 1 / -1;
    padding: 32px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    color: var(--muted);
    text-align: center;
}

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.modal.open { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 8, 16, 0.8);
    backdrop-filter: blur(8px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(220px, 330px) minmax(0, 1fr);
    width: min(980px, 100%);
    height: min(700px, calc(100vh - 44px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
    animation: abrir 0.22s ease-out;
}

@keyframes abrir {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(20, 17, 28, 0.8);
    font-size: 26px;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s;
}

.modal-close:hover { border-color: var(--accent); background: var(--accent); }

.modal-poster {
    position: relative;
    min-height: 100%;
    background: linear-gradient(160deg, var(--panel-2), var(--bg));
}

.modal-poster img {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#modalImage:not([src]) { visibility: hidden; }

.modal-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 36px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.modal-content > .badge { display: none; }

.modal-content h2 {
    margin: 0 44px 8px 0;
    font-family: var(--display);
    font-size: clamp(28px, 4.5vw, 44px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.modal-category { margin: 0 0 16px; color: var(--muted); }

.modal-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }

.modal-facts span {
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-2);
    font-size: 14px;
    font-weight: 600;
}

.modal[data-type="series"] .modal-facts span { border-color: var(--series-soft); background: var(--series-soft); color: var(--series); }
.modal[data-type="movie"] .modal-facts span { border-color: var(--accent-soft); background: var(--accent-soft); color: #ffb3bd; }

.modal-content h3 {
    margin: 0 0 8px;
    font-family: var(--display);
    font-size: 18px;
    font-weight: 700;
}

#modalSynopsis {
    margin: 0 0 24px;
    max-width: 64ch;
    color: var(--soft);
    font-size: 16px;
    line-height: 1.65;
}

.season-box[hidden] { display: none; }

#seasonList {
    display: grid;
    gap: 10px;
    max-height: min(310px, 38vh);
    padding-right: 6px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--series) transparent;
}

.season {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

summary {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    list-style: none;
    font-weight: 700;
    cursor: pointer;
}

summary::-webkit-details-marker { display: none; }

.season-arrow {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--series);
    border-bottom: 2px solid var(--series);
    transform: rotate(-45deg);
    transition: transform 0.16s ease;
}

.season[open] .season-arrow { transform: rotate(45deg); }

summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
summary small { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }

.episode-scroll {
    max-height: 230px;
    overflow: auto;
    border-top: 1px solid var(--line);
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.season-back {
    position: sticky;
    top: 0;
    z-index: 1;
    width: 100%;
    min-height: 38px;
    padding: 0 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    color: var(--series);
    font-weight: 700;
    text-align: left;
}

.season-back::before {
    content: "‹";
    display: inline-block;
    margin-right: 8px;
    font-size: 22px;
    line-height: 0;
    transform: translateY(2px);
}

.season ol {
    margin: 0;
    padding: 10px 16px 14px;
    color: var(--soft);
    line-height: 1.55;
    list-style: none;
}

.season li {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.season li:last-child { border-bottom: 0; }
.season li span { color: var(--series); font-weight: 700; }

/* ---------- Telas menores ---------- */
@media (max-width: 1150px) {
    .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Celular ---------- */
@media (max-width: 800px) {
    .shell { width: min(100% - 20px, 1240px); padding-top: 20px; }

    .topbar { gap: 18px; margin-bottom: 22px; }
    .search { flex-basis: 100%; max-width: none; }

    .filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
    .filter { padding: 9px 8px; }

    .stats { display: flex; justify-content: center; margin: 14px 0 0; }

    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
    .card-body { padding: 12px 11px 13px; }
    .card-body h2 { font-size: 15px; }
    .meta { font-size: 12px; }
    .category { font-size: 12px; gap: 5px; }
    .category span + span::before { margin-right: 6px; }

    .resultHeader { flex-direction: column; align-items: stretch; text-align: center; }
    .pager { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); width: 100%; }

    .modal { padding: 10px; }

    .modal-panel {
        display: flex;
        flex-direction: column;
        width: min(100%, 420px);
        height: min(94vh, 820px);
        max-height: calc(100vh - 20px);
        border-radius: 18px;
    }

    .modal-poster { flex: 0 0 auto; min-height: auto; height: min(320px, 42vh); }
    .modal-poster img { object-position: center top; }
    .modal-content { padding: 22px; }
    .modal-content h2 { margin-right: 0; font-size: clamp(26px, 8vw, 34px); overflow-wrap: anywhere; }
    .modal-category, #modalSynopsis { overflow-wrap: anywhere; }
    #seasonList { max-height: 260px; padding-right: 0; }
    .episode-scroll { max-height: min(300px, 42vh); }
    .season li { grid-template-columns: 42px minmax(0, 1fr); overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}