/*
 * Hresh's three reference pages: How To Play (guide), Patch Notes, and
 * Information. Their content is components/HreshHomeContentPartials.html,
 * which hresh.com and hresh.io both include, and whose scripts (the
 * Classic/Arcade switch, the patch version menu) find things by class and
 * id. So this file styles that markup as it is rather than renaming it.
 *
 * Everything is scoped under .hresh-doc, the <main> these pages use.
 */
@layer page {
    /* ---------- heading ---------- */

    .hresh-doc .header-container {
        margin-bottom: var(--s-7);
    }

    .hresh-doc .header-center {
        font-family: var(--font-pixel);
        font-weight: 400;
        font-size: clamp(18px, 0.7rem + 1.2vw, 28px);
        line-height: 1.6;
        letter-spacing: 0;
        text-shadow: 3px 3px 0 var(--blood-deep);
    }

    /* ---------- panels ---------- */

    .hresh-doc .content-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
        align-items: start;
        gap: var(--s-6);
    }

    /* How To Play: the quick guide is a fifth the height of the two panels
       after it. Where only two columns fit it takes a row of its own, so
       the two long panels sit side by side instead of each beside nothing.
       Measured on the page's own width, not the screen's: three 340px
       columns and their two gaps need 1084px, and hresh.io's side dock
       takes some of the screen. */
    .hresh-doc {
        container-type: inline-size;
    }

    @container (max-width: 1083.98px) {
        .hresh-doc #quick-guide-panel {
            grid-column: 1 / -1;
        }
    }

    .hresh-doc .game-mode-panel,
    .hresh-doc .maintenance-section,
    .hresh-doc .patch-notes {
        padding: clamp(20px, 3vw, 32px);
        background: linear-gradient(180deg, var(--panel-hi), var(--panel));
        box-shadow:
            0 calc(var(--px) * -1) 0 0 var(--line-strong),
            0 var(--px) 0 0 var(--line-strong),
            calc(var(--px) * -1) 0 0 0 var(--line-strong),
            var(--px) 0 0 0 var(--line-strong);
    }

    .hresh-doc h2 {
        margin-bottom: var(--s-4);
        font-family: var(--font-pixel);
        font-weight: 400;
        font-size: 12px;
        line-height: 1.6;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--gold);
    }

    .hresh-doc .panel-content h2:not(:first-child),
    .hresh-doc .patch-notes h2:not(:first-child) {
        margin-top: var(--s-6);
    }

    .hresh-doc p {
        color: var(--ink-soft);
    }

    /* ---------- lists ---------- */

    .hresh-doc .feature-list,
    .hresh-doc .guide-list,
    .hresh-doc .patch-list {
        display: grid;
        gap: var(--s-3);
        margin: 0;
        padding-left: 1.2rem;
        font-size: var(--text-sm);
        line-height: 1.65;
        color: var(--ink-soft);
    }

    .hresh-doc li::marker {
        color: var(--gold);
    }

    .hresh-doc .feature-link,
    .hresh-doc .content-container a:not([class]) {
        color: var(--gold);
        text-decoration: underline;
        text-decoration-color: rgb(245 212 112 / 0.4);
        text-underline-offset: 3px;
    }

    .hresh-doc .feature-link:hover {
        text-decoration-color: var(--gold);
    }

    .hresh-doc .game-over-text {
        font-weight: 700;
        color: var(--blood-hi);
    }

    .hresh-doc .end-text {
        font-weight: 700;
        color: var(--gold);
    }

    /* ---------- guide: Classic / Arcade switch ---------- */

    .hresh-doc .panel-toggle {
        display: inline-flex;
        align-items: center;
        margin-bottom: var(--s-5);
        box-shadow: 0 0 0 2px var(--line-strong);
    }

    .hresh-doc .toggle-btn {
        min-height: 40px;
        padding: 0 var(--s-5);
        font-family: var(--font-pixel);
        font-size: 9px;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--muted);
        transition:
            color var(--fast),
            background-color var(--fast);
    }

    .hresh-doc .toggle-btn:hover {
        color: var(--ink);
    }

    .hresh-doc .toggle-btn.active {
        color: var(--gold-ink);
        background: var(--gold);
    }

    .hresh-doc .toggle-divider {
        width: 2px;
        align-self: stretch;
        background: var(--line-strong);
    }

    /* ---------- guide: characters and enemies ---------- */

    .hresh-doc .character-list {
        display: grid;
        gap: var(--s-6);
    }

    .hresh-doc .character-item {
        display: grid;
        grid-template-columns: 64px minmax(0, 1fr);
        align-items: start;
        gap: var(--s-4);
        padding-bottom: var(--s-6);
        border-bottom: 1px solid var(--line);
    }

    .hresh-doc .character-item:last-child {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .hresh-doc .character-image {
        width: 64px;
        height: 64px;
        image-rendering: pixelated;
        background: var(--bg-deep);
        box-shadow: 0 0 0 1px var(--line);
    }

    .hresh-doc .character-info {
        display: grid;
        gap: var(--s-3);
    }

    .hresh-doc .character-info h3 {
        font-size: var(--text-md);
    }

    .hresh-doc .character-info p {
        font-size: var(--text-sm);
        line-height: 1.6;
    }

    .hresh-doc .character-stats {
        display: grid;
        /* two columns where a label and its value fit on one line, one
           column where they would not */
        grid-template-columns: repeat(auto-fit, minmax(min(100%, max(8rem, (100% - var(--s-4)) / 2)), 1fr));
        gap: 2px var(--s-4);
        font-size: var(--text-xs);
    }

    .hresh-doc .stat-item {
        display: flex;
        justify-content: space-between;
        gap: var(--s-2);
        padding: 4px 0;
        border-bottom: 1px dotted var(--line);
    }

    .hresh-doc .stat-label {
        white-space: nowrap;
        color: var(--muted);
    }

    .hresh-doc .stat-value {
        font-weight: 700;
        color: var(--sapphire-pale);
        font-variant-numeric: tabular-nums;
    }

    .hresh-doc .special-ability,
    .hresh-doc .ascension-ability,
    .hresh-doc .threat-level {
        padding: var(--s-3) var(--s-4);
        font-size: var(--text-xs);
        line-height: 1.55;
        color: var(--ink-soft);
        background: rgb(9 95 143 / 0.16);
        border-left: 2px solid var(--sapphire-hi);
    }

    /* these sit inside the stats grid; give them the full row */
    .hresh-doc .character-stats > .special-ability,
    .hresh-doc .character-stats > .ascension-ability,
    .hresh-doc .character-stats > .threat-level {
        grid-column: 1 / -1;
        margin-top: var(--s-2);
    }

    /* Enemy names carry their colour inline, chosen for a light page. The
       dark red and dark gold are lifted so they read on the dark one. */
    .hresh-doc h3 span[style*="8B0000"] {
        color: var(--blood-hi) !important;
    }

    .hresh-doc h3 span[style*="B8860B"] {
        color: var(--gold) !important;
    }

    /* The same class is also used for a sentence inside a callout (Rook's
       heal). There it is running text: coloured, and no box of its own. */
    .hresh-doc span.threat-level {
        padding: 0;
        font-size: inherit;
        font-weight: 700;
        color: var(--blood-hi);
        background: none;
        border: 0;
    }

    .hresh-doc .ascension-ability {
        background: rgb(245 212 112 / 0.08);
        border-left-color: var(--gold);
    }

    .hresh-doc .threat-level {
        background: rgb(194 45 35 / 0.12);
        border-left-color: var(--blood-hi);
    }

    /* ---------- patch notes ---------- */

    .hresh-doc .patch-container {
        display: grid;
        gap: var(--s-6);
        max-width: 52rem;
    }

    .hresh-doc .maintenance-window {
        display: flex;
        flex-wrap: wrap;
        gap: var(--s-2) var(--s-6);
        margin-top: var(--s-4);
        font-family: var(--font-pixel);
        font-size: 9px;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .hresh-doc .maintenance-window span {
        color: var(--gold);
    }

    /* the version menu */
    .hresh-doc .dropdown-container {
        position: relative;
        display: inline-block;
    }

    .hresh-doc .patch-notes-pill {
        display: inline-flex;
        align-items: stretch;
        min-height: 44px;
        font-family: var(--font-pixel);
        font-size: 10px;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--gold-ink);
        background: var(--gold);
        box-shadow:
            0 calc(var(--px) * -1) 0 0 var(--gold-hi),
            0 var(--px) 0 0 var(--gold-hi),
            calc(var(--px) * -1) 0 0 0 var(--gold-hi),
            var(--px) 0 0 0 var(--gold-hi),
            0 5px 0 0 #6b5310;
    }

    .hresh-doc .pill-left,
    .hresh-doc .pill-right {
        display: flex;
        align-items: center;
        padding: 0 var(--s-4);
    }

    .hresh-doc .pill-right {
        border-left: 2px solid rgb(29 21 3 / 0.3);
    }

    .hresh-doc .arrow {
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid currentColor;
        transition: transform var(--fast);
    }

    .hresh-doc .dropdown-container.active .arrow {
        transform: rotate(180deg);
    }

    .hresh-doc .dropdown-menu {
        position: absolute;
        left: 0;
        top: calc(100% + 12px);
        z-index: 10;
        display: none;
        min-width: 100%;
        padding: var(--s-1);
        background: var(--bg-deep);
        box-shadow:
            0 0 0 2px var(--gold),
            var(--shadow);
    }

    .hresh-doc .dropdown-container.active .dropdown-menu {
        display: block;
    }

    .hresh-doc .dropdown-option {
        padding: 10px var(--s-4);
        font-size: var(--text-sm);
        white-space: nowrap;
        color: var(--ink-soft);
        cursor: pointer;
        /* the open list is scrolled into view clear of a bottom dock */
        scroll-margin-bottom: calc(var(--dock-bottom, 0px) + var(--s-3));
    }

    .hresh-doc .dropdown-option:hover,
    .hresh-doc .dropdown-option:focus-visible {
        color: var(--gold);
        background: rgb(245 212 112 / 0.08);
    }

    /* the version being shown */
    .hresh-doc .dropdown-option[aria-current] {
        color: var(--gold);
        box-shadow: inset 2px 0 0 var(--gold);
    }

    /* ---------- last updated ---------- */

    .hresh-doc .last-updated-container {
        margin-top: var(--s-7);
    }

    .hresh-doc .last-updated-text {
        font-family: var(--font-pixel);
        font-size: 8px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--dim);
    }

    .hresh-doc .last-updated-date {
        color: var(--muted);
    }
}

@media (max-width: 480px) {
    @layer page {
        .hresh-doc .character-stats {
            grid-template-columns: 1fr;
        }
    }
}
