/* ---------- Fonts ---------- */

@font-face {
    font-family: "Goodmountain";
    src: url("fonts/Goodmountain.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

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

/* ---------- Colours, fonts and sizes ---------- */

:root {
    color-scheme: dark;
    /* Base colours */
    --iron: #161514; /* page background 161514*/
    --iron-raised: #201e1d; /* search boxes, chart bar tracks and the hover on feed rows */
    --panel: rgba(32, 30, 29, 0.82); /* cards and rows, slightly see-through */
    --spotlight: #262321; /* spotlight cards, a step lighter than the other cards */
    --bone: #e6e3e0; /* main text */
    --ash: #a29f9f; /* secondary text */
    --line: #2a2725; /* dividers and the outline around stat cards */
    --edge: #383634; /* outlines around spotlight cards, buttons and table rows */
    /* Accent colours, one job each */
    --accent-line: #c41f3b; /* the line under the menu, the Hottest Rivalry card's top edge, and the trim on cards with no class colour. Discord's card colour is in post-takeovers.js */
    --heading: #e6e3e0; /* section heading text */
    --heading-trim: #c9a24a; /* the short underline and diamond under section headings */
    --highlight: #c9a24a; /* headline values, spotlight top edges, gold pills, sort headings, crowns */
    --button: #c9a24a; /* the open menu page, selected buttons, hover outlines, keyboard focus */
    /* Composition chart colours. Class uses the class colours and Role the role colours below. */
    --chart-class: #c9a24a; /* Class bars, for a class with no colour below */
    --chart-class-strength: 90%; /* how much class colour the Class bars keep: 100% is full, lower is dimmer */
    --chart-race: #c9a24a; /* Race bars */
    --chart-level: #d13f17; /* Level bars */
    --chart-professions: #6f9a4c; /* Professions bars */
    --chart-rank: #8a7fc9; /* Rank bars */
    --chart-none: #5f5d5b; /* "Unknown" bars */
    /* Role colours, named after the role in lowercase */
    --role-tank: #4a9eff; /* Shaman blue */
    --role-healer: #00ff98; /* Monk green */
    --role-dps: #e0435a; /* Death Knight red */
    /* Journeys timeline colours, named after the event's pill in lowercase. They colour the dot, the pill
       and the highlighted words. A label with no colour here uses --highlight. */
    --event-level: #c9a24a;
    --event-gear: #3b8ff0; /* WoW's rare blue, lightened to read on the dark rows */
    --event-achievement: #b066f0; /* WoW's epic purple, lightened to match */
    --event-lead: #e0435a;
    --event-guild: #4fbf6a;
    /* Class colours, named after the class in lowercase with hyphens. A missing class shows in the main text colour. */
    --class-warrior: #c69b6d;
    --class-paladin: #f48cba;
    --class-hunter: #aad372;
    --class-rogue: #fff468;
    --class-priest: #ffffff;
    --class-shaman: #4a9eff;
    --class-mage: #3fc7eb;
    --class-warlock: #9fa0f5;
    --class-druid: #ff7c0a;
    --class-death-knight: #e0435a;
    --class-demon-hunter: #c26fe0;
    --class-monk: #00ff98;
    --class-evoker: #4fc2a8;
    --display: "Goodmountain", "Palatino Linotype", Georgia, serif; /* headings and menu */
    --body: "Alegreya", Georgia, "Times New Roman", serif; /* everything else */
    /* Sizes */
    --page-width: 1200px; /* width of the page content and the menu row */
    --avatar-size: 40px; /* portraits in table and feed rows. Phones have their own size under "Phones". */
    --avatar-tint: 16%; /* how much class colour fills the initials box shown without a portrait: higher is stronger */
    --tint-strength: 0.13; /* the faint class-colour tints: leaderboard row bars and the Journeys chart fill */
    --compare-strength: 0.6; /* the compare player's line on the Journeys chart: 1 is full class colour, lower is fainter */
}

/* ---------- Base ---------- */

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

/* The grain texture covers the whole page */
body {
    margin: 0;
    background: var(--iron) url("images/bg-grain.png") repeat;
    color: var(--bone);
    font-family: var(--body);
    font-size: 1.125rem;
    line-height: 1.6;
}

h2 {
    position: relative;
    font-family: var(--display);
    font-weight: 600;
    font-size: 2rem;
    margin: 0 0 0.75rem;
    padding-bottom: 0.75rem;
    color: var(--heading);
    background: linear-gradient(var(--heading-trim), var(--heading-trim)) left 0 bottom 0.3rem / 3.5rem 2px no-repeat, linear-gradient(var(--edge), var(--edge)) right 0 bottom calc(0.3rem + 0.5px) / calc(100% - 5rem) 1px no-repeat;
}

    h2::after {
        content: "";
        position: absolute;
        left: 4rem;
        bottom: calc(0.3rem - 2.5px);
        width: 7px;
        height: 7px;
        background: var(--heading-trim);
        transform: rotate(45deg);
    }

a:focus-visible,
button:focus-visible,
.search:focus-visible {
    outline: 3px solid var(--button);
    outline-offset: 2px;
}

section {
    margin-bottom: 4rem;
    scroll-margin-top: calc(var(--menu-height, 4rem) + 0.5rem);
}

.meta {
    display: block;
    font-size: 0.9rem;
    color: var(--ash);
    font-weight: 400;
}

.no-match {
    color: var(--ash);
    font-size: 1rem;
}

.player {
    font-weight: 700;
}

/* Player names that link to their journey (paintPlayerLink in app.js).
   They keep their class colour and only underline on hover. */
.journey-link {
    text-decoration: none;
}

/* Hover effects sit in (hover: hover) blocks like this one, so a tapped button or link on a phone doesn't stay lit */
@media (hover: hover) {
    .journey-link:hover {
        text-decoration: underline;
    }
}

/* A player's avatar (addAvatar in app.js): a box showing their initials, with their portrait on top
   when there is one. The border, tint and letters all take the player's class colour. */
.avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 4px;
    border: 2px solid var(--player-color, var(--line));
    background: color-mix(in srgb, var(--player-color, var(--ash)) var(--avatar-tint), var(--iron-raised));
    overflow: hidden;
    flex-shrink: 0;
    /* Lets the initials size themselves to the box, so one rule fits every avatar size */
    container-type: size;
}

/* The initials, 40% of the box wide, so two letters fit at every size (32px phones to 88px spotlights) */
.avatar-initials {
    font-family: var(--display);
    font-weight: 600;
    font-size: 40cqi;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--player-color, var(--bone));
    user-select: none;
}

/* The portrait fills the box and covers the initials. If it fails to load, app.js removes it. */
.avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- Menu ---------- */

/* Plain text links over a red line. The open page is gold with a gold underline. */
.menu {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--iron);
    border-bottom: 2px solid var(--accent-line);
}

    /* The top and bottom padding is the gap between the links and the red line */
    .menu ul {
        list-style: none;
        margin: 0 auto;
        padding: 0.8rem 0;
        width: min(92%, var(--page-width));
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem 1.6rem;
    }

    /* The see-through bottom border holds the underline's place, so the text doesn't move when it shows */
    .menu a {
        display: block;
        padding: 0.15rem 0;
        font-family: var(--display);
        font-weight: 600;
        font-size: 1.15rem;
        line-height: 1.4;
        color: var(--ash);
        text-decoration: none;
        border-bottom: 2px solid transparent;
    }

        /* The open page (buildMenu in app.js sets aria-current) */
        .menu a[aria-current="page"] {
            color: var(--button);
            border-bottom-color: var(--button);
        }

        /* A menu item with no page yet, like PvE: dimmed so it doesn't look clickable */
        .menu a[aria-disabled="true"] {
            opacity: 0.6;
            cursor: default;
        }

@media (hover: hover) {
    .menu a[href]:not([aria-current]):hover {
        color: var(--bone);
    }
}

/* ---------- Page container ---------- */

main {
    width: min(92%, var(--page-width));
    margin: 2.5rem auto 4rem;
}

    main > section:last-child {
        margin-bottom: 0;
    }

footer {
    text-align: center;
    color: var(--ash);
    font-size: 0.9rem;
    padding-bottom: 3rem;
}

/* ---------- Search boxes ---------- */

.search {
    width: 100%;
    max-width: 22rem;
    font: inherit;
    font-size: 1rem;
    padding: 0.5rem 0.8rem;
    margin-bottom: 1.25rem;
    background: var(--iron-raised);
    color: var(--bone);
    border: 1px solid var(--line);
    border-radius: 3px;
}

    .search::placeholder {
        color: var(--ash);
    }

@media (hover: hover) {
    .search:hover {
        border-color: var(--button);
    }
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1.25rem;
}

    .search-bar .search {
        margin-bottom: 0;
    }

    .search-bar .meta {
        margin: 0;
        white-space: nowrap;
    }

/* ---------- Button rows ---------- */

.board-nav {
    margin-bottom: 1.25rem;
}

.cat-row,
.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-buttons {
    justify-content: center;
    margin-top: 0.75rem;
}

.tab-gap {
    align-self: center;
    color: var(--ash);
}

.cat-btn {
    font: inherit;
    font-size: 0.95rem;
    padding: 0.4rem 0.9rem;
    background: transparent;
    color: var(--ash);
    border: 1px solid var(--edge);
    border-radius: 3px;
    cursor: pointer;
}

@media (hover: hover) {
    .cat-btn:hover {
        color: var(--bone);
        border-color: var(--button);
    }
}

/* Previous on the first page and Next on the last (pageItems in app.js) */
.cat-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* aria-current marks the open page button (drawPager in app.js) */
.cat-btn[aria-pressed="true"],
.cat-btn[aria-current="page"] {
    background: var(--button);
    border-color: var(--button);
    color: var(--iron);
    font-weight: 700;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.stat-btn {
    font: inherit;
    font-size: 0.95rem;
    padding: 0.35rem 0.9rem;
    background: none;
    border: 1px solid var(--edge);
    border-radius: 999px;
    color: var(--bone);
    cursor: pointer;
}

@media (hover: hover) {
    .stat-btn:hover {
        color: var(--button);
        border-color: var(--button);
    }
}

.stat-btn[aria-pressed="true"] {
    color: var(--button);
    font-weight: 700;
    border-color: var(--button);
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    container-type: inline-size;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--ash);
    font-size: 0.95rem;
    padding: 0 1rem;
}

    th:last-child {
        text-align: right;
    }

td {
    background: var(--panel);
    padding: 0.7rem 1rem;
    border-top: 1px solid var(--edge);
    border-bottom: 1px solid var(--edge);
}

    td:first-child {
        width: 4rem;
        border-left: 1px solid var(--edge);
        border-radius: 3px 0 0 3px;
    }

    td:last-child {
        text-align: right;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        border-right: 1px solid var(--edge);
        border-radius: 0 3px 3px 0;
    }

    td.no-match {
        text-align: left;
        font-weight: 400;
        border-radius: 3px;
    }

.roster-table th:last-child,
.roster-table td:last-child,
.history-table th:last-child,
.history-table td:last-child {
    text-align: left;
    font-weight: 400;
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

/* ---------- Leaderboard and PvP pages ---------- */

.board-desc {
    margin: 0 0 1rem;
}

#board-spotlight,
#roster-spotlight {
    margin-bottom: 1.25rem;
}

.rank {
    display: inline-grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    font-weight: 700;
    color: var(--ash);
}

.board-row td {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

    .board-row td:first-child {
        position: relative;
        border-left: 3px solid var(--player-color, var(--edge));
    }

    .board-row td > :not(.row-bar) {
        position: relative;
    }

.row-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    background: var(--player-color, var(--edge));
    opacity: var(--tint-strength);
    border-radius: 3px 0 0 3px;
    pointer-events: none;
}

/* ---------- Pills ---------- */

.rt-rank,
.change-pill {
    display: inline-block;
    color: var(--ash);
    font-size: 0.85rem;
    white-space: nowrap;
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 0.05rem 0.65rem;
}

    .rt-rank.rt-gold,
    .change-pill.joined {
        color: var(--highlight);
        border-color: var(--highlight);
    }

/* ---------- Roster ---------- */

.roster-table th {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.roster-table td {
    padding: 0.45rem 1rem;
}

.roster-row td:first-child {
    width: auto;
    border-left: 3px solid var(--player-color, var(--edge));
}

.rt-level {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Hides the Role column (4th) while no one has a role. buildRoster in app.js sets no-roles. */
.no-roles th:nth-child(4),
.no-roles td:nth-child(4) {
    display: none;
}

.rt-role {
    color: var(--ash);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
}

.maxed {
    color: var(--highlight);
}

.rt-profs {
    color: var(--ash);
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: nowrap;
}

.rt-prof {
    display: block;
}

.sort-head {
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--ash);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

    .sort-head[aria-pressed="true"] {
        color: var(--highlight);
    }

@media (hover: hover) {
    .sort-head:hover {
        color: var(--highlight);
    }
}

.sort-head[data-dir="asc"]::after {
    content: " \2191";
}

.sort-head[data-dir="desc"]::after {
    content: " \2193";
}

/* ---------- Roster: compare ---------- */

.versus-pick {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 40rem;
    margin-bottom: 0.75rem;
}

    .versus-pick .search {
        flex: 1;
        min-width: 0;
        max-width: none;
        margin-bottom: 0;
        cursor: pointer;
    }

.versus-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.stat-card.versus-card {
    padding: 0.6rem 0.9rem;
    border-left: 4px solid var(--player-color, var(--accent-line));
}

    .stat-card.versus-card:last-child {
        border-left: 1px solid var(--line);
        border-right: 4px solid var(--player-color, var(--accent-line));
        text-align: right;
    }

.versus-card:last-child .player-cell {
    flex-direction: row-reverse;
}

.versus-table td {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

    .versus-table td:nth-child(2) {
        text-align: center;
    }

    .versus-table td:first-child {
        width: 38%;
        border-left: 3px solid var(--a-color, var(--edge));
    }

    .versus-table td:last-child {
        width: 38%;
        font-weight: 400;
        border-right: 3px solid var(--b-color, var(--edge));
    }

.versus-table .meta {
    font-size: 0.8rem;
}

.versus-value {
    display: block;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.versus-table .win .versus-value {
    color: var(--highlight);
}

.versus-table .loss .versus-value {
    color: var(--ash);
    font-weight: 400;
}

.versus-board {
    color: var(--bone);
    text-decoration: none;
}

@media (hover: hover) {
    .versus-board:hover {
        color: var(--highlight);
        text-decoration: underline;
    }
}

/* ---------- Roster: composition charts ---------- */

.chart-tabs {
    margin-bottom: 1.25rem;
}

.bars {
    display: grid;
    gap: 0.45rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 9rem 1fr 2.5rem;
    align-items: center;
    gap: 0.75rem;
}

.bar-label {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-row.blank .bar-label {
    color: var(--ash);
}

.bar-track {
    background: var(--iron-raised);
    border: 1px solid var(--edge);
    border-radius: 3px;
    height: 1.6rem;
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    border-radius: 3px 0 0 3px;
    min-width: 2px;
}

.bar-value {
    font-size: 0.95rem;
    color: var(--ash);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- Cards ---------- */

/* Three levels, loudest first: spotlight cards (.sod), stat cards (.stat-card), then feed rows (under "Home: feeds") */

/* Stat cards: quiet boxes */
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}

/* Spotlight cards: a lighter fill and a gold top edge. Square corners, to suit the one thick edge. */
.sod {
    background: var(--spotlight);
    border: 1px solid var(--edge);
    border-top: 3px solid var(--highlight);
}

.stat-label,
.sod-label {
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ash);
}

a.feed-row {
    color: inherit;
    text-decoration: none;
}

/* Cards that are links lift on hover and outline in gold, leaving their coloured edge alone */
:is(a.stat-card, a.sod, a.recent-card) {
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
    :is(a.stat-card, a.sod, a.recent-card):is(:hover, :focus-visible) {
        transform: translateY(-2px);
        border-right-color: var(--button);
        border-bottom-color: var(--button);
    }

    /* Stat cards have no coloured edge, so all four sides turn gold */
    a.stat-card:is(:hover, :focus-visible) {
        border-color: var(--button);
    }

    /* Spotlight cards keep their top edge */
    a.sod:is(:hover, :focus-visible) {
        border-left-color: var(--button);
    }

    /* Recently active cards keep their left edge */
    a.recent-card:is(:hover, :focus-visible) {
        border-top-color: var(--button);
    }

    /* Feed rows in a list have no outline, so they light up instead */
    a.feed-row:not(.recent-card):hover {
        background: var(--iron-raised);
    }
}

@media (prefers-reduced-motion: reduce) {
    :is(a.stat-card, a.sod, a.recent-card) {
        transition: none;
    }

        :is(a.stat-card, a.sod, a.recent-card):is(:hover, :focus-visible) {
            transform: none;
        }
}

/* ---------- Home: Guild Snapshot ---------- */

.snapshot {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

    .snapshot > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .snapshot > .no-match {
        margin: 0;
    }

.stat-card {
    padding: 0.8rem 1.1rem;
}

.stat-label {
    display: block;
}

.stat-value {
    display: block;
    font-size: 2.2rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

    /* An empty state, like 0 leads held (dim in drawStatCards) */
    .stat-value.dim {
        color: var(--ash);
    }

/* The gold end of a card's meta line, like "still holding" (metaGold in drawStatCards) */
.meta-gold {
    color: var(--highlight);
}

/* ---------- Spotlight cards ---------- */

.sod {
    display: block;
    padding: 1.1rem 1.35rem;
    margin-bottom: 0.75rem;
}

.sod-label {
    margin-bottom: 0.75rem;
}

    /* The crown, on spotlight labels and on stat cards with crown set (drawStatCards in app.js) */
    .sod-label::before,
    .stat-label.crowned::before {
        content: "\265B";
        color: var(--highlight);
        margin-right: 0.4rem;
    }

.sod-body {
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

    .sod-body .avatar {
        width: 88px;
        height: 88px;
    }

.sod-line {
    display: block;
    font-size: 1.2rem;
}

.sod-value {
    display: block;
    font-size: 2.75rem;
    line-height: 1.05;
    color: var(--highlight);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- Home: rivalry ---------- */

/* The Hottest Rivalry section (showRivalry in app.js), under the snapshot cards. The card itself is .sod,
   with a red top edge in place of the gold so it doesn't compete with the stat of the day.
   Leader on the left, challenger on the right, their values and the board in the middle.
   The section's header and spacing are the page-wide h2 and section rules. */
.rivalry {
    margin: 0;
    border-top-color: var(--accent-line);
}

.rivalry-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
}

/* One player: avatar, name in class colour, race and class. The right side mirrors the left. */
.rivalry-side {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

    .rivalry-side.right {
        flex-direction: row-reverse;
        text-align: right;
    }

    .rivalry-side .avatar {
        width: 76px;
        height: 76px;
    }

    .rivalry-side .player {
        display: block;
        font-size: 1.5rem;
        line-height: 1.15;
        overflow-wrap: break-word;
    }

.rivalry-score {
    text-align: center;
}

/* The two values, like "412 – 409". The leader's is gold. */
.rivalry-values {
    display: block;
    font-size: 2.75rem;
    line-height: 1.05;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rivalry-lead {
    color: var(--highlight);
}

.rivalry-board {
    display: block;
    font-size: 1.1rem;
    margin-top: 0.3rem;
}

/* ---------- Home: feeds ---------- */

/* A feed row: avatar, text, then how long ago. In a list (Leaderboard Changes, Recent Achievements)
   the rows have no box, just a hairline between them. */
.feed-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.25rem;
}

    .feed-row:not(.recent-card) + .feed-row {
        border-top: 1px solid var(--line);
    }

.feed-text {
    grid-column: 2;
}

.feed-line {
    font-size: 1rem;
}

/* The board or achievement name */
.feed-row .feat {
    font-weight: 700;
}

.feed-row .when {
    grid-column: 3;
    color: var(--ash);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* A feed row drawn as a card in a grid: Recently active on Journeys and the Hall of Fame class cards.
   The left trim takes the class colour. */
.recent-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--player-color, var(--accent-line));
    border-radius: 3px;
    padding: 0.6rem 1rem;
}

.see-more {
    display: inline-block;
    margin-top: 0.5rem;
    text-decoration: none;
}

/* ---------- History ---------- */

.history-table td {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.history-row td:first-child {
    width: auto;
    white-space: nowrap;
    color: var(--ash);
    font-variant-numeric: tabular-nums;
    border-left: 3px solid var(--player-color, var(--edge));
}

.history-board {
    color: var(--highlight);
    text-decoration: none;
}

@media (hover: hover) {
    .history-board:hover {
        text-decoration: underline;
    }
}

/* ---------- Hall of Fame ---------- */

/* The First 60 is a spotlight card (.sod) and the class cards are Recently active cards
   (.feed-row.recent-card in a .recent-grid), so these rules only add what's new. */

/* The class name at the top of a class card, in its class colour (hallClassCard in app.js) */
.hall-class {
    display: block;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hall-names {
    display: block;
}

/* A shared award's avatars, overlapping */
.hall-avatars {
    display: flex;
    flex-shrink: 0;
}

    .hall-avatars .avatar + .avatar {
        margin-left: -0.75rem;
    }

/* An unclaimed award: grey trim (the spotlight's top edge too), a "?" avatar and dim text, with no panel fill */
.hall-empty {
    --player-color: var(--edge);
    background: transparent;
    border-top-color: var(--edge);
    color: var(--ash);
}

    .hall-empty .avatar-initials,
    .hall-empty .sod-value,
    .hall-empty .sod-label::before {
        color: var(--ash);
    }

/* ---------- Journeys ---------- */

/* Space between the journey's header, progress, highlights and timeline.
   margin-bottom undoes the page-level section spacing on the timeline, which is a section. */
.journey-block {
    margin-top: 2rem;
    margin-bottom: 0;
}

    .journey-block h3 {
        font-family: var(--display);
        font-weight: 600;
        font-size: 1.4rem;
        color: var(--heading);
        margin: 0 0 0.75rem;
    }

#journey-pick {
    cursor: pointer;
}

/* The picker card at the top of Journeys. The card itself is .sod (the spotlight look);
   this centres the picker, outlines it in gold, and tightens the "journeys tracked" line under it. */
.journey-pick-card {
    text-align: center;
}

    .journey-pick-card .search {
        margin-bottom: 0.5rem;
        border-color: var(--button);
    }

    .journey-pick-card .meta {
        margin: 0;
    }

/* Recently active: a grid of player cards that wraps to fit the page width */
#journey-recent .stat-label {
    margin: 0 0 0.5rem;
}

.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.5rem;
}

#journey-filters {
    margin-bottom: 0.5rem;
}

/* The Progress block's control rows: metric tabs and time ranges, then the Compare picker and the key.
   Each row puts its two halves at opposite ends, wrapping onto two lines when there isn't room. */
.chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

    .chart-controls .chart-tabs {
        margin-bottom: 0;
    }

/* "Compare with" and its picker, sized to the names instead of the full search-box width */
.chart-compare-pick .search {
    width: auto;
    max-width: 14rem;
    margin: 0 0 0 0.4rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}

/* The chart's key: a short line and the name for each player, in class colour.
   The compare player's line is as faint as theirs on the chart. */
.chart-key {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

    .chart-key + .chart-key {
        margin-left: 1rem;
    }

    .chart-key .player {
        color: var(--player-color);
    }

.chart-swatch {
    width: 1.2rem;
    height: 3px;
    border-radius: 2px;
    background: var(--player-color);
}

.chart-key.compare .chart-swatch {
    opacity: var(--compare-strength);
}

/* Same class compare: dashed swatch to match the dashed line. Change the dash sizes here and below. */
.same-class .chart-key.compare .chart-swatch {
    background: repeating-linear-gradient(to right, var(--player-color) 0 5px, transparent 5px 8px);
}

/* Progress chart: value scale on the left, lines in the middle, dates underneath */
.line-chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.4rem 0.75rem;
}

    .line-chart > .no-match {
        grid-column: 1 / -1;
        margin: 0;
    }

/* The scale. Each value is placed level with its guide line by app.js; the hidden sizer gives the column its width. */
.chart-scale {
    position: relative;
    text-align: right;
    font-size: 0.85rem;
    color: var(--ash);
    font-variant-numeric: tabular-nums;
}

.chart-scale-sizer {
    display: block;
    height: 0;
    visibility: hidden;
}

.chart-tick {
    position: absolute;
    right: 0;
    transform: translateY(-50%);
    line-height: 1;
    white-space: nowrap;
}

/* Holds the chart and its hover readout */
.chart-area {
    position: relative;
    min-width: 0;
}

/* The chart's height. Phones have their own under "Phones". pan-y keeps the page scrolling on phones
   while a sideways drag moves the readout. */
.chart-plot {
    display: block;
    width: 100%;
    height: 18rem;
    background: var(--iron-raised);
    border: 1px solid var(--edge);
    border-radius: 3px;
    touch-action: pan-y;
}

.chart-grid {
    stroke: var(--line);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

/* The faint fill under the line, in the player's class colour at the same strength as the leaderboard row bars */
.chart-fill {
    fill: var(--player-color, var(--highlight));
    opacity: var(--tint-strength);
}

/* The line takes the player's class colour, set on the chart by app.js */
.chart-line {
    fill: none;
    stroke: var(--player-color, var(--highlight));
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

    /* The compare player's line: their class colour, thinner and fainter (--compare-strength) */
    .chart-line.chart-compare {
        stroke: var(--compare-color, var(--ash));
        stroke-width: 2.5;
        opacity: var(--compare-strength);
    }

/* Same class as the open player: dashed so the two lines stay apart (drawComparePick in app.js).
       Dash length, then gap. */
.same-class .chart-line.chart-compare {
    stroke-dasharray: 8 6;
}

/* The dashed line down the chart where the pointer is */
.chart-hover {
    stroke: var(--ash);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.6;
    vector-effect: non-scaling-stroke;
}

/* The hover or tap readout: the date and time, then each player's value in their class colour */
.chart-readout {
    position: absolute;
    top: 0.6rem;
    z-index: 1;
    pointer-events: none;
    padding: 0.35rem 0.7rem;
    background: var(--iron);
    border: 1px solid var(--edge);
    border-radius: 3px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: nowrap;
}

    .chart-readout .meta {
        font-size: 0.85rem;
    }

    .chart-readout .player {
        color: var(--player-color);
    }

/* The dates, each centred on its midnight by app.js. Ones near an edge line up with it instead. */
.chart-dates {
    grid-column: 2;
    position: relative;
    height: 1.4em;
    font-size: 0.85rem;
    color: var(--ash);
}

.chart-date {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

    .chart-date.start {
        transform: none;
    }

    .chart-date.end {
        transform: translateX(-100%);
    }

/* Timeline (drawTimeline in app.js): a heading for each day, then that day's rows along a line in the
   player's class colour. Each row is a dot on the line, the time, and one line per event.
   --timeline-gutter is the space left of the rows, where the line and dots sit. */
.timeline {
    --timeline-gutter: 2rem;
    --timeline-line-center: 10px; /* the middle of the line, from the left edge of the list */
}

.timeline-day {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ash);
}

    /* A hairline running from the date to the right edge */
    .timeline-day::after {
        content: "";
        flex: 1;
        height: 1px;
        background: var(--line);
    }

.timeline-list {
    position: relative;
    padding-left: var(--timeline-gutter);
    margin-bottom: 1.25rem;
}

    /* The line down the left, in the player's class colour */
    .timeline-list::before {
        content: "";
        position: absolute;
        left: calc(var(--timeline-line-center) - 1px);
        top: 0.4rem;
        bottom: 0.4rem;
        width: 2px;
        border-radius: 2px;
        background: var(--player-color, var(--edge));
        opacity: 0.45;
    }

.timeline-event {
    position: relative;
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border-radius: 3px;
}

    /* A hairline between rows. Big rows have their own border, so they get none. */
    .timeline-event:not(.big) + .timeline-event:not(.big) {
        border-top: 1px solid var(--line);
        border-radius: 0;
    }

/* The dot on the line, a ring in the event's colour. app.js sets --dot to one colour, or to equal
   slices of several when events of different kinds share the row. ::after punches out the middle. */
.timeline-dot {
    --dot-size: 13px;
    position: absolute;
    top: 50%;
    left: calc(var(--timeline-line-center) - var(--timeline-gutter) - var(--dot-size) / 2);
    width: var(--dot-size);
    height: var(--dot-size);
    margin-top: calc(var(--dot-size) / -2);
    border-radius: 50%;
    background: var(--dot);
}

    .timeline-dot::after {
        content: "";
        position: absolute;
        inset: 3px;
        border-radius: 50%;
        background: var(--iron);
    }

.timeline-time {
    font-size: 0.9rem;
    color: var(--ash);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.timeline-lines {
    display: grid;
    gap: 0.25rem;
}

/* One event: the title on the left, its pill on the right */
.timeline-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.timeline-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

/* The highlighted end of the title and the pill take the event's colour, set by app.js */
.timeline-value {
    color: var(--event-color);
}

.timeline-line .change-pill {
    color: var(--event-color);
    border-color: var(--event-color);
}

/* A big event (big in JOURNEY_EVENTS): a row of its own, tinted in its colour, with a larger solid dot.
   The crown shows in the dot for crown kinds. The dot moves 1px left to make up for the row's border. */
.timeline-event.big {
    margin: 0.25rem 0;
    padding: 0.6rem 0.65rem;
    background: color-mix(in srgb, var(--event-color) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--event-color) 35%, transparent);
}

    .timeline-event.big .timeline-dot {
        --dot-size: 19px;
        left: calc(var(--timeline-line-center) - var(--timeline-gutter) - var(--dot-size) / 2 - 1px);
        display: grid;
        place-items: center;
        font-size: 0.7rem;
        line-height: 1;
        color: var(--iron);
    }

        .timeline-event.big .timeline-dot::after {
            display: none;
        }

    .timeline-event.big .timeline-title {
        font-size: 1.1rem;
    }

/* ---------- Phones ---------- */

@media (max-width: 520px) {
    :root {
        --avatar-size: 32px; /* portraits in table and feed rows on phones */
    }

    body {
        font-size: 1.05rem;
    }

    /* The content nearly reaches the screen edges, giving it more room */
    main {
        width: auto;
        margin: 1rem 0.9rem 2.5rem;
    }

    section {
        margin-bottom: 2.5rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    /* The menu and the leaderboard's button rows stay on one line and scroll sideways. The fade on the
       right hints at more, and the end padding lets the last button scroll clear of it.
       centerInRow in app.js scrolls the open button into view. */
    .menu ul,
    .board-nav .cat-row,
    .board-nav .stat-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        padding-right: 1.5rem;
        mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
    }

        .menu ul::-webkit-scrollbar,
        .board-nav .cat-row::-webkit-scrollbar,
        .board-nav .stat-row::-webkit-scrollbar {
            display: none;
        }

    .menu li,
    .board-nav button {
        flex-shrink: 0;
    }

    /* The auto margins centre the menu while it fits, without cutting off Home once it scrolls */
    .menu ul {
        width: 100%;
        justify-content: flex-start;
        gap: 1.1rem;
        padding: 0.6rem 1.5rem 0.6rem 0.9rem;
    }

    .menu li:first-child {
        margin-left: auto;
    }

    .menu li:last-child {
        margin-right: auto;
    }

    .menu a {
        font-size: 0.95rem;
    }

    td, th {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    /* A narrower Rank column on the boards, since it only holds a number or two */
    .board-row td:first-child {
        width: 2.75rem;
        padding-right: 0;
    }

    .rank {
        width: 1.75rem;
    }

    .bar-row {
        grid-template-columns: 6.5rem 1fr 2rem;
        gap: 0.5rem;
    }

    .bar-label {
        font-size: 0.9rem;
    }

    .feed-row {
        grid-template-columns: auto 1fr;
    }

        .feed-row .when {
            grid-column: 2;
            justify-self: start;
        }

    /* Tables that turn each row into a card: Roster and History (card-table in their HTML).
       Each kind of row sets its own grid below. */
    .card-table,
    .card-table thead,
    .card-table tbody {
        display: block;
    }

        .card-table thead tr {
            display: flex;
            flex-wrap: wrap;
            gap: 0.25rem 1rem;
            margin-bottom: 0.5rem;
        }

        .card-table th {
            padding: 0;
        }

        .card-table tbody tr {
            display: grid;
            align-items: center;
            gap: 0.3rem 0.75rem;
            margin-bottom: 6px;
            padding: 0.55rem 0.75rem;
            background: var(--panel);
            border: 1px solid var(--edge);
            border-left: 3px solid var(--player-color, var(--edge));
            border-radius: 3px;
        }

        /* The row is the card, so cells drop their own box. :first-child outranks the desktop row trims. */
        .card-table td,
        .card-table td:first-child {
            width: auto;
            padding: 0;
            background: none;
            border: none;
            border-radius: 0;
        }

    /* Roster card: name and rank on top, professions, role and level underneath */
    .roster-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "player player rank" "profs role level";
    }

        .roster-row td:nth-child(1) {
            grid-area: player;
        }

        .roster-row td:nth-child(2) {
            grid-area: level;
            justify-self: end;
        }

        .roster-row td:nth-child(3) {
            grid-area: rank;
            justify-self: end;
        }

        .roster-row td:nth-child(4) {
            grid-area: role;
        }

        .roster-row td:nth-child(5) {
            grid-area: profs;
            padding-left: calc(var(--avatar-size) + 0.65rem);
        }

    /* History card: name and date on top, the last two columns underneath with their headings
       (labelCells in app.js). The table's own headings are hidden. */
    .history-table thead {
        display: none;
    }

    .history-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "player date" "what last";
    }

        .history-row td:nth-child(1) {
            grid-area: date;
            justify-self: end;
            font-size: 0.85rem;
        }

        .history-row td:nth-child(2) {
            grid-area: player;
        }

        .history-row td:nth-child(3) {
            grid-area: what;
        }

        .history-row td:nth-child(4) {
            grid-area: last;
            justify-self: end;
        }

        .history-row td:nth-child(n+3)::before {
            content: attr(data-label) " ";
            color: var(--ash);
            font-size: 0.8rem;
            font-weight: 400;
        }

    .snapshot {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .sod {
        padding: 0.9rem 1rem;
        margin-bottom: 0.5rem;
    }

    .sod-line {
        font-size: 1.05rem;
    }

    .sod-value {
        font-size: 2.2rem;
    }

    .sod-body .avatar {
        width: 64px;
        height: 64px;
    }

    /* Rivalry card: both players side by side on top, the values and board underneath */
    .rivalry-body {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "left right" "score score";
        gap: 0.75rem 0.5rem;
    }

    .rivalry-side {
        grid-area: left;
        gap: 0.5rem;
    }

        .rivalry-side.right {
            grid-area: right;
        }

    .rivalry-score {
        grid-area: score;
    }

    .rivalry-side .avatar {
        width: 44px;
        height: 44px;
    }

    .rivalry-side .player {
        font-size: 1.05rem;
    }

    .rivalry-side .meta {
        font-size: 0.8rem;
    }

    .rivalry-values {
        font-size: 2.2rem;
    }

    .rivalry-board {
        font-size: 0.95rem;
    }

    .chart-plot {
        height: 10rem;
    }

    /* The scale's in-between values and their guide lines (phoneStep in JOURNEY_METRICS), so Level shows every 10 */
    .chart-minor {
        display: none;
    }

    .timeline-event {
        grid-template-columns: 4.25rem minmax(0, 1fr);
        gap: 0.5rem;
    }

    .timeline-time {
        font-size: 0.8rem;
    }

    /* The pill drops under the title, so the title keeps the row's width */
    .timeline-line {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.15rem;
    }

        .timeline-line .change-pill {
            justify-self: start;
        }
}
