:root {
    --guide-nav-height: 52px;
}

html {
    scroll-padding-top: var(--guide-nav-height);
}

html,
body {
    overflow-x: clip;
}

body {
    letter-spacing: 0;
}

main {
    max-width: 1100px;
    overflow: visible;
}

section[id] {
    scroll-margin-top: 16px;
}

a {
    color: var(--gold);
    overflow-wrap: anywhere;
}

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 4px;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    padding: 10px 16px;
    background: var(--panel);
    color: var(--ink);
    z-index: 20;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

nav {
    max-width: 100%;
}

nav a {
    padding: 6px 0;
    overflow-wrap: normal;
}

.hero {
    flex-wrap: wrap;
}

.hero>div {
    min-width: 0 !important;
}

.card-zoom {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    color: inherit;
    cursor: zoom-in;
    aspect-ratio: 488 / 680;
}

.card-zoom img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0;
}

.hero>.card-zoom {
    flex: 0 0 auto;
    width: min(280px, 100%);
}

.card-zoom .card-img:hover {
    transform: none;
    box-shadow: none;
    position: static;
}

.card-zoom:focus-visible {
    outline-offset: -4px;
}

.card-zoom.is-unavailable {
    min-height: 120px;
    background: var(--panel);
}

.grid {
    grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
}

.c .body,
.c .nm,
.c .ty {
    overflow-wrap: anywhere;
}

.badge {
    letter-spacing: 0;
}

.mechanic-en {
    font-size: .78em;
    font-weight: normal;
    color: var(--muted);
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.table-scroll table {
    width: 100%;
}

.deck-search {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin: 20px 0;
}

.deck-search label {
    display: grid;
    gap: 6px;
    flex: 1 1 260px;
    font-size: .9rem;
    color: var(--muted);
}

.deck-search input {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--muted);
    border-radius: 6px;
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--panel);
}

.deck-search [role="status"] {
    min-width: 15ch;
    padding: 10px 0;
    font-size: .85rem;
    color: var(--muted);
}

.card-dialog {
    width: min(580px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--muted);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
}

.card-dialog::backdrop {
    background: rgb(0 0 0 / 78%);
}

.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.dialog-heading h2 {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 1.1rem;
    overflow-wrap: anywhere;
}

.dialog-close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--muted);
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font: 1.7rem Georgia, serif;
}

.card-dialog>img {
    display: block;
    width: 100%;
    height: min(680px, calc(100dvh - 150px));
    object-fit: contain;
    border-radius: 8px;
}

.card-dialog>a {
    display: block;
    margin-top: 8px;
    text-align: center;
    font-size: .85rem;
}

body:has(.card-dialog[open]) {
    overflow: hidden;
}

@media (max-width: 700px) {

    /* Stacked tables: each row becomes a card, each cell shows its column
       header (stamped as data-th by guide.js). Rows with their own TH
       (key/value tables) use it as the card label instead. */
    .table-scroll {
        overflow-x: visible;
    }

    .table-scroll table {
        display: block;
        font-size: .9rem;
    }

    .table-scroll thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .table-scroll tbody {
        display: block;
    }

    .table-scroll tr {
        display: block;
        margin-bottom: 14px;
        padding: 4px 14px 10px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 10px;
    }

    .table-scroll tr:not(:has(td)) {
        display: none;
    }

    .table-scroll td {
        display: block;
        padding: 8px 0;
        border-bottom: 0;
        overflow-wrap: anywhere;
    }

    .table-scroll td + td,
    .table-scroll tr > th + td {
        border-top: 1px solid var(--line);
    }

    .table-scroll td[data-th] {
        display: grid;
        grid-template-columns: minmax(96px, 38%) 1fr;
        gap: 2px 12px;
    }

    .table-scroll td[data-th]::before,
    .table-scroll tr > th {
        font-size: .72rem;
        font-weight: 600;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .table-scroll td[data-th]::before {
        content: attr(data-th);
        padding-top: 2px;
    }

    .table-scroll tr > th {
        display: block;
        padding: 10px 0 0;
        border-bottom: 0;
    }

    nav {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        gap: 18px;
        padding: 6px 16px;
        overscroll-behavior-x: contain;
    }

    nav a {
        flex: 0 0 auto;
        white-space: nowrap;
        min-height: 36px;
    }

    .hero {
        flex-direction: column;
        align-items: center;
    }

    .hero>div {
        width: 100%;
    }

    .hero img {
        max-width: 280px;
    }

    h1 {
        font-size: 1.7rem;
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

@media print {

    nav,
    .skip-link,
    .deck-search,
    .card-dialog {
        display: none !important;
    }

    #cartas [hidden] {
        display: block !important;
    }

    .c,
    .callout {
        break-inside: avoid;
    }
}
