@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=DM+Mono:wght@400;500&display=swap');

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

:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f6f6f7;
    --surface-hover: #f0f0f2;
    --border: #d8d8dc;
    --border-strong: #a0a0a8;
    --text: #111114;
    --text-mid: #3a3a40;
    --text-sub: #666670;
    --accent: #d42b1a;
    --accent-bg: #fff0ee;

    --font-ui:      'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-brand:   'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-mono:    'DM Mono', monospace;
}


@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0e10;
        --surface: #0e0e10;
        --surface-alt: #18181c;
        --surface-hover: #202026;
        --border: #2c2c34;
        --border-strong: #4a4a56;
        --text: #f0f0f4;
        --text-mid: #b0b0bc;
        --text-sub: #72727e;
        --accent: #e05a4a;
        --accent-bg: #2a1210;
    }

    .movie-count span {
        color: var(--text-mid);
    }
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ── HEADER ── */

header {
    background: var(--bg);
    border-bottom: 2px solid var(--text);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
}

.header-brand {
    padding: 11px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

h1 {
    font-family: var(--font-brand);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    line-height: 1;
}

h1 .brand-accent {
    color: var(--accent);
}

.header-sub { display: none; }

.scrape-info {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-sub);
    padding: 0 20px 6px;
    display: flex;
    align-items: end;
    letter-spacing: 0.03em;
    margin-left: auto;
}

/* ── FILTERS ── */

.filters {
    display: flex;
    align-items: stretch;
    overflow-x: auto;
}

.filter-group {
    display: flex;
    flex-direction: column;
    padding: 8px 16px;
    border-right: 1px solid var(--border);
    min-width: 0;
    gap: 4px;
}

.filter-group > label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-sub);
}

.filter-group select {
    padding: 3px 22px 3px 0;
    border: none;
    border-bottom: 2px solid var(--text);
    border-radius: 0;
    font-size: 0.92rem;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='7' fill='%23111114'%3E%3Cpath d='M4.5 7L0 0h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1px center;
    min-width: 100px;
}

@media (prefers-color-scheme: dark) {
    .filter-group select {
        /* Re-render arrow in light colour for dark bg */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='7' fill='%23f0f0f4'%3E%3Cpath d='M4.5 7L0 0h9z'/%3E%3C/svg%3E");
    }
}

.filter-group select:focus { outline: none; border-bottom-color: var(--accent); }

.cinemas-filter { flex: 1; min-width: 240px; }

#cinema-toggles {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.cinema-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    transition: opacity 0.15s, filter 0.15s;
    user-select: none;
    background: transparent;
    animation: cinema-appear 0.5s ease backwards;
}

@keyframes cinema-appear {
    from { opacity: 0; transform: translateY(6px); }
}

.cinema-toggle:nth-child(1)  { animation-delay: 0ms; }
.cinema-toggle:nth-child(2)  { animation-delay: 100ms; }
.cinema-toggle:nth-child(3)  { animation-delay: 200ms; }
.cinema-toggle:nth-child(4)  { animation-delay: 300ms; }
.cinema-toggle:nth-child(5)  { animation-delay: 400ms; }
.cinema-toggle:nth-child(6)  { animation-delay: 500ms; }
.cinema-toggle:nth-child(7)  { animation-delay: 600ms; }
.cinema-toggle:nth-child(8)  { animation-delay: 700ms; }
.cinema-toggle:nth-child(9)  { animation-delay: 800ms; }
.cinema-toggle:nth-child(10) { animation-delay: 900ms; }
.cinema-toggle:nth-child(11) { animation-delay: 1000ms; }
.cinema-toggle:nth-child(12) { animation-delay: 1100ms; }

.cinema-toggle:hover { filter: brightness(0.8); }
.cinema-toggle.inactive { opacity: 0.2; filter: grayscale(1); }
.cinema-toggle.bioplus-disabled { opacity: 0.15; filter: grayscale(1); pointer-events: none; text-decoration: line-through; }

.cinema-toggle .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bioplus-toggle-wrap {
    border-right: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-mid);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 13px;
    height: 13px;
    cursor: pointer;
}

/* ── VIEW TOGGLE ── */

.view-toggle {
    display: flex;
    flex-shrink: 0;
}

.view-toggle button {
    padding: 0 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-sub);
    transition: all 0.15s;
    border-left: 1px solid var(--border);
}

.view-toggle button.active {
    background: var(--text);
    color: var(--bg);
}

.view-toggle button:hover:not(.active) {
    color: var(--text);
    background: var(--surface-hover);
}

/* ── LOADING ── */

main#loading {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-sub);
    font-size: 1rem;
}

main#loading .loading-sub {
    font-size: 0.8rem;
    color: var(--text-sub);
    opacity: 0.7;
    margin-top: 8px;
}

.loader {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ── VIEWS ── */

.view { padding: 0; max-width: 100%; margin: 0; overflow-x: auto; }

/* ── MOVIE CARDS ── */

.movie-card {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.movie-header {
    display: grid;
    grid-template-columns: 56px 1fr 96px 44px;
    align-items: stretch;
    cursor: pointer;
    transition: background 0.1s;
}

.movie-header:hover { background: var(--surface-hover); }
.movie-card.expanded > .movie-header { background: var(--surface-alt); }

.movie-poster {
    width: 56px;
    height: 80px;
    object-fit: cover;
    display: block;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.movie-info {
    padding: 12px 20px;
    min-width: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.movie-title {
    font-family: var(--font-ui);
    font-size: 1.35rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.movie-meta {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-mid);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.movie-meta span { white-space: nowrap; }
.movie-meta-dot { color: var(--border-strong); }

.movie-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
    padding: 0 12px;
    text-align: center;
}

.movie-count strong {
    font-family: var(--font-ui);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.movie-count span {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-sub);
    line-height: 1.3;
}

.movie-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    font-size: 0.55rem;
    transition: transform 0.2s;
}

.movie-card.expanded .movie-chevron { transform: rotate(90deg); }

/* ── SHOWINGS ── */

.movie-showings {
    border-top: 1px solid var(--border);
    display: none;
    background: var(--surface-alt);
}

.movie-card.expanded .movie-showings { display: block; }

.showing-day { border-bottom: 1px solid var(--border); }
.showing-day:last-child { border-bottom: none; }

.day-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-sub);
    padding: 7px 20px 6px;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border);
}

.showing-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.showing-row:last-child { border-bottom: none; }
.showing-row:hover { background: var(--surface-hover); }

.showing-time {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 9px 0 9px 20px;
    width: 80px;
    flex-shrink: 0;
    color: var(--text);
    border-right: 1px solid var(--border);
}

.cinema-badge {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 2px 9px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    margin: 0 14px;
    flex-shrink: 0;
    white-space: nowrap;
}

.showing-room {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-mid);
    flex: 1;
}

.showing-price {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-mid);
    white-space: nowrap;
    margin-right: 8px;
    letter-spacing: 0.02em;
}

.showing-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-right: 8px; }

.showing-tag {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 2px;
}

.showing-sold-out {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-right: 20px;
}

.showing-book {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-decoration: none;
    padding: 9px 20px;
    border-left: 1px solid var(--border);
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
}

.showing-book:hover { background: var(--accent); color: white; }

/* ── TIMELINE ── */

.timeline-day-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 14px 24px 8px;
    border-bottom: 1px solid var(--border);
}

.timeline-day-label:first-child { padding-top: 14px; }

.timeline {
    display: grid;
    gap: 0;
    border-bottom: 2px solid var(--text);
    min-width: fit-content;
}

.timeline-header {
    background: var(--surface);
    color: var(--text);
    padding: 8px 12px;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-right: 1px solid var(--border);
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
    text-decoration-skip-ink: none;
}

.timeline-header:last-child { border-right: none; }

/* poster cell in timeline header row */
.timeline-header-poster {
    background: var(--text);
    border-right: 1px solid rgba(255,255,255,0.12);
    width: 40px;
    flex-shrink: 0;
}

.timeline-slot {
    padding: 7px 11px;
    font-size: 0.78rem;
    min-width: 150px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.timeline-slot:last-child { border-right: none; }
.timeline-slot:hover .slot-movie:not(.sold-out) { filter: brightness(0.97); }

.timeline-slot a { color: var(--text); text-decoration: none; }
.timeline-slot a:hover .slot-title { text-decoration: underline; }

/* time column cell */
.timeline-slot-time {
    background: var(--surface-alt);
    padding: 7px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.slot-time {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-sub);
    display: block;
    white-space: nowrap;
}

.slot-poster {
    width: 40px;
    height: 58px;
    max-width: 100%;
    object-fit: cover;
    display: block;
    border-radius: 1px;
    flex-shrink: 0;
}

.slot-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.slot-title {
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    color: var(--text);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: break-word;
}

.slot-room {
    font-family: var(--font-mono);
    color: var(--text-sub);
    font-size: 0.62rem;
    margin-top: 2px;
    display: block;
}

.timeline-slot.sold-out { opacity: 0.4; }

.slot-movie {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 5px;
    border-radius: 2px;
    color: var(--text);
    text-decoration: none;
    width: 100%;
}
.slot-movie + .slot-movie {
    margin-top: 7px;
}
.slot-movie:hover .slot-title { text-decoration: underline; }
.slot-movie.sold-out { opacity: 0.4; }

.timeline-empty {
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.timeline-time-gap {
    height: 4px;
    background: var(--surface-alt);
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.timeline-loading {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-sub);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.timeline-loading .loader { margin-bottom: 16px; }

/* ── EMPTY STATE ── */

.empty-state {
    text-align: center;
    color: var(--text-sub);
    padding: 70px 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.try-tomorrow {
    display: block;
    margin: 28px auto 0;
    padding: 10px 20px;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: floralwhite;
    width: fit-content;
    transition: opacity 0.15s, background 0.15s;
}
.try-tomorrow:hover {
    opacity: 0.85;
    background: #fff;
}
@media (prefers-color-scheme: dark) {
    .try-tomorrow {
        background: #1e1a14;
    }
    .try-tomorrow:hover {
        background: #2a2418;
    }
    .slot-movie {
        background: var(--surface) !important;
    }
    .slot-movie .slot-title,
    .slot-movie .slot-room {
        color: var(--text);
    }
}

/* ── MOBILE ── */

@media (max-width: 640px) {
    .header-brand { padding: 10px 16px; }
    h1 { font-size: 0.95rem; }
    .scrape-info { padding: 0 14px; font-size: 0.58rem; align-items: center; }
    .filters { flex-wrap: wrap; }
    .filter-group { padding: 7px 12px; }
    .cinemas-filter { flex-basis: 100%; border-right: none; order: 1; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 2px; }
    .filter-group > label { display: none; }
    .bioplus-toggle-wrap { border-right: none; }
    .view-toggle { margin-left: auto; }
    .movie-header { grid-template-columns: 48px 1fr 44px; }
    .movie-poster { width: 48px; height: 68px; }
    .movie-title { font-size: 1.1rem; }
    .movie-count { display: none; }
    .showing-row { flex-wrap: nowrap; }
    .showing-room { display: none; }
    .showing-book, .showing-sold-out { margin-left: auto; }
}

/* ── SMALL SCREENS (TABLET + MOBILE) ── */

@media (max-width: 1024px) {
    .timeline-header { padding: 6px 8px; font-size: 0.65rem; }
    .timeline-slot-time { padding: 5px 6px; }
    .slot-time { font-size: 0.65rem; }
}

/* DEBUG: uncomment to show grid density info + outlines
.timeline::before {
    content: attr(data-debug);
    display: block;
    grid-column: 1 / -1;
    background: #222;
    color: #0f0;
    font-family: monospace;
    font-size: 11px;
    padding: 4px 8px;
}
.timeline-compact { outline: 3px solid orange; }
.timeline-mini { outline: 3px solid red; }
*/

/* ── GRID DENSITY (column-count driven) ── */

.timeline-compact .timeline-slot { min-width: 70px; padding: 4px 3px; }
.timeline-compact .slot-poster { width: 100%; height: auto; aspect-ratio: 40 / 58; }
.timeline-compact .slot-movie { flex-direction: column; align-items: center; gap: 3px; padding: 2px; }
.timeline-compact .slot-text { min-width: 0; width: 100%; text-align: center; }
.timeline-compact .slot-title { font-size: 0.78rem; white-space: normal; overflow: visible; text-overflow: unset; text-align: center; }
.timeline-compact .slot-room { display: none; }
.timeline-compact .timeline-header { padding: 5px 4px; font-size: 0.55rem; }

.timeline-mini .timeline-slot { min-width: 40px; padding: 2px; }
.timeline-mini .slot-poster { width: 100%; height: auto; aspect-ratio: 40 / 58; border-radius: 2px; }
.timeline-mini .slot-text { display: none; }
.timeline-mini .slot-movie { flex-direction: column; align-items: center; padding: 1px; gap: 0; }
.timeline-mini .slot-movie + .slot-movie { margin-top: 2px; }
.timeline-mini .timeline-header { padding: 4px 3px; font-size: 0.5rem; letter-spacing: 0.03em; }
.timeline-mini .timeline-slot-time { padding: 2px 4px; }
.timeline-mini .slot-time { font-size: 0.55rem; }
