/* maybemattis.de – base styles (own minimal CSS, no framework).
   Design tokens as custom properties; shared by inventory now and the blog later. */

:root {
    /* Palette */
    --color-bg: #f6f6f4;
    --color-surface: #ffffff;
    --color-surface-2: #efeeeb;
    --color-border: #e0dfda;
    --color-text: #23211c;
    --color-text-muted: #6c6a62;
    --color-accent: #5b4b8a;
    --color-accent-strong: #45376e;
    --color-accent-soft: #ece8f5;
    --color-danger: #a3341f;
    --color-ok: #2f7d4f;

    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas,
        "Liberation Mono", monospace;

    /* Spacing / shape */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
    --content-width: 72rem;
}

/* Section color worlds: MaybeGames reads blue, MaybeMusic green, MaybeMe red.
   Only the three section pages and their reviews carry a tint (base.html sets
   data-section there); the explorer, toplists and inventory keep the neutral
   accent. Every accented element derives from these three tokens, so the whole
   page — nav, links, badges, buttons, focus rings — shifts with the section. */
body[data-section="maybegames"] {
    --color-accent: #2f5fa8;
    --color-accent-strong: #244a82;
    --color-accent-soft: #e5edf7;
}

body[data-section="maybemusic"] {
    --color-accent: #2f7d4f;
    --color-accent-strong: #245f3d;
    --color-accent-soft: #e4f2e9;
}

body[data-section="maybeme"] {
    --color-accent: #a03328;
    --color-accent-strong: #7d2820;
    --color-accent-soft: #f7e8e5;
}

/* The section's own nav entry stays marked while its world is tinted. */
.site-nav a[aria-current="page"] {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Section pages give their heading a colored keel so the world reads at a glance. */
body[data-section] main > h1 {
    display: inline-block;
    border-bottom: 3px solid var(--color-accent);
    padding-bottom: var(--space-2);
}

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

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

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3 {
    line-height: 1.2;
    margin: 0 0 var(--space-3);
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.2rem;
}

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

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.site-header__brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.site-header__brand:hover {
    text-decoration: none;
}

.site-nav {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.site-header__spacer {
    margin-left: auto;
}

.site-header__user {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.linkbutton {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--color-accent);
    cursor: pointer;
}

.linkbutton:hover {
    text-decoration: underline;
}

main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-4) var(--space-8);
}

/* Messages ---------------------------------------------------------------- */

.messages {
    list-style: none;
    margin: 0 0 var(--space-4);
    padding: 0;
}

.messages li {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--color-accent-soft);
    margin-bottom: var(--space-2);
}

/* Buttons / forms --------------------------------------------------------- */

.button {
    display: inline-block;
    padding: var(--space-2) var(--space-4);
    background: var(--color-accent);
    color: #fff;
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font: inherit;
    cursor: pointer;
    text-align: center;
}

.button:hover {
    background: var(--color-accent-strong);
    border-color: var(--color-accent-strong);
    text-decoration: none;
}

.button--ghost {
    background: transparent;
    color: var(--color-accent);
}

.button--ghost:hover {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
}

input[type="text"],
input[type="search"],
input[type="password"],
select {
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
}

input:focus,
select:focus,
.button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    display: block;
    margin-bottom: var(--space-1);
}

/* Card -------------------------------------------------------------------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-6);
}

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

.auth {
    max-width: 24rem;
    margin: var(--space-8) auto;
}

.auth .card {
    display: grid;
    gap: var(--space-3);
}

.auth p {
    margin: 0;
}

.auth input {
    width: 100%;
}

.form-error {
    color: var(--color-danger);
}

.form-success {
    color: var(--color-ok);
}

.form-hint,
.auth .form-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: var(--space-1) 0 0;
}

/* Single sign-on (phase 16). Only rendered while the feature is switched on. */

.auth__sso {
    display: block;
    width: 100%;
}

/* Qualified with .auth on purpose: `.auth p { margin: 0 }` above is more
   specific than a bare class and would otherwise eat the spacing. */

.auth .auth__divider {
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: var(--space-4) 0;
}

.auth .auth__aside {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: var(--space-4);
    text-align: center;
}

/* Filter bar -------------------------------------------------------------- */

.filters {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
}

.filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--space-3);
    align-items: end;
}

.filters__grid input,
.filters__grid select {
    width: 100%;
}

.filters__actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.result-meta {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: var(--space-3);
}

/* Table ------------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

table.games {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

table.games th,
table.games td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    white-space: nowrap;
}

table.games th {
    background: var(--color-surface-2);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table.games tbody tr:hover {
    background: var(--color-accent-soft);
}

table.games td.name {
    white-space: normal;
    min-width: 14rem;
    font-weight: 500;
}

/* Badges ------------------------------------------------------------------ */

.badge {
    display: inline-block;
    padding: 0.05rem var(--space-2);
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.5;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.badge--accent {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border-color: transparent;
}

.badge--ok {
    background: #e4f2e9;
    color: var(--color-ok);
    border-color: transparent;
}

.badge-row {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.muted {
    color: var(--color-text-muted);
}

.rating {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Pagination -------------------------------------------------------------- */

.pagination {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    justify-content: center;
    margin-top: var(--space-6);
}

.pagination__current {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

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

.detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.detail-header .year {
    color: var(--color-text-muted);
    font-size: 1.2rem;
    font-weight: 400;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.detail-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.detail-section h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.deflist {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

.deflist dt {
    color: var(--color-text-muted);
}

.deflist dd {
    margin: 0;
}

.play-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font: inherit;
    cursor: pointer;
}

.play-toggle[aria-pressed="true"] {
    background: #e4f2e9;
    border-color: transparent;
    color: var(--color-ok);
    font-weight: 600;
}

.back-link {
    display: inline-block;
    margin-bottom: var(--space-4);
    font-size: 0.9rem;
}

/* Responsive: stacked table on narrow screens ----------------------------- */

@media (max-width: 640px) {
    table.games thead {
        display: none;
    }

    table.games,
    table.games tbody,
    table.games tr,
    table.games td {
        display: block;
        width: 100%;
    }

    table.games tr {
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        margin-bottom: var(--space-3);
        padding: var(--space-2);
    }

    table.games td {
        border: none;
        white-space: normal;
        display: flex;
        justify-content: space-between;
        gap: var(--space-4);
        padding: var(--space-1) var(--space-2);
    }

    table.games td::before {
        content: attr(data-label);
        color: var(--color-text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    table.games td.name::before {
        content: "";
    }
}

/* Blog: review feed + detail ---------------------------------------------- */

.review-feed {
    display: grid;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.review-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4) var(--space-6);
}

.review-card__title {
    margin: 0 0 var(--space-2);
    font-size: 1.25rem;
}

.review-card__meta,
.review__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-2);
}

.review-card__teaser {
    margin: 0;
}

.review-card__image {
    max-width: 100%;
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
}

.review__head {
    margin-bottom: var(--space-4);
}

.review__header-image {
    max-width: 100%;
    border-radius: var(--radius);
    margin-top: var(--space-3);
}

.review__facts {
    background: var(--color-surface-2);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-6);
}

.review__facts p {
    margin: 0 0 var(--space-1);
}

.review__body,
.review__conclusion {
    max-width: 48rem;
}

/* --- Toplists ------------------------------------------------------------- */

.toplist-entries {
    list-style: none;
    padding: 0;
    display: grid;
    gap: var(--space-4);
    max-width: 48rem;
}

.toplist-entry {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4) var(--space-6);
}

.toplist-entry__title {
    margin: 0 0 var(--space-2);
    font-size: 1.25rem;
}

.toplist-entry__rank {
    color: var(--color-text-muted);
    margin-right: var(--space-1);
}

.toplist-entry__preview {
    max-width: 100%;
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
}

.toplist-entry__description {
    margin: 0;
}

.toplist-entry__tracks {
    margin: var(--space-2) 0 0;
    padding-left: var(--space-4);
}

/* --- Series pages (package G) --------------------------------------------- */

.series-header__image {
    max-width: 100%;
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
}

.series-header__description {
    max-width: 48rem;
    margin-bottom: var(--space-4);
}

.series-games__list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: var(--space-2);
    max-width: 48rem;
}

.series-games__item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-4);
}

.series-games__item .badge {
    text-decoration: none;
}

.series-index {
    list-style: none;
    padding: 0;
    display: grid;
    gap: var(--space-1);
    max-width: 32rem;
}

.series-index__item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border);
}

.series-index__counts {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* --- Markdown content (rendered body texts) --- */

.review__body img,
.toplist-entry__description img {
    max-width: 100%;
    border-radius: var(--radius);
}

.video-embed {
    margin: var(--space-6) 0;
}

.video-embed iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--radius);
}

.video-embed--invalid {
    border: 1px dashed var(--color-danger);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-4);
    color: var(--color-danger);
}

.video-embed--invalid::before {
    content: "⚠ Ungültiger YouTube-Link";
}

/* Album chapter card (::: album directive, package D). The section carries the
   id="album-<slug>" anchor (E3); scroll-margin keeps it clear of the top edge. */
.album-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4) var(--space-6);
    margin: var(--space-6) 0;
    scroll-margin-top: var(--space-6);
}

.album-card--missing {
    border-style: dashed;
    color: var(--color-text-muted);
}

.album-card__placeholder {
    margin: 0;
}

.album-card__head {
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
}

.album-card__cover {
    flex: 0 0 auto;
    width: 9rem;
    max-width: 30%;
    border-radius: var(--radius-sm);
}

.album-card__cover--empty {
    aspect-ratio: 1;
    background: var(--color-surface-2);
}

.album-card__title {
    margin: 0 0 var(--space-1);
    font-size: 1.25rem;
}

.album-card__year {
    color: var(--color-text-muted);
    font-weight: 400;
}

.album-card__composers {
    margin: 0 0 var(--space-2);
}

.album-card__ratings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin: var(--space-2) 0 0;
}

.album-card__tracklist {
    margin-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-3);
}

.album-card__tracklist summary {
    cursor: pointer;
    color: var(--color-text-muted);
}

.album-card__tracklist table {
    width: 100%;
    margin-top: var(--space-2);
    border-collapse: collapse;
    font-size: 0.875rem;
}

.album-card__tracklist td {
    padding: var(--space-1) var(--space-2);
    border-top: 1px solid var(--color-border);
}

.album-card__track-no,
.album-card__track-duration {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.album-card__track-rating {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The tracks tied at the album's best rating stand out in the accent color. */
.album-card__top-track .album-card__track-rating {
    color: var(--color-accent-strong);
    font-weight: 600;
}

/* Inline track chip ([Text](track:<pk>)) — no page behind it (E3), but a
   tooltip with album + rating (title attribute set by the renderer). */
.track-ref {
    color: var(--color-accent-strong);
    font-weight: 500;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: help;
}

/* CSS-only carousel: each image paragraph becomes a snap-scrolled slide. */
.gallery {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: var(--space-2);
    margin: var(--space-6) 0;
}

.gallery p {
    margin: 0;
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.gallery img {
    display: block;
    height: 14rem;
    width: auto;
    border-radius: var(--radius);
}

/* --- MaybeMe: portfolio cards + timeline ---------------------------------- */
.portfolio-group {
    margin-block: var(--space-8);
}

.portfolio-card {
    display: flex;
    gap: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-block: var(--space-4);
}

.portfolio-card__image {
    max-width: 160px;
    border-radius: var(--radius-sm);
    align-self: flex-start;
}

.portfolio-card__date,
.portfolio-card__credits {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.timeline {
    margin-block: var(--space-8);
}

.timeline__list {
    list-style: none;
    padding: 0;
}

.timeline__item {
    position: relative;
    padding-left: var(--space-8);
    padding-bottom: var(--space-6);
    border-left: 2px solid var(--color-accent-soft);
    margin-left: var(--space-2);
}

.timeline__item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 0.3rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent);
}

.timeline__year {
    font-weight: 700;
    color: var(--color-accent-strong);
}

.timeline__kind {
    display: inline-block;
    margin-left: var(--space-2);
    padding: 0 var(--space-2);
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.timeline__title {
    margin: var(--space-2) 0;
}

@media (max-width: 640px) {
    .portfolio-card {
        flex-direction: column;
    }
}

/* --- Self-hosted media (::: video / audio / download, SFTP uploads) ------- */

.media-embed {
    margin: var(--space-6) 0;
}

.media-embed--video video {
    width: 100%;
    max-height: 32rem;
    border-radius: var(--radius);
    background: #000;
}

.media-embed--audio audio {
    width: 100%;
}

.media-embed--invalid {
    border: 1px dashed var(--color-danger);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-4);
    color: var(--color-danger);
}

.media-embed--invalid::before {
    content: "⚠ Ungültige Medien-Angabe";
}

.download {
    margin: var(--space-4) 0;
}

.download__link {
    font-weight: 600;
}

.download__meta {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* --- Album & game detail pages ------------------------------------------- */

.album-page__head,
.game-page__head {
    margin-bottom: var(--space-6);
}

.album-page__head {
    display: flex;
    gap: var(--space-6);
    align-items: flex-start;
    flex-wrap: wrap;
}

.album-page__cover {
    width: 12rem;
    height: 12rem;
    object-fit: cover;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.album-page__cover--empty {
    background: var(--color-surface-2);
}

.album-page__info {
    flex: 1 1 16rem;
}

.album-page__year,
.game-page__year {
    color: var(--color-text-muted);
    font-weight: 400;
}

.album-page__composers {
    margin: var(--space-1) 0 var(--space-3);
}

.album-page__ratings span,
.game-page__facts p {
    margin-right: var(--space-4);
}

.album-page__links {
    margin-top: var(--space-4);
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.game-page__header-image {
    max-width: 100%;
    border-radius: var(--radius);
    margin-top: var(--space-3);
}

.game-page__facts {
    background: var(--color-surface-2);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-6);
}

.game-page__facts p {
    margin: 0 0 var(--space-2);
}

.tracklist {
    width: 100%;
    border-collapse: collapse;
}

.tracklist td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.tracklist__no,
.tracklist__rating,
.tracklist__duration {
    color: var(--color-text-muted);
    white-space: nowrap;
}

.tracklist__rating,
.tracklist__duration {
    text-align: right;
}

.tracklist__top {
    font-weight: 600;
}

.tracklist__artists {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.album-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--space-3);
}

.album-list__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.album-list__cover {
    width: 3rem;
    height: 3rem;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.album-list__title {
    font-weight: 600;
}

.album-list__year {
    color: var(--color-text-muted);
}

.media-library__table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-4);
}

.media-library__table th,
.media-library__table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.media-library__url,
.media-library__snippet {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre;
}

.media-library__size {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .album-page__head {
        flex-direction: column;
    }
}

/* Inventory maintenance forms (phase 11) ---------------------------------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.detail-header__actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.gameform__section {
    margin-bottom: var(--space-4);
}

.gameform__section h2 {
    margin-top: 0;
}

.gameform__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: var(--space-3);
    align-items: start;
}

.gameform__checkgroups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.gameform__checkgroups ul {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
}

.gameform__checkgroups label,
.gameform__checkrow label {
    display: inline;
    color: var(--color-text);
    font-size: 0.95rem;
}

.gameform__checkrow {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.gameform__checkrow .field {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: var(--space-2);
}

.gameform__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
    font: inherit;
    width: 100%;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
}

.field input[type="text"] {
    width: 100%;
}

.field--error input,
.field--error select,
.field--error textarea {
    border-color: var(--color-danger);
}

.field__help {
    margin: var(--space-1) 0 0;
    font-size: 0.8rem;
}

.form-error {
    margin: var(--space-1) 0 0;
    padding-left: var(--space-4);
}

.formset {
    width: 100%;
    border-collapse: collapse;
}

.formset th {
    text-align: left;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
    padding-bottom: var(--space-1);
}

.formset td {
    padding: var(--space-1) var(--space-2) var(--space-1) 0;
    vertical-align: top;
}

.formset select {
    width: 100%;
}

@media (max-width: 640px) {
    .gameform__checkgroups ul {
        columns: 1;
    }
}

/* Game image slots (phase 12) ------------------------------------------- */

.imageform__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: var(--space-4);
}

.imageform__summary {
    display: inline;
    font-size: 1.15rem;
}

.imageslot {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

.imageslot__title {
    margin: 0;
    font-size: 1rem;
}

/* One fixed box for every format, so a 350x500 cover and a 1600x667 header
   sit in the same grid without the rows jumping. */
.imageslot__preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 8rem;
    max-height: 12rem;
    overflow: hidden;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
}

/* The link is a flex item, and a flex item does not shrink below its content
   by default — a 1600 px header would be clipped by the overflow above instead
   of scaled down. */
.imageslot__preview a {
    display: block;
    min-width: 0;
    max-width: 100%;
}

.imageslot__preview img {
    display: block;
    max-width: 100%;
    max-height: 12rem;
    object-fit: contain;
}

.imageslot__meta {
    margin: 0;
    font-size: 0.8rem;
}

.imageslot__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.imageslot--broken .imageslot__preview {
    border: 1px dashed var(--color-danger);
}

.imageslot input[type="file"],
.field input[type="file"] {
    font: inherit;
    width: 100%;
    font-size: 0.85rem;
}

/* IGDB lookup (phase 13) ------------------------------------------------- */

.igdb-candidates {
    display: grid;
    gap: var(--space-3);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
}

.igdb-candidate {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}

.igdb-candidate__cover {
    flex: 0 0 auto;
    width: 6rem;
    height: auto;
    border-radius: var(--radius-sm);
}

/* min-width: 0 so a long IGDB summary wraps instead of stretching the card. */
.igdb-candidate__body {
    min-width: 0;
}

/* `.badge-row` is inline-flex, and `game_list.html` needs it that way. Here it
   is the last thing above the button whenever IGDB has neither a description
   nor platforms for an entry — and then the button crept up beside the badge.
   Block-level flex only inside a candidate keeps both happy. */
.igdb-candidate__body .badge-row {
    display: flex;
}

.igdb-candidate__body h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

/* The comparison table is the one wide thing on the page; let it scroll on its
   own rather than pushing the whole layout sideways on a phone. */
.igdb-diff {
    display: block;
    overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-3) 0;
}

.igdb-diff th,
.igdb-diff td {
    padding: var(--space-2);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border);
}

.igdb-diff__row--blocked {
    opacity: 0.6;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* IGDB matching (phase 14, temporary) -------------------------------------
   Delete this block together with the screen it styles; the removal list is in
   TODOs/14_curation_followup.md. */

.match__intro {
    max-width: 60ch;
    margin-bottom: var(--space-6);
}

table.match th,
table.match td {
    vertical-align: top;
    white-space: normal;
}

/* The row header is a title, not a column label — undo table.games th. */
table.match th[scope="row"] {
    width: 32%;
    background: transparent;
    color: var(--color-text);
    font-size: 0.92rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

.match__links {
    display: block;
    margin-top: var(--space-1);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.match__form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.match__form input {
    flex: 1 1 18rem;
    min-width: 12rem;
}

.match__action p {
    margin: var(--space-2) 0 0;
    font-size: 0.85rem;
}

.match__error {
    color: var(--color-danger);
}

.match__row--error {
    background: #fdf1ee;
}

.match__suggest {
    width: 34%;
    font-size: 0.85rem;
}

.match__waiting {
    margin: 0;
    font-size: 0.85rem;
}

/* The main-game suggestions: a short list of names to press, not a menu. */
.match__parents {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.match__parents form {
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
}

.match__parents .linkbutton {
    text-align: left;
}

.match__state {
    margin: 0 0 var(--space-2);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.match__state--sure {
    color: var(--color-ok);
}

.match__state--unsure {
    color: var(--color-text-muted);
}

.match__picks {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--space-2);
}

.match__pick {
    padding: var(--space-1) var(--space-2);
    border-left: 3px solid transparent;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
}

.match__pick--fits {
    border-left-color: var(--color-ok);
}

/* A link in behaviour, a button in markup: it changes the field, it does not
   navigate — so it must be reachable by keyboard and announced as a control. */
.match__pickname {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}

.match__pickname:hover,
.match__pickname:focus-visible {
    text-decoration: underline;
}

.match__meta {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.78rem;
}

/* The strip of open piles, shown on every curation screen. Each tab carries
   its count, so a pile that filled up while somebody worked on another one
   says so instead of waiting to be found. */
.match__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.match__tab {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4em;
    padding: 0.35em 0.8em;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.match__tab:hover,
.match__tab:focus-visible {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.match__tab--active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: var(--color-on-accent, #fff);
    font-weight: 600;
}

.match__tab--empty {
    opacity: 0.55;
}

.match__tabcount {
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
}

/* The two years side by side, with the gap that made the row a question. */
.match__years {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6em;
    font-variant-numeric: tabular-nums;
}

.match__gap {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.match__id {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 40rem) {
    table.match th[scope="row"],
    .match__suggest {
        width: auto;
    }
}
