:root {
    --bg: #0b0b0c;
    --surface: #161618;
    --surface-2: #1f1f22;
    --line: #2c2c30;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --accent: #f5c518;
    --accent-ink: #121212;
    --radius: 8px;
    --gutter: clamp(16px, 4vw, 56px);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }


button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Üst çubuk ---------- */
.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: calc(14px + env(safe-area-inset-top, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px)) 14px max(var(--gutter), env(safe-area-inset-left, 0px));
    background: linear-gradient(to bottom, rgba(0,0,0,.85), rgba(0,0,0,0));
    transition: background .25s ease;
}
.topbar.solid { background: rgba(11,11,12,.96); box-shadow: 0 1px 0 var(--line); }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; min-width: 44px; min-height: 44px; }
.brand-logo {
    background: var(--accent);
    color: #000;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: -.5px;
    padding: 3px 8px;
    border-radius: 4px;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .5px; }

.search {
    min-width: 0;
    position: relative;
    flex: 1;
    max-width: 560px;
    margin-left: auto;
}
.search-icon {
    position: absolute; left: 14px; top: 50%;
    width: 20px; height: 20px; transform: translateY(-50%);
    fill: var(--muted); pointer-events: none;
}
.search input {
    width: 100%;
    height: 44px;
    padding: 0 44px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,197,24,.2); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border-radius: 50%; right: 0;
    border: none; background: transparent; color: var(--muted);
    font-size: 22px; line-height: 1; cursor: pointer;
}
.search-clear:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Vitrin ---------- */
.hero {
    position: relative;
    min-height: min(78vh, 720px);
    display: flex;
    align-items: flex-end;
    padding: calc(var(--topbar-height, 72px) + 48px) var(--gutter) 64px;
    overflow: hidden;
}
.hero-bg {
    position: absolute; inset: 0;
    background-color: var(--surface);
    background-size: cover;
    background-position: center 20%;
    transform: scale(1.04);
    transition: opacity .6s ease;
}
.hero-bg.blurred { filter: blur(24px) brightness(.7); transform: scale(1.2); }
.hero-bg-poster {
    position: absolute;
    right: var(--gutter);
    bottom: 64px;
    width: min(22vw, 260px);
    aspect-ratio: 2 / 3;
    border-radius: var(--radius);
    background-size: cover;
    background-position: center;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    z-index: 1;
}
.hero-shade {
    position: absolute; inset: 0;
    background:
        linear-gradient(to right, rgba(11,11,12,.95) 0%, rgba(11,11,12,.6) 45%, rgba(11,11,12,.1) 100%),
        linear-gradient(to top, var(--bg) 0%, rgba(11,11,12,0) 40%);
}
.hero-body { position: relative; z-index: 2; max-width: 640px; }
.hero-kicker {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.hero-title {
    margin: 0 0 12px;
    font-size: clamp(32px, 5.5vw, 64px);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -1px;
    text-wrap: balance;
}
.hero-meta { margin: 0 0 14px; color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.hero-meta .rating { color: var(--text); font-weight: 600; }
.hero-meta .rating::before { content: "★ "; color: var(--accent); }
.hero-desc {
    margin: 0 0 24px;
    font-size: 16px;
    line-height: 1.55;
    color: #d4d4d8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-actions[hidden] { display: none; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 46px; padding: 0 22px;
    border-radius: 6px; border: none;
    font-weight: 700; font-size: 16px;
    cursor: pointer; text-decoration: none;
    transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 22px; height: 22px; fill: currentColor; }
.btn-play { background: var(--accent); color: var(--accent-ink); }
.btn-play:hover { background: #ffd43b; }
.btn-ghost { background: rgba(109,109,110,.55); color: #fff; }
.btn-ghost:hover { background: rgba(109,109,110,.8); }

/* ---------- Satırlar (Top 10) ---------- */
#rows { position: relative; z-index: 3; margin-top: -24px; padding-bottom: 48px; }
.row { margin-bottom: 36px; }
.section-head {
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    padding: 0 var(--gutter);
    margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: clamp(18px, 2vw, 22px); font-weight: 700; }
.section-note { color: var(--muted); font-size: 13px; }

/* Top 10 satırı pencereye sığar: kart genişliği (--cw) satırın kendi genişliğinden
   hesaplanır (kapsayıcı sorgusu). 92 px'in (900 px altı ekranlarda 118 px) altına inmez;
   o zaman satır kaydırılır. */
.rail-wrap { position: relative; container-type: inline-size; }
.rail {
    --gap: 12px;
    --cw-min: 92px;
    --cw: clamp(var(--cw-min), calc((100cqi - 2 * var(--gutter) - 9 * var(--gap)) / 10), 230px);
    display: flex;
    gap: var(--gap);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding: 0 var(--gutter);
    padding: 12px var(--gutter) 18px;
    scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-btn {
    position: absolute; top: 12px; bottom: 18px; z-index: 4;
    width: calc(var(--gutter) - 4px); min-width: 44px;
    border: none; cursor: pointer;
    background: rgba(11,11,12,.6);
    color: #fff; font-size: 40px; line-height: 1;
    opacity: 0; transition: opacity .2s ease;
}
.rail-wrap:hover .rail-btn, .rail-btn:focus-visible { opacity: 1; }
.rail-wrap:not(.scrollable) .rail-btn { display: none; }
.rail-btn:hover { background: rgba(11,11,12,.85); }
.rail-btn.prev { left: 0; }
.rail-btn.next { right: 0; }
@media (hover: none) { .rail-btn { display: none; } }

.top-item {
    position: relative;
    flex: 0 0 var(--cw);
    width: var(--cw);
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    scroll-snap-align: start;
    cursor: pointer;
    border: none; background: none; padding: 0; text-align: left;
}
.rank {
    position: absolute;
    left: 0;
    bottom: 26px;              /* altyazı yüksekliği: posterin alt kenarına hizalar */
    z-index: 0;
    font-size: calc(var(--cw) * .8);
    font-weight: 900;
    line-height: .74;
    letter-spacing: calc(var(--cw) * -.07);
    color: var(--bg);
    -webkit-text-stroke: clamp(2px, calc(var(--cw) * .018), 3px) #595959;
    pointer-events: none;
    user-select: none;
    transition: -webkit-text-stroke-color .2s ease;
}
.rank.two-digit { font-size: calc(var(--cw) * .6); letter-spacing: calc(var(--cw) * -.09); }
.top-item:hover .rank, .top-item:focus-visible .rank { -webkit-text-stroke-color: var(--accent); }

.poster {
    position: relative;
    width: clamp(112px, 11vw, 160px);
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-2);
    box-shadow: 0 6px 18px rgba(0,0,0,.45);
    transition: transform .2s ease, box-shadow .2s ease;
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .no-img {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 10px; text-align: center;
    color: var(--muted); font-size: 13px; font-weight: 600;
}
.top-item:hover .poster, .top-item:focus-visible .poster,
.card:hover .poster, .card:focus-visible .poster {
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 14px 30px rgba(0,0,0,.6), 0 0 0 2px var(--accent);
}
.top-item:focus-visible, .card:focus-visible { outline: none; }

.poster-badge {
    position: absolute; left: 6px; top: 6px;
    background: rgba(0,0,0,.75);
    color: #fff; font-size: 11px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px;
}

.top-caption {
    display: block;
    margin-top: 8px;
    width: 100%;
    height: 18px; line-height: 18px;
    font-size: 13px; color: #d4d4d8;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-stack { position: relative; z-index: 1; display: flex; flex-direction: column; width: calc(var(--cw) * .64); }
.top-stack .poster { width: 100%; }

.skeleton .poster { width: calc(var(--cw) * .64); margin-bottom: 26px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- Arama sonuçları ---------- */
.results { padding: calc(var(--topbar-height, 72px) + 24px) 0 48px; min-height: 70vh; }
.results .section-head h2 { overflow-wrap: anywhere; }
.results[hidden] { display: none; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 28px 18px;
    padding: 8px var(--gutter);
}
.card {
    border: none; background: none; padding: 0; text-align: left;
    cursor: pointer; color: inherit;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 0;
}
.card .poster { width: 100%; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-sub { font-size: 12px; color: var(--muted); }
.empty { padding: 32px var(--gutter); color: var(--muted); font-size: 15px; }

/* ---------- Ayrıntı penceresi ---------- */
.detail {
    width: min(860px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    overflow: auto;
}
.detail[open] { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; }
.detail::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.detail-close {
    position: absolute; right: 12px; top: 10px; z-index: 2;
    width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(0,0,0,.55); color: #fff;
    font-size: 24px; line-height: 1; cursor: pointer;
}
.detail-close:hover { background: rgba(0,0,0,.85); }
.detail-poster { background: var(--surface-2) center / cover no-repeat; min-height: 360px; }
.detail-body { padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.detail-type { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; }
.detail-title { margin: 0; font-size: 28px; line-height: 1.15; padding-right: 36px; }
.detail-meta { margin: 0; color: var(--muted); font-size: 14px; }
.detail-desc { margin: 0; color: #d4d4d8; font-size: 15px; line-height: 1.55; }
.detail-desc:empty, .detail-meta:empty { display: none; }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }

.episode-pick {
    display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center;
    padding: 14px; border-radius: var(--radius);
    background: var(--surface-2); border: 1px solid var(--line);
}
.episode-pick[hidden] { display: none; }
.episode-pick label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #d4d4d8; }
.episode-pick input[type="number"] {
    width: 72px; height: 44px; padding: 0 10px;
    border-radius: 6px; border: 1px solid var(--line);
    background: var(--bg); color: var(--text); font-size: 16px;
}
.episode-pick input[type="number"]:disabled { opacity: .45; }
.episode-pick .ep-free { flex-basis: 100%; min-height: 44px; font-size: 13px; color: var(--muted); }
.episode-pick input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

@media (max-width: 640px) {
    .topbar { gap: 12px; flex-wrap: wrap; }
    .brand-name { display: none; }
    .search { max-width: none; }
    .hero { min-height: 72vh; padding-top: 110px; }
    .hero-bg-poster { display: none; }
    .detail[open] { grid-template-columns: 1fr; }
    .detail-poster { min-height: 220px; background-position: center 25%; }
    .detail-body { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

.hero[hidden], #rows[hidden], .hero-bg-poster[hidden] { display: none; }

.site-foot {
    display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
    padding: 24px var(--gutter) 32px;
    border-top: 1px solid var(--line);
    color: var(--muted); font-size: 13px;
}
.site-foot b { color: var(--text); font-weight: 600; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }
.legal-notice { flex-basis: 100%; max-width: 90ch; margin: 4px 0 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.legal-notice a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 3px; }
.site-foot { padding-bottom: max(32px, env(safe-area-inset-bottom, 0px)); }

@media (max-width: 900px) { .rail { --cw-min: 118px; } }

:root[data-theme="light"] {
    --bg: #f4f5f7; --surface: #fff; --surface-2: #e5e7eb; --line: #cbd0d8;
    --text: #181b22; --muted: #515b6b; color-scheme: light;
}
.display-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.theme-toggle, .language-switch button { min-width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.theme-toggle { display: grid; place-items: center; }
.theme-toggle svg { width: 21px; height: 21px; }
.theme-toggle .moon-icon { display: none; }
[data-theme="light"] .theme-toggle .moon-icon { display: block; }
[data-theme="light"] .theme-toggle .sun-icon { display: none; }
.language-switch { display: flex; gap: 8px; }
.language-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.display-controls button:hover { border-color: var(--accent); }
[data-theme="light"] .topbar { background: linear-gradient(to bottom, rgba(244,245,247,.98), rgba(244,245,247,.85)); }
[data-theme="light"] .topbar.solid { background: rgba(244,245,247,.98); }
[data-theme="light"] .hero-shade { background: linear-gradient(to right, rgba(244,245,247,.98), rgba(244,245,247,.8) 55%, rgba(244,245,247,.2)), linear-gradient(to top, var(--bg), transparent 60%); }
[data-theme="light"] .hero-desc, [data-theme="light"] .detail-desc, [data-theme="light"] .episode-pick label, [data-theme="light"] .card-sub { color: #414958; }
[data-theme="light"] .detail-type { color: #806000; }
[data-theme="light"] .hero-kicker { color: #806000; }
[data-theme="light"] .top-caption { color: var(--text); }
[data-theme="light"] .btn-ghost { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) {
    .display-controls { margin-left: auto; }
    .topbar .search { order: 3; flex-basis: 100%; max-width: none; }
    .hero { padding-top: calc(var(--topbar-height, 128px) + 24px); }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; }
    .detail { width: calc(100% - 24px); max-width: calc(100% - 24px); }
    .detail-title { font-size: clamp(23px, 6vw, 28px); overflow-wrap: anywhere; }
    .detail-actions .btn { justify-content: center; height: auto; min-height: 46px; padding: 12px 16px; }
}
