:root {
    --bg-color: #212121;
    --fg-color: #f9f9f0;
    --link-color: rgb(124, 124, 255);
    --visited-link-color: rgb(200, 126, 200);
    --surface-color: #333;
    --border-color: #444;
}

html {
    overflow-x: hidden;
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    color: var(--fg-color);
    overflow-x: hidden;
    max-width: 100vw;
}

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

img {
    max-width: 100%;
}

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

a:visited {
    color: var(--visited-link-color);
}

form {
    margin: 0;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

header a {
    text-decoration: none;
    color: inherit;
    margin-right: 1rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hamburger-btn,
.icon-btn {
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
}

.hamburger-btn {
    font-size: 1.75rem;
}

/* hamburger nav drawer, toggled with a hidden checkbox so no js is needed */
.nav-toggle {
    display: none;
}

.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 220px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.nav-section:last-child {
    border-bottom: none;
}

.nav-scrim {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 10;
}

.nav-toggle:checked ~ .nav-drawer {
    transform: translateX(0);
}

.nav-toggle:checked ~ .nav-scrim {
    display: block;
}

/* modal, same checkbox-toggle pattern as the nav drawer - opened by a
   label with an hx-get that loads content into .modal-box as it's toggled */
.modal-toggle {
    display: none;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    align-items: center;
    justify-content: center;
}

.modal-scrim {
    position: fixed;
    inset: 0;
}

.modal-box {
    position: relative;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    padding-top: 3rem;
    max-width: 500px;
    width: calc(100vw - 2rem);
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 31;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.modal-box h2 {
    margin-top: 0;
    padding-right: 2.5rem;
}

.modal-toggle:checked ~ .modal-overlay {
    display: flex;
}

/* hides activity fields in the add-movie form until "log an activity" is
   picked - the radio's wrapping .form-group needs :has() so a plain sibling
   combinator can reach it */
.collapsible-fields {
    display: none;
}

.form-group:has(#action-activity:checked) ~ .collapsible-fields {
    display: block;
}

.flash-messages .alert {
    background: var(--surface-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.login-container {
    max-width: 300px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    box-sizing: border-box;
    background: var(--surface-color);
    color: var(--fg-color);
    border: 1px solid var(--border-color);
    /* iOS Safari zooms the page in on focus if an input's font-size is
       under 16px - keep this at/above 16px so focusing never zooms */
    font-size: 16px;
    font-family: inherit;
}

.btn {
    display: inline-block;
    box-sizing: border-box;
    padding: 0.5rem 1rem;
    text-decoration: none;
    background: transparent;
    color: var(--fg-color);
    border: 1px solid var(--fg-color);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.25;
    vertical-align: middle;
    margin: 0;
}

.btn:link,
.btn:visited {
    color: var(--fg-color);
}

.btn-danger,
.btn-danger:link,
.btn-danger:visited {
    color: #ff8080;
    border-color: #ff8080;
}

/* a row of buttons/button-wrapping forms that sit on the same baseline with
   even spacing - use this instead of one-off inline styles on forms */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-row form {
    margin: 0;
    display: contents;
}

/* media card - used for tmdb search results, and anywhere a poster+title
   grid is shown */
.media-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.media-card a {
    text-decoration: none;
    color: inherit;
}

.media-card-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    background: var(--surface-color);
    border-radius: 4px;
    overflow: hidden;
}

.media-card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-card-placeholder {
    width: 100%;
    height: 100%;
    background: var(--surface-color);
}

.media-card-check {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--bg-color);
    color: var(--fg-color);
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-card-title {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.media-card-badge {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* list row - poster+title up top, controls below, so buttons never have to
   compete with the title for width on narrow screens */
.list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.list-row-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 100%;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.list-row-poster {
    width: 50px;
    aspect-ratio: 2 / 3;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.list-row-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.list-row-title {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.list-row-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 100%;
    margin-left: calc(50px + 0.75rem);
}

.list-row-position {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.list-row-position .form-control {
    width: 4rem;
}

/* activity timeline - what happened, when, and the note, with a small
   poster thumbnail alongside instead of just a check mark */
.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item-poster {
    width: 42px;
    aspect-ratio: 2 / 3;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.activity-item-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.activity-item-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.activity-item-summary {
    margin: 0;
}

.activity-item-notes {
    margin: 0.25rem 0 0;
    opacity: 0.85;
}

.in-list-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}
