/* --- Fonts --- */

@font-face {
    font-family: "Roboto Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/RobotoMono-Regular.woff2") format("woff2");
}

@font-face {
    font-family: "Roboto Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/RobotoMono-Medium.woff2") format("woff2");
}

/* --- CSS Variables --- */

:root {
    --color-bg: hsl(45, 25%, 95%);
    --color-overlay: hsl(45, 25%, 85%);
    --color-primary: hsl(250, 25%, 10%);
    --color-secondary: hsl(250, 12.5%, 40%);
    --font-size-sm: 0.875rem;
}

/* --- Reset & Base --- */

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

html {
    background: var(--color-bg);
    font-size: 16px;
}

body {
    color: var(--color-primary);
    font-family: "Roboto Mono", monospace;
    line-height: 1.5;
    padding: 8rem 0;
    letter-spacing: -0.04rem;
}

body.modal-open {
    position: fixed;
    overflow-y: scroll;
    width: 100%;
}

button {
    letter-spacing: inherit;
    font-size: inherit;
    font-family: inherit;
}

::selection {
    background: hsl(245, 25%, 85%);
}

::backdrop {
    background: var(--color-bg);
    opacity: 0.7;
}

/* --- Layout --- */

header,
main,
footer {
    margin: auto;
    max-width: 540px;
    width: 100%;
}

main {
    padding-bottom: 5rem;
}

/* --- Typography --- */

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-primary);
    font-size: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: white;
    text-decoration-thickness: 2px;
    text-underline-offset: 1px;
}

h1,
h2,
h3,
h4,
h5,
h6,
h1 a,
h2 a,
h3 a,
h4 a,
h5 a,
h6 a {
    color: inherit;
}

h1 {
    font-size: 2rem;
}

h1,
h2 {
    line-height: 1.2;
}

h2 {
    padding-bottom: 1rem;
}

h3 {
    text-decoration: none;
    margin-bottom: 0.25rem;
}

small {
    font-size: var(--font-size-sm);
}

/* --- Header --- */

header {
    padding-bottom: 2.5rem;
}

header h1 {
    padding-bottom: 0.25rem;
}

header h1 + small:has(+ p) {
    display: inline-block;
    padding-bottom: 1.5rem;
}

header:has(h2) {
    padding-bottom: 1rem;
}

/* --- Navigation --- */

nav {
    padding-bottom: 2.5rem;
}

nav a {
    text-decoration: none;
}

/* Sort Options Nav */

nav.sort-options > a,
nav.sort-options > span {
    display: grid;
    grid-template-columns: 2ch 1fr;
}

nav.sort-options span span::before {
    content: "\2192";
}

nav.sort-options span {
    color: var(--color-primary);
    font-weight: 500;
}

/* All Items Nav (Dates, Movies, Theaters) */

nav.all-dates,
nav.all-movies,
nav.all-theaters {
    gap: 0.25rem;
    padding-bottom: 1.5rem;
}

nav.all-movies,
nav.all-theaters {
    display: flex;
    flex-direction: column;
}

nav.all-dates {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
}

nav > a.movie,
nav > a.date,
nav > a.theater {
    font-weight: 500;
}

nav > a.movie,
nav > a.theater {
    padding-right: 2ch;
}

nav:has(> a.movie) a,
nav:has(> a.date) a,
nav:has(> a.theater) a {
    color: var(--color-primary);
    text-decoration: none;
    background: var(--color-overlay);
}

/* --- Links --- */

a {
    color: var(--color-secondary);
}

a.active {
    color: var(--color-primary);
}

a.external:hover {
    opacity: 1;
}

/* Time Links */

a.time {
    color: var(--color-primary);
    background: var(--color-overlay);
    white-space: nowrap;
    text-decoration: none;
    font-size: var(--font-size-sm);
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: 500;
    position: relative;
    top: -1px;
}

a.time:hover {
    background: var(--color-primary);
    color: white;
}

.times {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

span.times {
    display: inline-flex;
    gap: 0.25rem;
}

/* --- Content Sections --- */

section > .date-group,
section > .movie-group,
section > .theater-group {
    padding: 1.5rem 0;
}

section > .date-group h2,
section > .movie-group h2,
section > .theater-group h2 {
    color: var(--color-primary);
    font-size: 1.5rem;
    padding-bottom: 0.25rem;
}

section > .theater-group h2:has(+ span.age-range) {
    display: inline-block;
}

/* Nested Groups */

.movie-group:not(section > .movie-group),
.theater-group:not(section > .theater-group),
.date-group:not(section > .date-group) {
    margin-bottom: 1rem;
}

.movie-group:not(section > .movie-group):last-child,
.theater-group:not(section > .theater-group):last-child,
.date-group:not(section > .date-group):last-child {
    margin-bottom: 0;
}

/* --- UI Components --- */

/* Age Range Badge */

span.age-range {
    cursor: default;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 10px;
    background: var(--color-badge);
    color: var(--color-primary);
    position: relative;
    top: -3px;
    clip-path: polygon(
        5px 0%,
        calc(100% - 5px) 0%,
        100% 50%,
        calc(100% - 5px) 100%,
        5px 100%,
        0% 50%
    );
}

/* Info Button */

div:has(> .info-btn) h2 {
    display: inline-block;
}

.info-btn {
    background: transparent;
    border: none;
    color: var(--color-secondary);
    cursor: pointer;
    font-size: var(--font-size-sm);
    padding: 0;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.info-btn::before {
    content: "[";
}

.info-btn::after {
    content: "]";
}

.info-btn::before,
.info-btn::after {
    color: var(--color-primary);
}

.info-btn:hover {
    color: var(--color-primary);
}

/* --- Movie Dialog (Modal) --- */

.movie-dialog {
    max-width: 540px;
    width: 90%;
    max-height: 90dvh;
    margin: auto;
    padding: 1.5rem;
    background: var(--color-bg);
    border: 1px solid;
    border-radius: 6px;
    box-shadow: 0 2px 1rem rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    overflow-x: hidden;
}

form[method="dialog"]:has(.modal-close) {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.modal-close {
    border: none;
    font-size: 1.5rem;
    color: var(--color-primary);
    padding: 0 10px;
    cursor: pointer;
    background: none;
}

.modal-body h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: white;
    text-decoration-thickness: 2px;
}

.modal-body strong {
    color: var(--color-primary);
    font-weight: 500;
}

.modal-poster {
    width: 100%;
    max-width: 160px;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 6px;
    border: 2px solid var(--color-overlay);
    opacity: 0.9;
}

.movie-dialog .synopsis {
    padding-bottom: 1rem;
}

/* --- Confirmation Dialog --- */

.confirm-dialog {
    max-width: 480px;
    width: 90%;
    margin: auto;
    padding: 1.5rem;
    background: var(--color-bg);
    border: 1px solid;
    border-radius: 6px;
    box-shadow: 0 2px 1rem rgba(0, 0, 0, 0.3);
}

.external-note {
    display: block;
    color: var(--color-secondary);
    text-align: center;
}

#confirm-details:has(+ .dialog-buttons) {
    margin-bottom: 1.5rem;
}

.dialog-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dialog-buttons:has(+ .external-note) {
    margin-bottom: 1.5rem;
}

.dialog-btn {
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.cancel-btn {
    background: var(--color-bg);
    color: var(--color-primary);
    border: 1px solid var(--color-secondary);
}

.cancel-btn:hover {
    background: var(--color-primary);
    color: white;
    border: 1px solid var(--color-primary);
}

.confirm-btn {
    background: var(--color-overlay);
    color: var(--color-primary);
}

.confirm-btn:hover {
    background: var(--color-primary);
    color: white;
}

/* --- Back to Top Button --- */

.back-to-top {
    position: fixed;
    bottom: 0;
    right: 2rem;
    background: var(--color-primary);
    border-radius: 6px 6px 0 0;
    color: white;
    border: none;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
    z-index: 999;
    opacity: 0;
    transform: translateY(32px);
    pointer-events: none;
    padding: 0.5rem 1rem;
}

.back-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top span {
    display: block;
    line-height: 1;
}

/* --- Utilities --- */

.movie-group .date {
    color: var(--color-secondary);
}

.arrow {
    color: var(--color-primary);
}

/* --- Responsive --- */

@media only screen and (max-width: calc(540px + 2rem)) {
    body {
        padding: 3rem 1rem;
    }

    nav.all-dates {
        grid-template-columns: repeat(7, 1fr);
    }

    .back-to-top {
        right: 1rem;
    }

    .movie-dialog,
    .confirm-dialog {
        padding: 1rem;
    }

    .movie-dialog form {
        top: 0.5rem;
        right: 0.5rem;
    }

    .modal-body h3,
    .confirm-dialog h3 {
        margin-bottom: 0.75rem;
    }

    .modal-poster {
        max-width: 120px;
    }

    .movie-dialog .synopsis {
        padding-bottom: 0.75rem;
    }

    #confirm-details:has(+ .dialog-buttons) {
        margin-bottom: 1.25rem;
    }

    .dialog-buttons:has(+ .external-note) {
        margin-bottom: 1.25rem;
    }
}

@media only screen and (max-width: calc(480px + 2rem)) {
    nav.all-dates {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media only screen and (max-width: calc(420px + 2rem)) {
    nav.all-dates {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media only screen and (max-width: calc(360px + 2rem)) {
    nav.all-dates {
        grid-template-columns: repeat(4, 1fr);
    }
}
