/* Premium Movie Club UI */
:root {
    /* Light mode */
    --bg: #f7f8f6;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --text: #212A31;
    --text-muted: #748D92;
    --border: #D3D9D4;
    --primary: #124E66;
    --primary-hover: #0e3d52;
    --primary-soft: rgba(18, 78, 102, 0.1);
    --up: #2e7d6f;
    --down: #c45c5c;
    --shadow: 0 1px 3px 0 rgb(33 42 49 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(33 42 49 / 0.08);
    --shadow-lg: 0 20px 25px -5px rgb(33 42 49 / 0.1);
    --radius: 16px;
    --radius-sm: 12px;
}

[data-theme="dark"] {
    /* Dark mode */
    --bg: #1a2228;
    --bg-card: #212A31;
    --bg-elevated: #2E3944;
    --text: #e8eceb;
    --text-muted: #748D92;
    --border: #3a4652;
    --primary: #4a8aa3;
    --primary-hover: #5c9bb5;
    --primary-soft: rgba(74, 138, 163, 0.15);
    --up: #4caf9a;
    --down: #e07a7a;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}
.container { max-width: 1280px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Header */
header {
    background: color-mix(in srgb, var(--bg-card) 85%, transparent);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; max-width: 1280px; margin: 0 auto;
}
.logo {
    font-size: 1.65rem; font-weight: 700; letter-spacing: -0.03em;
    text-decoration: none; color: var(--text);
}
.logo span { color: var(--primary); }
nav { display: flex; gap: 0.5rem; align-items: center; }
nav a {
    color: var(--text-muted); text-decoration: none; font-weight: 500;
    padding: 0.5rem 0.9rem; border-radius: 999px; transition: all 0.2s;
    font-size: 0.95rem;
}
nav a:hover, nav a.active { color: var(--text); background: var(--primary-soft); }
.theme-toggle {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 999px; padding: 0.4rem; cursor: pointer;
    color: var(--text); font-size: 0.85rem; font-weight: 500;
    transition: all 0.2s; margin-left: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
}
.theme-toggle .material-icons { font-size: 20px; }
.theme-toggle:hover { background: var(--border); }

/* Page header */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }

/* Cards */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.75rem;
}
.movie-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s;
    border: 1px solid var(--border);
    position: relative;
}
.movie-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: var(--shadow-lg);
}
.poster-wrap { position: relative; overflow: hidden; }
.poster {
    width: 100%; aspect-ratio: 2/3; object-fit: cover;
    background: var(--border); transition: transform 0.5s ease;
}
.movie-card:hover .poster { transform: scale(1.05); }
.card-body { padding: 1.15rem 1.15rem 1rem; }
.card-title {
    font-weight: 600; font-size: 1.05rem; line-height: 1.35;
    margin-bottom: 0.3rem; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.85rem; }

/* Vote bar */
.vote-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border);
}
.vote-btn {
    border: none; background: transparent; cursor: pointer;
    padding: 0.45rem 0.65rem; border-radius: 10px; font-size: 1.15rem;
    transition: all 0.2s; color: var(--text-muted); display: flex; align-items: center;
}
.vote-btn.up:hover, .vote-btn.up.active { background: rgba(16, 185, 129, 0.12); color: var(--up); }
.vote-btn.down:hover, .vote-btn.down.active { background: rgba(244, 63, 94, 0.12); color: var(--down); }
.score {
    font-weight: 700; font-size: 1.05rem; min-width: 2.2rem; text-align: center;
    color: var(--text);
}

/* Buttons & forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.65rem 1.35rem; border-radius: 12px; font-weight: 600;
    text-decoration: none; border: none; cursor: pointer; transition: all 0.2s;
    font-size: 0.95rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-elevated); border-color: var(--text-muted); }

input, select {
    width: 100%; padding: 0.8rem 1rem; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
    font-size: 1rem; transition: all 0.2s; font-family: inherit;
}
input:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards; opacity: 0; }

/* Empty state */
.empty-state {
    text-align: center; padding: 4rem 1rem; color: var(--text-muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 0.5rem; font-weight: 600; }

/* Mobile */
@media (max-width: 640px) {
    .header-inner { flex-direction: column; gap: 0.75rem; padding: 0.85rem 1rem; }
    nav { width: 100%; justify-content: center; flex-wrap: wrap; }
    .movie-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.25rem; }
    .container { padding: 1.25rem 1rem; }
    .page-header h1 { font-size: 1.65rem; }
}

/* Attribution */
.attribution {
    text-align: center; padding: 2.5rem 1rem; font-size: 0.75rem; color: var(--text-muted);
    border-top: 1px solid var(--border); margin-top: 4rem;
}

/* Movie details button (feed cards) */
.details-btn {
    width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    margin-bottom: 0.65rem; padding: 0.4rem 0.75rem;
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 10px;
    font: inherit; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.01em;
    cursor: pointer; transition: all 0.2s;
}
.details-btn .material-icons { font-size: 17px; }
.details-btn:hover { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); }
.details-btn:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); color: var(--primary); }

/* Movie details modal */
body.md-locked { overflow: hidden; }
.md-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background: rgb(17 24 29 / 0.55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; transition: opacity 0.22s ease;
}
.md-overlay[hidden] { display: none; }
.md-overlay.is-open { opacity: 1; }
.md-dialog {
    position: relative; width: 100%; max-width: 760px; max-height: min(88vh, 900px);
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg-card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(12px) scale(0.97); opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.md-dialog:focus { outline: none; }
.md-overlay.is-open .md-dialog { transform: none; opacity: 1; }
.md-close-wrap {
    position: sticky; top: 0; height: 0; z-index: 2;
    display: flex; justify-content: flex-end;
}
.md-close {
    margin: 0.75rem 0.75rem 0 0; flex-shrink: 0;
    width: 38px; height: 38px; border-radius: 999px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--bg-card) 85%, transparent); color: var(--text);
    border: 1px solid var(--border); box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: all 0.2s;
}
.md-close:hover { background: var(--bg-elevated); border-color: var(--text-muted); }
.md-close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); border-color: var(--primary); }
.md-close .material-icons { font-size: 20px; }

.md-hero { position: relative; aspect-ratio: 16 / 6; background: var(--primary-soft); overflow: hidden; }
.md-hero--plain { aspect-ratio: auto; height: 72px; }
.md-backdrop { width: 100%; height: 100%; object-fit: cover; display: block; }
.md-hero::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(to bottom, transparent 35%, var(--bg-card) 100%);
}
.md-head {
    position: relative; display: flex; gap: 1.25rem; align-items: flex-start;
    padding: 0 1.75rem; margin-top: -4.5rem;
}
.md-poster {
    width: 128px; flex-shrink: 0; aspect-ratio: 2 / 3; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); background: var(--border);
}
.md-poster--empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.md-head-text { min-width: 0; padding-top: 4.85rem; }
.md-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.md-year { color: var(--text-muted); font-weight: 500; }
.md-tagline { color: var(--text-muted); font-style: italic; margin-top: 0.3rem; font-size: 0.95rem; }
.md-chips, .md-genres { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.md-chip {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.65rem;
    border-radius: 999px; font-size: 0.8rem; font-weight: 500;
    background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
}
.md-chip .material-icons { font-size: 16px; color: var(--text-muted); }
.md-cert { font-weight: 700; letter-spacing: 0.03em; border-color: var(--text-muted); }
.md-rating .material-icons { color: #e3a008; }
.md-genre {
    font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
}
.md-muted { color: var(--text-muted); }

.md-body { padding: 1.5rem 1.75rem 1.75rem; display: grid; gap: 1.5rem; }
.md-section h3 {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 0.6rem;
}
.md-overview { font-size: 0.98rem; line-height: 1.7; }
.md-facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem;
    padding: 1rem 1.1rem; border-radius: var(--radius-sm);
    background: var(--bg); border: 1px solid var(--border);
}
.md-fact dt { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.md-fact dd { font-size: 0.92rem; font-weight: 500; margin-top: 0.1rem; }

.md-cast { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.md-person { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.md-person img, .md-avatar {
    width: 44px; height: 44px; border-radius: 999px; object-fit: cover; flex-shrink: 0;
    background: var(--border); border: 1px solid var(--border);
}
.md-avatar { display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.md-avatar .material-icons { font-size: 22px; }
.md-person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.md-person-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-person-role { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.md-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.md-actions .btn { gap: 0.4rem; }
.md-actions .material-icons { font-size: 20px; }

.md-state { padding: 3.5rem 1.75rem; text-align: center; display: grid; justify-items: center; gap: 0.75rem; }
.md-state-title { font-size: 1.1rem; font-weight: 600; }
.md-state-icon { font-size: 40px; color: var(--down); }
.md-retry { gap: 0.35rem; margin-top: 0.25rem; }
.md-spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--primary);
    animation: md-spin 0.8s linear infinite;
}
@keyframes md-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .md-overlay { align-items: flex-end; padding: 0; }
    .md-dialog {
        max-width: none; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0;
        border-bottom: none; transform: translateY(40px);
    }
    .md-head { padding: 0 1.1rem; gap: 0.9rem; margin-top: -3rem; }
    .md-head-text { padding-top: 3.3rem; }
    .md-poster { width: 92px; }
    .md-title { font-size: 1.25rem; }
    .md-body { padding: 1.25rem 1.1rem 1.5rem; }
    .md-cast { grid-template-columns: 1fr 1fr; }
    .md-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
    .md-overlay, .md-dialog { transition: none; }
    .md-spinner { animation-duration: 2s; }
}
