/* Watchlog — dunkle Bühne, Poster tragen die Farbe, Bernstein als Projektorlicht */

:root {
    --bg: #0f1116;
    --surface: #161a22;
    --surface-2: #1c212c;
    --line: #272d3a;
    --text: #e9e7e1;
    --muted: #8d93a1;
    --accent: #e3a94f;
    --accent-soft: rgba(227, 169, 79, 0.14);
    --radius: 10px;
    --font-display: "Bricolage Grotesque", sans-serif;
    --font-body: "Instrument Sans", sans-serif;
    --font-mono: "Spline Sans Mono", monospace;
}

/* Light Mode folgt der Systemeinstellung (Handy/OS) */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f2f0ea;
        --surface: #fbfaf7;
        --surface-2: #e7e4da;
        --line: #dcd7ca;
        --text: #24262c;
        --muted: #6d7280;
        --accent: #a87418;
        --accent-soft: rgba(168, 116, 24, 0.12);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { display: block; max-width: 100%; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

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

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.9rem 1.5rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.wordmark span { color: var(--accent); }

.topbar nav {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.topbar nav::-webkit-scrollbar { display: none; }

.topbar nav a {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}

.topbar nav a:hover { color: var(--text); }

.topbar nav a.active { color: var(--text); background: var(--surface-2); }

.topbar-actions { display: flex; align-items: center; gap: 0.7rem; margin-left: auto; }

.topbar-search { display: flex; align-items: center; gap: 0.4rem; }

.topbar-search input,
.search-page input {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    padding: 0.35rem 0.9rem;
    font: inherit;
    font-size: 0.88rem;
    width: 180px;
    transition: width 0.2s, opacity 0.2s, border-color 0.15s;
}

.topbar-search input:focus,
.search-page input:focus { border-color: var(--accent); outline: none; }

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

/* Eingeklappt: nur die Lupe, das Feld erscheint erst beim Öffnen */
.topbar-search input { width: 0; padding: 0.35rem 0; border-width: 0; opacity: 0; pointer-events: none; }

.topbar-search.open input { width: 200px; padding: 0.35rem 0.9rem; border-width: 1px; opacity: 1; pointer-events: auto; }

.icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--muted);
    transition: color 0.15s, background 0.15s;
}

.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

.search-page { display: flex; gap: 0.5rem; margin-bottom: 2rem; }

.search-page input { flex: 1; max-width: 420px; width: auto; padding: 0.5rem 1rem; }

.flash {
    margin-bottom: 1.5rem;
    padding: 0.7rem 1.1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.9rem;
}

/* ---------- Login ---------- */

.auth-wrap { display: grid; place-items: center; min-height: 65vh; }

.auth-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2.2rem 2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.auth-card label { display: flex; flex-direction: column; gap: 0.35rem; }

.auth-card input {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    padding: 0.55rem 0.85rem;
    font: inherit;
}

.auth-card input:focus { border-color: var(--accent); outline: none; }

.btn-primary {
    background: var(--accent);
    color: #14161c;
    border-radius: 999px;
    padding: 0.6rem;
    font-weight: 600;
    margin-top: 0.3rem;
}

.form-error { color: #e5484d; font-size: 0.85rem; }

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    max-width: 820px;
    margin-top: 1.25rem;
}

.profile-grid .auth-card { max-width: none; }

.auth-card h2 { font-size: 1.05rem; }

/* ---------- Layout ---------- */

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }

.section { margin-bottom: 3rem; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1.1rem;
}

h1, h2 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }

.empty {
    padding: 2.5rem 1.5rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: var(--muted);
}

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.stat { background: var(--surface); padding: 1rem 1.25rem; }

.stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart-row .value { font-variant-numeric: tabular-nums; }

.stat span { color: var(--muted); font-size: 0.85rem; }

/* ---------- Fortschrittsbalken ---------- */

.bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.2s; }

.progress-line { display: flex; align-items: center; gap: 0.6rem; }
.progress-line .bar { flex: 1; }
.progress-line .count { flex: none; }

/* ---------- Breite Kacheln (eine pro Zeile, Dashboard) ---------- */

.row-list { display: flex; flex-direction: column; gap: 0.6rem; }

.row-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    transition: border-color 0.15s;
}

.row-card:hover { border-color: var(--accent); }

.row-card .poster { width: 64px; height: 96px; object-fit: cover; flex-shrink: 0; }

.row-card .body { flex: 1; min-width: 0; padding: 0.7rem 0; }

.row-card .title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-card .subtitle { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-card .ep-line {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    min-width: 0;
    margin-top: 0.1rem;
}

.row-card .ep-line .mono { flex: none; }

.row-card .ep-line .ep-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-card .progress-line { max-width: 340px; margin-top: 0.45rem; }

.row-card .code { padding-right: 1.1rem; flex: none; }

.row-card .actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-right: 1.1rem;
    flex: none;
    position: relative;
    z-index: 2;
}

/* Ganze Karte klickbar, Buttons in .actions bleiben eigenständig */
.row-card .cover { position: absolute; inset: 0; z-index: 1; }

.leaving { opacity: 0; transform: translateX(10px); transition: opacity 0.25s, transform 0.25s; }

/* ---------- Kachel-Ansicht (Umschalter auf Serien/Filme) ---------- */

.view-toggle .icon-list { display: none; }
html.grid-view .view-toggle .icon-list { display: block; }
html.grid-view .view-toggle .icon-grid { display: none; }

html.grid-view .row-list.switchable {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.2rem 1rem;
}

html.grid-view .switchable .row-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    background: none;
    border: none;
    overflow: visible;
}

html.grid-view .switchable .row-card:hover { border-color: transparent; }

html.grid-view .switchable .poster,
html.grid-view .switchable .poster-empty {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    transition: transform 0.15s, border-color 0.15s;
}

html.grid-view .switchable .row-card:hover .poster,
html.grid-view .switchable .row-card:hover .poster-empty { transform: translateY(-3px); border-color: var(--accent); }

html.grid-view .switchable .poster-empty { font-size: 2rem; }

html.grid-view .switchable .body { padding: 0; }

html.grid-view .switchable .title { font-family: var(--font-body); font-weight: 500; font-size: 0.88rem; }

html.grid-view .switchable .subtitle { font-size: 0.78rem; }

/* Zähler/✓ als Badge auf dem Poster */
html.grid-view .switchable .code {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(15, 17, 22, 0.85);
    color: var(--accent) !important;
}

/* Aktionen (Haken/Datum) kompakt auf dem Poster */
html.grid-view .switchable .actions {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0;
    background: rgba(15, 17, 22, 0.75);
    border-radius: 999px;
}

html.grid-view .switchable .actions .mono { display: none; }

.row-card .poster-empty {
    display: grid;
    place-items: center;
    width: 64px;
    height: 96px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
}

/* ---------- Filter-Pills ---------- */

.pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.pills a {
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
    transition: all 0.15s;
}

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

.pills a.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Serien-Detail ---------- */

.show-hero {
    position: relative;
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow: hidden;
    margin-bottom: 2.5rem;
    background: var(--surface);
}

.show-hero .backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 20%;
    opacity: 0.18;
    filter: saturate(0.9);
}

.show-hero > * { position: relative; }

.show-hero img.poster { width: 130px; border-radius: 8px; flex-shrink: 0; }

.show-hero img.still { width: 320px; max-width: 40%; border-radius: 8px; flex-shrink: 0; align-self: flex-start; }

.show-hero .overview { color: var(--muted); font-size: 0.9rem; max-width: 60ch; margin-top: 0.6rem; }

.chips { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }

.chip {
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 0.78rem;
    color: var(--muted);
}

.chip.running { border-color: var(--accent); color: var(--accent); }

.chip.rating { border-color: var(--accent); color: var(--accent); font-variant-numeric: tabular-nums; }

.season { margin-bottom: 2rem; }

.season-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.season-head h2 { font-size: 1.05rem; }

.season-head .progress-line { flex: 1; max-width: 420px; }

.btn {
    padding: 0.35rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--muted);
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.episode-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.episode {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem 1rem;
    background: var(--surface);
}

.episode-list > * + * { border-top: 1px solid var(--line); }

.episode .code { flex: none; width: 72px; }

.episode .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }

.episode .date { flex: none; }

.episode .ep-rating { flex: none; color: var(--accent); }

.episode.future { opacity: 0.45; }

.episode.watched .name { color: var(--muted); }

/* ---------- Check-Toggle ---------- */

.check {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: grid;
    place-items: center;
    color: transparent;
    font-size: 0.8rem;
    line-height: 1;
    transition: all 0.15s;
}

.check:hover { border-color: var(--accent); color: var(--muted); }

.check.on { background: var(--accent); border-color: var(--accent); color: #14161c; }

/* ---------- Statistik-Charts ---------- */

.chart { display: flex; flex-direction: column; gap: 0.55rem; max-width: 640px; }

.chart-row { display: flex; align-items: center; gap: 0.8rem; }

.chart-row .label {
    flex: none;
    width: 170px;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
    color: var(--muted);
}

.chart-row .bar { flex: 1; height: 10px; border-radius: 5px; }

.chart-row .bar i { border-radius: 5px; }

.chart-row .value { flex: none; width: 56px; }

a.chart-row:hover .label { color: var(--text); }

@media (max-width: 640px) {
    .chart-row .label { width: 110px; }
}

/* ---------- Kalender ---------- */

.day { margin-bottom: 1.6rem; }

.day > .mono { display: block; margin-bottom: 0.5rem; }

.cal-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 0.4rem;
}

.cal-row img { width: 34px; height: 51px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }

.cal-row .name { font-weight: 500; }

.cal-row .ep { color: var(--muted); font-size: 0.85rem; }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .topbar { gap: 0.5rem; padding: 0.75rem 0.9rem; }
    .wordmark { font-size: 1.1rem; }
    .topbar nav a { padding: 0.3rem 0.55rem; font-size: 0.9rem; }
    .topbar-search.open { position: absolute; inset: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; padding: 0 0.9rem; }
    .topbar-search.open input { width: 100%; flex: 1; }
    .container { padding: 1.25rem 1rem 4rem; }
    .section-head .pills { width: 100%; }
    .show-hero { flex-direction: column; }
    .show-hero img.poster { width: 100px; }
    .episode .date { display: none; }
    .show-hero img.still { width: 100%; max-width: none; }
    .season-head { flex-wrap: wrap; }
}

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