/* ============================================================================
 * coa-db.css — site shell, listings, palette
 * ----------------------------------------------------------------------------
 * Project:  coa-db (db.exil.es)
 * License:  AGPL-3.0-or-later
 *
 * Palette and item-quality / spell-school colours are derived from aowow's
 * basic.css (also AGPL — license-clean to lift). The structural layout, naming
 * conventions (BEM-ish), CSS custom properties, and modern logical-property
 * usage are all original.
 *
 * Section index:
 *   1. Reset & box model
 *   2. Design tokens (CSS variables)
 *   3. Typography
 *   4. Page shell (header, main, footer)
 *   5. Site header & search
 *   6. Breadcrumbs
 *   7. Item-quality colour classes (.q0..q7)
 *   8. Spell-school colour classes (.sc1..)
 *   9. Listings (.listview tables)
 *  10. Forms & buttons
 *  11. Utilities
 * ========================================================================== */


/* 1. Reset & box model -------------------------------------------------------
 * Minimal — modern browsers already do most of the work. We just normalise
 * box-sizing, kill default margins, and ensure font smoothing is consistent
 * on macOS / Linux.
 * -------------------------------------------------------------------------- */

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

html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote {
    margin: 0;
}

ul, ol { padding-inline-start: 0; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-size-adjust: 100%;
    color-scheme: dark;
}

img, svg { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

button { font: inherit; cursor: pointer; }


/* 2. Design tokens -----------------------------------------------------------
 * Every colour and most sizes live here so a light-theme override is a
 * single :root rule away. Names use a `--namespace-purpose` convention.
 * -------------------------------------------------------------------------- */

:root {
    /* --- surface / background ladder, darkest → lightest. Pushed deep
     *     enough that WoW's stock quality colours (q3 #0070dd in
     *     particular) still read as contrast pops. Wowhead-classic dark.
     * --- */
    --bg-page:        #050608;   /* document background                       */
    --bg-shell:       #0a0c10;   /* header / footer band                       */
    --bg-panel:       #0f1217;   /* cards, listing rows                        */
    --bg-panel-alt:   #131720;   /* zebra row                                  */
    --bg-elevated:    #1c2028;   /* hover / focus highlight                    */
    --bg-tooltip:     #050505;   /* item / spell tooltip background (dark)     */

    /* --- borders / dividers --- */
    --border-subtle:  #242932;
    --border-strong:  #3a414c;
    --border-accent:  #5a4a1f;   /* warm gold rim for tooltips                 */

    /* --- text — bright enough to clear WCAG AA on the deepened panels --- */
    --fg-primary:     #f0f0f0;
    --fg-muted:       #c4c8ce;
    --fg-faint:       #939aa3;
    --fg-disabled:    #5d6068;

    /* --- accent (Wowhead-y warm gold) --- */
    --accent:         #ffd100;   /* primary heading / brand accent             */
    --accent-soft:    #d4a017;
    --accent-hover:   #ffe066;
    --link:           #ffd100;
    --link-hover:     #ffe066;

    /* --- semantic --- */
    --ok:             #5df644;
    --warn:           #ff8040;
    --err:            #ff4040;
    --info:           #71d5ff;

    /* --- item-quality colours (match crates/types/src/quality.rs hex_color) --- */
    --q0: #9d9d9d;   /* Poor       */
    --q1: #ffffff;   /* Common     */
    --q2: #1eff00;   /* Uncommon   */
    --q3: #0070dd;   /* Rare       */
    --q4: #a335ee;   /* Epic       */
    --q5: #ff8000;   /* Legendary  */
    --q6: #e6cc80;   /* Artifact   */
    --q7: #00ccff;   /* Heirloom   */

    /* --- spell-school colours (bitmask values from crates/types/src/school.rs) --- */
    --sc-physical: #ffffff;
    --sc-holy:     #ffe680;
    --sc-fire:     #ff8040;
    --sc-nature:   #4dff4d;
    --sc-frost:    #80ffff;
    --sc-shadow:   #b080ff;
    --sc-arcane:   #ff80ff;

    /* --- typography --- */
    --font-ui:    "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
    --font-tip:   Tahoma, Verdana, Geneva, "DejaVu Sans", sans-serif;
    --font-mono:  ui-monospace, "JetBrains Mono", "Fira Code", Menlo,
                  Consolas, "Liberation Mono", monospace;

    --fs-xs:    11px;
    --fs-sm:    12px;
    --fs-base:  14px;
    --fs-md:    16px;
    --fs-lg:    18px;
    --fs-xl:    22px;
    --fs-2xl:   28px;

    --lh-tight: 1.2;
    --lh-base:  1.5;

    /* --- layout --- */
    --content-max:   1200px;
    --header-height: 56px;
    --radius-sm: 3px;
    --radius-md: 5px;
    --radius-lg: 8px;

    /* --- shadows --- */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);

    /* --- focus ring (always visible for keyboard users) --- */
    --focus-ring: 0 0 0 2px var(--accent), 0 0 0 4px rgba(255, 209, 0, 0.25);
}


/* 3. Typography --------------------------------------------------------------
 * The site UI uses a system stack. Tooltips switch to Tahoma/Verdana to
 * match the in-game / Wowhead vibe. Numbers (item levels, stats, money)
 * use a monospace face for tabular alignment.
 * -------------------------------------------------------------------------- */

body {
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--fg-primary);
    background: var(--bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--accent);
    line-height: var(--lh-tight);
    margin-block-end: 0.5em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl);  }
h3 { font-size: var(--fs-lg);  }
h4 { font-size: var(--fs-md);  }
h5, h6 { font-size: var(--fs-base); }

p { margin-block-end: 1em; }

a {
    color: var(--link);
    text-decoration: none;
    transition: color 80ms linear;
}
a:hover, a:focus-visible { color: var(--link-hover); text-decoration: underline; }

code, pre, .num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--fg-muted); }
.text-faint { color: var(--fg-faint); }

::selection { background: var(--accent); color: #000; }


/* 4. Page shell --------------------------------------------------------------
 * <body> is a flex column so the footer sticks to the bottom on short pages.
 * Each section is full-bleed but its inner wrapper clamps to --content-max.
 * -------------------------------------------------------------------------- */

.site-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: 1rem;
    padding-block: 1.5rem 3rem;
}


/* 5. Site header & search ----------------------------------------------------
 * Sticky top bar with brand on the left, a centred search field that
 * stretches, and primary nav on the right. Collapses to a stacked layout
 * below 720px.
 * -------------------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-shell);
    border-block-end: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: 1rem;
    min-height: var(--header-height);
}

.site-header__brand {
    display: inline-flex;
    align-items: baseline;
    font-family: var(--font-ui);
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--fg-primary);
    flex-shrink: 0;
}
.site-header__brand:hover, .site-header__brand:focus-visible {
    text-decoration: none;
    color: var(--accent-hover);
}
.site-header__brand-mark { color: var(--accent); }
.site-header__brand-dot  { color: var(--fg-muted); margin-inline: 1px; }
.site-header__brand-name { color: var(--fg-primary); }

/* search form fills the remaining space between brand and nav */
.site-search {
    display: flex;
    flex: 1 1 auto;
    max-width: 540px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.site-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.site-search__input {
    flex: 1 1 auto;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--fg-primary);
    font-size: var(--fs-base);
    padding-inline: 0.75rem;
    padding-block: 0.4rem;
    min-width: 0;   /* prevent flex overflow */
}
.site-search__input::placeholder { color: var(--fg-faint); }

.site-search__submit {
    background: var(--bg-elevated);
    color: var(--fg-primary);
    border: 0;
    border-inline-start: 1px solid var(--border-strong);
    padding-inline: 0.9rem;
    font-weight: 600;
    transition: background-color 80ms linear, color 80ms linear;
}
.site-search__submit:hover, .site-search__submit:focus-visible {
    background: var(--accent);
    color: #000;
}

.site-nav {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}
.site-nav__link {
    display: inline-block;
    padding-inline: 0.75rem;
    padding-block: 0.4rem;
    color: var(--fg-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.site-nav__link:hover, .site-nav__link:focus-visible {
    background: var(--bg-elevated);
    color: var(--accent-hover);
    text-decoration: none;
}

@media (max-width: 720px) {
    .site-header__inner {
        flex-wrap: wrap;
        padding-block: 0.5rem;
        gap: 0.5rem;
    }
    .site-search { order: 3; flex-basis: 100%; max-width: none; }
    .site-nav { margin-inline-start: auto; }
}


/* 6. Breadcrumbs -------------------------------------------------------------
 * A single-line list rendered with `›` separators. The current page (last
 * crumb) is non-link and slightly highlighted.
 * -------------------------------------------------------------------------- */

.breadcrumb {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: 1rem;
    padding-block: 0.6rem 0.4rem;
    font-size: var(--fs-sm);
    color: var(--fg-muted);
    border-block-end: 1px solid var(--border-subtle);
}
.breadcrumb__list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
}
.breadcrumb__item { display: inline-flex; align-items: center; gap: 0.5rem; }
.breadcrumb__link { color: var(--fg-muted); }
.breadcrumb__link:hover { color: var(--accent-hover); text-decoration: underline; }
.breadcrumb__current { color: var(--fg-primary); font-weight: 500; }
.breadcrumb__sep { color: var(--fg-disabled); }


/* 7. Item-quality colour classes --------------------------------------------
 * Lifted directly from aowow's basic.css (AGPL → AGPL is fine). Both the
 * element itself and any descendant <a> get the colour, which matches the
 * convention used by item-tooltip renderers (`<span class="q3"><a …>name</a></span>`).
 * Variables let themes override per-quality without touching this block.
 * -------------------------------------------------------------------------- */

.q0, .q0 a, a.q0, .color-q0 { color: var(--q0); }
.q1, .q1 a, a.q1, .color-q1 { color: var(--q1); }
.q2, .q2 a, a.q2, .color-q2 { color: var(--q2); }
.q3, .q3 a, a.q3, .color-q3 { color: var(--q3); }
.q4, .q4 a, a.q4, .color-q4 { color: var(--q4); }
.q5, .q5 a, a.q5, .color-q5 { color: var(--q5); }
.q6, .q6 a, a.q6, .color-q6 { color: var(--q6); }
.q7, .q7 a, a.q7, .color-q7 { color: var(--q7); }


/* 8. Spell-school colour classes --------------------------------------------
 * Bitmask values from crates/types/src/school.rs:
 *   PHYSICAL=1, HOLY=2, FIRE=4, NATURE=8, FROST=16, SHADOW=32, ARCANE=64
 * `.sc127` (0b1111111) covers spells classified as all-magic (rare).
 * Renderers select the dominant single-school class; multi-school selectors
 * (e.g. `.sc6` for Holy+Fire) fall back to the gradient utility below.
 * -------------------------------------------------------------------------- */

.sc1   { color: var(--sc-physical); }   /* Physical                */
.sc2   { color: var(--sc-holy);     }   /* Holy                    */
.sc4   { color: var(--sc-fire);     }   /* Fire                    */
.sc8   { color: var(--sc-nature);   }   /* Nature                  */
.sc16  { color: var(--sc-frost);    }   /* Frost                   */
.sc32  { color: var(--sc-shadow);   }   /* Shadow                  */
.sc64  { color: var(--sc-arcane);   }   /* Arcane                  */
.sc127 { color: var(--accent);      }   /* All schools (rare)       */

/* Multi-school fallback: Holy+Fire = Holy Fire, Fire+Frost = Frostfire, etc.
 * Renderers can wrap the icon in `<span class="sc-multi sc6 sc4 sc2">` to get
 * a subtle outline indicating mixed schools. */
.sc-multi {
    text-shadow: 0 0 4px currentColor;
}


/* 9. Listings (.listview) ----------------------------------------------------
 * The Wowhead-style sortable, paginated table used for /items, /spells, etc.
 * Header sticks below the site header during scroll. Rows alternate to make
 * scanning easier.
 * -------------------------------------------------------------------------- */

.listview {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-block-end: 1.5rem;
}

.listview__title {
    padding: 0.75rem 1rem;
    background: var(--bg-shell);
    border-block-end: 1px solid var(--border-subtle);
    font-size: var(--fs-md);
    color: var(--accent);
    margin: 0;
}

.listview__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.listview__table th,
.listview__table td {
    padding: 0.45rem 0.75rem;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--border-subtle);
}
.listview__table thead th {
    position: sticky;
    top: var(--header-height);
    background: var(--bg-shell);
    color: var(--fg-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: var(--fs-xs);
    border-block-end: 1px solid var(--border-strong);
    cursor: pointer;
    user-select: none;
}
.listview__table thead th[aria-sort="ascending"]::after  { content: " \25B2"; opacity: 0.7; }
.listview__table thead th[aria-sort="descending"]::after { content: " \25BC"; opacity: 0.7; }

.listview__table tbody tr:nth-child(even) td { background: var(--bg-panel-alt); }
.listview__table tbody tr:hover td           { background: var(--bg-elevated); }
.listview__table tbody tr:last-child td      { border-block-end: 0; }

/* Right-align numeric columns; renderers add `.num` to <td>. */
.listview__table td.num,
.listview__table th.num { text-align: end; font-family: var(--font-mono); }

/* Tiny thumbnail icon inside a listview cell (e.g. item icon next to name). */
.listview__icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-inline-end: 0.4rem;
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    vertical-align: middle;
    background-color: var(--bg-tooltip);
    background-size: cover;
}

/* Pagination row. */
.listview__pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-shell);
    border-block-start: 1px solid var(--border-subtle);
    font-size: var(--fs-sm);
    color: var(--fg-muted);
}
.listview__pager-controls { display: flex; gap: 0.25rem; }
.listview__pager-controls a,
.listview__pager-controls span {
    display: inline-block;
    min-width: 28px;
    padding: 0.2rem 0.5rem;
    text-align: center;
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--fg-muted);
    text-decoration: none;
}
.listview__pager-controls a:hover { background: var(--accent); color: #000; }
.listview__pager-controls .is-current {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}


/* 10. Forms & buttons --------------------------------------------------------
 * Generic styles for the few non-search forms we need (filters, login).
 * -------------------------------------------------------------------------- */

input, select, textarea {
    background: var(--bg-panel);
    color: var(--fg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.btn {
    display: inline-block;
    background: var(--bg-elevated);
    color: var(--fg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 80ms linear, color 80ms linear;
}
.btn:hover, .btn:focus-visible {
    background: var(--accent);
    color: #000;
    text-decoration: none;
}
.btn--ghost { background: transparent; }


/* Global focus ring — keyboard users only. */
:focus-visible {
    outline: 0;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}


/* 11. Site footer ------------------------------------------------------------
 * Quiet band below main content. Same width clamp as the rest.
 * -------------------------------------------------------------------------- */

.site-footer {
    background: var(--bg-shell);
    border-block-start: 1px solid var(--border-subtle);
    color: var(--fg-faint);
    font-size: var(--fs-sm);
    padding-block: 1.25rem;
    margin-block-start: 2rem;
}
.site-footer__inner {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: 1rem;
}
.site-footer__line { margin: 0; }
.site-footer__line + .site-footer__line { margin-block-start: 0.25rem; }
.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--accent-hover); }


/* 12. Utilities --------------------------------------------------------------
 * Tiny helpers used by renderers. Keep this list short — utility classes
 * tend to grow into a CSS framework otherwise.
 * -------------------------------------------------------------------------- */

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.gap-sm    { gap: 0.5rem; }
.gap-md    { gap: 1rem; }
.text-center { text-align: center; }
.text-end    { text-align: end; }

.hidden { display: none !important; }

/* Home landing — search-first, category cards, quick-search chips. */
.home {
    max-width: 760px;
    margin-inline: auto;
    padding-block-start: 2rem;
}

.home-search {
    display: flex;
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-block-end: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.home-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.home-search__input {
    flex: 1 1 auto;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--fg-primary);
    font-size: var(--fs-lg);
    padding: 0.7rem 1rem;
    min-width: 0;
}
.home-search__input::placeholder { color: var(--fg-faint); }
.home-search__submit {
    background: var(--bg-elevated);
    color: var(--fg-primary);
    border: 0;
    border-inline-start: 1px solid var(--border-strong);
    padding-inline: 1.2rem;
    font-weight: 600;
    font-size: var(--fs-base);
    transition: background-color 80ms linear, color 80ms linear;
}
.home-search__submit:hover, .home-search__submit:focus-visible {
    background: var(--accent);
    color: #000;
}

.home-cats {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 0 0 1.5rem;
    padding: 0;
}
.home-cat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.7rem 0.9rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--fg-primary);
    text-decoration: none;
}
.home-cat:hover, .home-cat:focus-visible {
    background: var(--bg-elevated);
    border-color: var(--accent-soft);
    text-decoration: none;
}
.home-cat__name {
    font-weight: 600;
    color: var(--accent);
    font-size: var(--fs-base);
}
.home-cat__count {
    color: var(--fg-muted);
    font-size: var(--fs-sm);
}
.home-cat--soon {
    cursor: default;
    opacity: 0.55;
}
.home-cat--soon:hover {
    background: var(--bg-panel);
    border-color: var(--border-subtle);
}
.home-cat--soon .home-cat__name { color: var(--fg-muted); }

.home-section {
    margin-block-end: 1.25rem;
    padding-block-start: 0.6rem;
    border-block-start: 1px solid var(--border-subtle);
}
.home-section h2 {
    margin: 0 0 0.5rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}

.home-chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0;
    margin: 0;
}
.home-chip {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--bg-panel);
    color: var(--fg-muted);
    font-size: var(--fs-sm);
    text-decoration: none;
}
.home-chip:hover, .home-chip:focus-visible {
    background: var(--bg-elevated);
    color: var(--accent-hover);
    border-color: var(--accent-soft);
    text-decoration: none;
}

.home-about {
    margin: 0;
    color: var(--fg-muted);
    font-size: var(--fs-sm);
}
.home-about a { color: var(--link); }

@media (max-width: 600px) {
    .home-cats { grid-template-columns: repeat(2, 1fr); }
}

/* Search results — two columns (Items | Spells), Wowhead-style tables. */
.search-summary { margin-block-end: 0.85rem; }
.search-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
.search-col h2 {
    margin: 0 0 0.5rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.3rem;
}
.search-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.search-table th,
.search-table td {
    padding: 3px 8px;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--border-subtle);
}
.search-table thead th {
    color: var(--fg-muted);
    font-weight: 500;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-block-end: 1px solid var(--border-strong);
}
/* No zebra striping — quality colours (q3 blue, q4 purple, q5 orange, q6 yellow)
   already do the row-level scanning work. Hover gives a subtle highlight. */
.search-table tbody tr:hover td { background: var(--bg-panel); }
.search-table td.num,
.search-table th.num { text-align: end; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.search-table td.muted { color: var(--fg-muted); }
@media (max-width: 800px) {
    .search-grid { grid-template-columns: 1fr; }
}

/* Item page header — icon next to title. */
.item-page .item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-block-end: 0.5rem;
}
.item-page .icon-large {
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.item-page .item-header h1 { margin: 0; }


/* === Quest page ===========================================================
 * Wiki-density quest page — header with side-coloured title + level, dl meta
 * bar, giver chips, body copy with objectives/completion, rewards as a card
 * grid, and a flex-row chain footer.
 * -------------------------------------------------------------------------- */

.quest-page {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: 1rem 1.25rem;
    font-size: var(--fs-base);
}

.quest-page section { margin-block: 1.25rem; }

.quest-page h2 {
    font-size: var(--fs-md);
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.25rem;
    margin-block-end: 0.5rem;
}
.quest-page h3 {
    font-size: var(--fs-base);
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-block-end: 0.3rem;
}

.quest-page__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-block-end: 0.5rem;
}
.quest-page__title { margin: 0; font-size: var(--fs-2xl); }
.quest-page__level {
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-md);
}

.side-alliance { color: #3b82f6; }
.side-horde    { color: #ef4444; }
.side-both     { color: var(--accent); }
.side-neutral  { color: var(--fg-primary); }
.side-hostile  { color: var(--err); }

.quest-page__meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.25rem;
    margin-block: 0.75rem;
    font-size: var(--fs-sm);
}
.quest-page__meta dt { color: var(--fg-muted); font-weight: 600; }
.quest-page__meta dd { margin: 0; }

.quest-page__givers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-block: 0.75rem;
}
.quest-page__giver {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    background: var(--bg-panel);
    font-size: var(--fs-sm);
    color: var(--fg-muted);
}
.quest-page__giver a { color: var(--link); }

.quest-text { margin-block: 0.75rem; }
.quest-text p { margin-block-end: 0.5rem; }
.quest-text--objectives ul.quest-objectives {
    padding-inline-start: 1.25rem;
    list-style: square;
}
.quest-text--objectives ul.quest-objectives li { margin-block-end: 0.15rem; }
.quest-text--completion p { color: var(--fg-muted); font-style: italic; }

.quest-rewards__items,
.quest-rewards__choice,
.quest-rewards__money,
.quest-rewards__xp,
.quest-rewards__rep {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel);
}
.quest-rewards > div,
.quest-rewards > section {
    /* Wrap rewards children in a responsive card grid. */
}
.quest-rewards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
.quest-rewards h2 { grid-column: 1 / -1; }
.quest-rewards__items,
.quest-rewards__choice,
.quest-rewards__money,
.quest-rewards__xp,
.quest-rewards__rep {
    grid-column: 1 / -1;
}
@media (min-width: 640px) {
    .quest-rewards {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
    .quest-rewards__items,
    .quest-rewards__choice,
    .quest-rewards__money,
    .quest-rewards__xp,
    .quest-rewards__rep { grid-column: auto; }
}

.quest-rewards__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.quest-rewards__list li { padding-block: 0.1rem; }

.quest-rewards__money,
.quest-rewards__xp {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.money-gold   { color: #ffd100; }
.money-silver { color: #c0c0c0; }
.money-copper { color: #c08040; }

.quest-chain__list {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 0;
    padding: 0;
}
.quest-chain__prev { text-align: start; }
.quest-chain__next { margin-inline-start: auto; text-align: end; }


/* === NPC page =============================================================
 * Mirrors the quest-page idiom: header block, dl meta, then a stack of small
 * sections (locations / quests / drops / vendor). Tables borrow the
 * `.search-table` cosmetics — small font, 1px borders, hover highlight, no
 * zebra. Drop chance is right-aligned tabular numerics.
 * -------------------------------------------------------------------------- */

.npc-page {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: 1rem 1.25rem;
    font-size: var(--fs-base);
}

.npc-page section { margin-block: 1.25rem; }

.npc-page h2 {
    font-size: var(--fs-md);
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.25rem;
    margin-block-end: 0.5rem;
}

.npc-page__header {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-block-end: 0.5rem;
}
.npc-page__name { margin: 0; font-size: var(--fs-2xl); }
.npc-page__subtitle {
    color: var(--fg-muted);
    font-style: italic;
    font-size: var(--fs-sm);
}
.npc-page__levels {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--fg-muted);
    font-size: var(--fs-sm);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.npc-page__boss,
.npc-page__elite {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 2px;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fff;
    font-family: var(--font-ui);
}
.npc-page__boss  { background: #c2410c; }
.npc-page__elite { background: #6d28d9; }

.npc-page__meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.25rem;
    margin-block: 0.75rem;
    font-size: var(--fs-sm);
}
.npc-page__meta dt { color: var(--fg-muted); font-weight: 600; }
.npc-page__meta dd { margin: 0; }

.npc-page__description {
    color: var(--fg-muted);
    font-size: var(--fs-sm);
    margin-block: 0.75rem;
    max-width: 70ch;
}

/* Bare ul lists for starts/ends quests — compact, link-coloured. */
.npc-quests-starts ul,
.npc-quests-ends ul {
    list-style: none;
    margin: 0;
    padding-inline-start: 0;
    columns: 2;
    column-gap: 1.5rem;
    font-size: var(--fs-sm);
}
.npc-quests-starts li,
.npc-quests-ends li {
    padding-block: 0.1rem;
    break-inside: avoid;
}
@media (max-width: 600px) {
    .npc-quests-starts ul,
    .npc-quests-ends ul { columns: 1; }
}

/* Tables — borrow `.search-table` cosmetics: small font, 1px borders, hover
 * highlight, NO zebra striping. Quality colours on item links carry the
 * scanning load. */
.npc-locations__table,
.npc-drops__table,
.npc-vendor__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.npc-locations__table th,
.npc-locations__table td,
.npc-drops__table th,
.npc-drops__table td,
.npc-vendor__table th,
.npc-vendor__table td {
    padding: 3px 8px;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--border-subtle);
}
.npc-locations__table thead th,
.npc-drops__table thead th,
.npc-vendor__table thead th {
    color: var(--fg-muted);
    font-weight: 500;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-block-end: 1px solid var(--border-strong);
}
.npc-locations__table tbody tr:hover td,
.npc-drops__table tbody tr:hover td,
.npc-vendor__table tbody tr:hover td {
    background: var(--bg-panel);
}

/* Sortable drops table headers. */
.npc-drops__table th[data-sort-key] {
    cursor: pointer;
    user-select: none;
}
.npc-drops__table th[aria-sort="ascending"]::after  { content: " \25B2"; opacity: 0.7; }
.npc-drops__table th[aria-sort="descending"]::after { content: " \25BC"; opacity: 0.7; }

/* Right-align numeric columns: chance / observed in drops, price / stock in
 * vendor, spawns / coords in locations. Nth-child mirrors the renderer
 * column order exactly. */
.npc-drops__table th:nth-child(2),
.npc-drops__table td:nth-child(2),
.npc-drops__table th:nth-child(3),
.npc-drops__table td:nth-child(3) {
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.npc-vendor__table th:nth-child(2),
.npc-vendor__table td:nth-child(2),
.npc-vendor__table th:nth-child(3),
.npc-vendor__table td:nth-child(3) {
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.npc-locations__table th:nth-child(3),
.npc-locations__table td:nth-child(3),
.npc-locations__table th:nth-child(4),
.npc-locations__table td:nth-child(4) {
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}


/* --- Bare .muted utility --- */
.muted { color: var(--fg-muted); }


/* --- Quest reward extras (talents / max-level money / honor / spell / title) ---
 * Mirror the card framing already on .quest-rewards__money / __xp / __rep so
 * every reward subsection looks the same in the responsive grid. */
.quest-rewards__money-max,
.quest-rewards__talents,
.quest-rewards__honor,
.quest-rewards__spell,
.quest-rewards__title {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel);
    grid-column: 1 / -1;
}
.quest-rewards__money-max,
.quest-rewards__honor {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.quest-rewards__money-max { color: var(--fg-muted); }
.quest-rewards__talents  { color: var(--accent-hover); font-weight: 600; }
.quest-rewards__honor    { color: #ff8040; }
@media (min-width: 640px) {
    .quest-rewards__money-max,
    .quest-rewards__talents,
    .quest-rewards__honor,
    .quest-rewards__spell,
    .quest-rewards__title { grid-column: auto; }
}
.quest-reward__item        { font-weight: 500; }
.quest-reward__title-name  { color: var(--accent); font-weight: 600; }


/* --- Item source block (Dropped / Sold / Pickpocketed / Skinned / Quest) --- */
.item-source {
    margin-block-start: 1.25rem;
}
.item-source + .item-source {
    margin-block-start: 1rem;
}
.item-source h2 {
    font-size: var(--fs-md);
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.25rem;
    margin-block-end: 0.4rem;
}
.item-sources {
    list-style: none;
    margin: 0;
    padding-inline-start: 0;
    columns: 2;
    column-gap: 1.5rem;
    font-size: var(--fs-sm);
}
.item-sources li {
    padding-block: 0.1rem;
    break-inside: avoid;
}
.item-sources li.muted {
    color: var(--fg-faint);
    font-style: italic;
}

/* Lazy-loaded comments slot — hide unless the JS populates it. */
.item-comments-placeholder:empty { display: none; }


/* --- Tooltip-internal money classes (item.rs sell-price line) ---
 * Item tooltip uses the un-hyphenated forms (moneygold/moneysilver/moneycopper);
 * the rest of the site uses .money-gold / .money-silver / .money-copper. Both
 * map to the same coin colours. */
.moneygold,   .money-gold   { color: #ffd100; font-variant-numeric: tabular-nums; }
.moneysilver, .money-silver { color: #c0c0c0; font-variant-numeric: tabular-nums; }
.moneycopper, .money-copper { color: #c08040; font-variant-numeric: tabular-nums; }


/* --- Quest badges (Daily / Group / Heroic / Sharable / …) --- */
.quest-page__badges {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.quest-badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    color: var(--fg-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    line-height: 1.5;
}
.quest-badge--type {
    background: rgba(255, 209, 0, 0.08);
    border-color: var(--accent-soft);
    color: var(--accent-hover);
}
.quest-badge--daily,
.quest-badge--weekly {
    background: rgba(0, 112, 221, 0.18);
    border-color: #0070dd;
    color: #71d5ff;
}
.quest-badge--group,
.quest-badge--raid,
.quest-badge--raid-10,
.quest-badge--raid-25 {
    background: rgba(255, 128, 64, 0.15);
    border-color: var(--warn);
    color: var(--warn);
}
.quest-badge--heroic,
.quest-badge--legendary {
    background: rgba(255, 64, 64, 0.16);
    border-color: var(--err);
    color: var(--err);
}
.quest-badge--pvp {
    background: rgba(163, 53, 238, 0.18);
    border-color: var(--q4);
    color: var(--q4);
}
.quest-badge--sharable,
.quest-badge--repeatable,
.quest-badge--auto-accept {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--fg-primary);
}


/* --- NPC page extras (HP / damage / immune dd cells, reputation list) --- */
.npc-page__hp,
.npc-page__dmg {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--fg-primary);
}
.npc-page__immune {
    color: var(--fg-muted);
}

.npc-reputation ul {
    list-style: none;
    margin: 0;
    padding-inline-start: 0;
    columns: 2;
    column-gap: 1.5rem;
    font-size: var(--fs-sm);
}
.npc-reputation li {
    padding-block: 0.1rem;
    break-inside: avoid;
}
.rep-gain { color: var(--ok); font-variant-numeric: tabular-nums; }
.rep-loss { color: var(--err); font-variant-numeric: tabular-nums; }


/* --- NPC trainer block (Teaches table) --- */
.npc-trainer__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.npc-trainer__table th,
.npc-trainer__table td {
    padding: 3px 8px;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--border-subtle);
}
.npc-trainer__table thead th {
    color: var(--fg-muted);
    font-weight: 500;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-block-end: 1px solid var(--border-strong);
}
.npc-trainer__table tbody tr:hover td {
    background: var(--bg-panel);
}
/* Cost / Skill / Lvl right-aligned, tabular. */
.npc-trainer__table th:nth-child(2),
.npc-trainer__table td:nth-child(2),
.npc-trainer__table th:nth-child(3),
.npc-trainer__table td:nth-child(3),
.npc-trainer__table th:nth-child(4),
.npc-trainer__table td:nth-child(4) {
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.npc-trainer__more {
    margin-block-start: 0.4rem;
    color: var(--fg-faint);
    font-size: var(--fs-sm);
    font-style: italic;
}


/* --- NPC locations table column hints (Map | Area | Coords | Spawns) --- */
.npc-locations__table th:first-child,
.npc-locations__table td:first-child { width: 1%; white-space: nowrap; }
.npc-locations__table th:nth-child(2),
.npc-locations__table td:nth-child(2) { width: auto; }


/* --- Listing pages (/items, /spells, /quests, /npcs, /worldforged) --- */
.listing { margin-block-end: 1.5rem; }
.listing > h1 {
    font-size: var(--fs-xl);
    margin-block-end: 0.6rem;
}
.listing__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.6rem 0.8rem;
    margin-block-end: 0.8rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}
.listing__filters label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--fg-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.listing__filters input,
.listing__filters select {
    font-size: var(--fs-sm);
    text-transform: none;
    letter-spacing: 0;
    color: var(--fg-primary);
}
.listing__filters button {
    background: var(--bg-elevated);
    color: var(--fg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.9rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    transition: background-color 80ms linear, color 80ms linear;
}
.listing__filters button:hover,
.listing__filters button:focus-visible {
    background: var(--accent);
    color: #000;
}

.listing__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.listing__table th,
.listing__table td {
    padding: 0.4rem 0.75rem;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid var(--border-subtle);
}
.listing__table thead th {
    background: var(--bg-shell);
    color: var(--fg-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: var(--fs-xs);
    border-block-end: 1px solid var(--border-strong);
}
.listing__table tbody tr:nth-child(even) td {
    background: var(--bg-panel-alt);
}
.listing__table tbody tr:hover td {
    background: var(--bg-elevated);
}
.listing__table tbody tr:last-child td {
    border-block-end: 0;
}
.listing__table td.num,
.listing__table th.num {
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.listing__table td.muted { color: var(--fg-muted); }


/* --- Pagination strip --- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-block: 0.6rem;
    font-size: var(--fs-sm);
    color: var(--fg-muted);
}
.pagination a {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--fg-primary);
    text-decoration: none;
}
.pagination a:hover,
.pagination a:focus-visible {
    background: var(--accent);
    color: #000;
    border-color: var(--accent-soft);
    text-decoration: none;
}


/* --- Search results: 5-column responsive grid --- */
.search-results > h1 {
    font-size: var(--fs-xl);
    margin-block-end: 0.4rem;
}
.search-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}


/* --- 720px breakpoint: stack source columns, allow tables to scroll --- */
@media (max-width: 720px) {
    .item-sources,
    .npc-reputation ul {
        columns: 1;
    }
    .listing__table,
    .npc-trainer__table,
    .npc-locations__table,
    .npc-drops__table,
    .npc-vendor__table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .search-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .site-main,
    .quest-page,
    .npc-page {
        padding-inline: 0.6rem;
    }
}

/* ---------- Class & talent pages ------------------------------------- */

.class-page__head { margin-block-end: 1rem; }
.class-page__head h1 { margin-block-end: 0.2rem; }

.class-page__trees {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-block-start: 1rem;
}

.talent-tree {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 0.75rem 0.85rem 1rem;
}
.talent-tree__head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-block-end: 0.6rem;
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.4rem;
}
.talent-tree__head h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--fg-primary);
}

/* 4-column Wowhead-classic grid. The `style` attribute on .talent-grid sets
   grid-template-rows dynamically because tier counts vary per tab. */
.talent-grid {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    column-gap: 16px;
    row-gap: 12px;
    justify-content: center;
}

.talent-cell {
    width: 56px;
    height: 56px;
    position: relative;
    display: block;
}
.talent-cell--empty { /* keeps grid track without visible content */ }

.talent-cell--filled {
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,.6) inset;
    transition: border-color 80ms linear, transform 80ms linear;
}
.talent-cell--filled:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    z-index: 2;
}
.talent-cell--filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.talent-cell__rank {
    position: absolute;
    inset-block-end: -2px;
    inset-inline-end: -2px;
    background: rgba(0,0,0,.85);
    color: var(--fg-primary);
    font-size: 0.75rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    pointer-events: none;
}

/* Class index page reuses .listing — no extra rules needed. */

/* "Class spells" section under the talent grids. Wide-but-tight table. */
.class-spells { margin-block-start: 1.5rem; }
.class-spells__head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-block-end: 0.5rem;
    border-block-end: 1px solid var(--border-subtle);
    padding-block-end: 0.35rem;
}
.class-spells__head h2 { margin: 0; font-size: 1.1rem; color: var(--fg-primary); }
.class-spells__table { width: 100%; max-width: 720px; }
.class-spells__icon { width: 28px; padding-inline-end: 0; }
.class-spells__icon img {
    display: block;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
}
