/* ============================================================================
 * Shared UI layer.
 *
 * This file owns everything that appears on more than one page: design tokens,
 * the application bar and navigation, the notice banner, and the common panel,
 * button, form and badge primitives.
 *
 * It is loaded last, after each page's inline <style> block, so it wins on
 * equal specificity. Page-specific styling (vault drag-and-drop, profession
 * bars, charts) stays with its page.
 * ========================================================================= */

/* ── Design tokens ───────────────────────────────────────────────────────── */

:root {
    /* Surfaces, from deepest to most raised. */
    --bg: #0d0a06;
    --surface-1: rgba(26, 20, 13, 0.92);
    --surface-2: rgba(38, 30, 19, 0.92);
    --surface-3: rgba(54, 43, 28, 0.92);
    --surface-glass: rgba(18, 14, 9, 0.82);

    /* Ink. */
    --text: #f2e4ca;
    --text-dim: #c4b494;
    --text-faint: #8f8168;
    --heading: #ffd77a;

    /* Lines. */
    --line: rgba(160, 136, 96, 0.28);
    --line-strong: rgba(180, 154, 108, 0.5);

    /* Accents. */
    --gold: #c8a050;
    --gold-bright: #ffd77a;
    --success: #63c47a;
    --danger: #e0685f;
    --info: #6aa9e0;
    --warn: #dcb646;

    /* Per-section hues, reused by nav and page accents. */
    --hue-vault: #b47fe8;
    --hue-roster: #e8c14f;
    --hue-prof: #4fd39a;
    --hue-decor: #e87fc0;
    --hue-raids: #e0836a;
    --hue-history: #6aa9e0;

    /* Type. Serif for display, sans for interface text: the original design
       used Palatino for everything, which reads poorly at small sizes. */
    --font-display: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Spacing scale. */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;

    --radius: 8px;
    --radius-sm: 5px;
    --radius-pill: 999px;

    --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-3: 0 10px 34px rgba(0, 0, 0, 0.5);

    --ring: 0 0 0 2px rgba(255, 215, 122, 0.75);

    --appbar-h: 56px;
}

/* ── Base ────────────────────────────────────────────────────────────────── */

body {
    /* Push content below the sticky bar. */
    padding-top: calc(var(--appbar-h) + var(--sp-4)) !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Interface text uses the sans stack; headings keep the serif character. */
.appbar,
.notice,
.btn,
.panel,
.chip,
.tag,
input,
select,
textarea,
button,
table {
    font-family: var(--font-ui);
}

h1, h2, h3, .page-title {
    font-family: var(--font-display);
}

::selection {
    background: rgba(255, 215, 122, 0.28);
}

/* Consistent, visible keyboard focus everywhere. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: var(--radius-sm);
}

/* Skip link for keyboard users. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-3);
    color: var(--gold-bright);
    border: 1px solid var(--line-strong);
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    left: 0;
}

/* ── Application bar ─────────────────────────────────────────────────────── */

.appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--appbar-h);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-4);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    backdrop-filter: blur(12px) saturate(1.2);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-2);
}

.appbar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
    color: var(--heading);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.appbar-brand img {
    width: 24px;
    height: 24px;
    filter: drop-shadow(var(--shadow-1));
}

.appbar-brand span {
    display: none;
}

@media (min-width: 900px) {
    .appbar-brand span {
        display: inline;
    }
}

.appbar-spacer {
    flex: 1;
}

.appbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */

/* The nav lives in the bar as a horizontal row. It used to be an absolutely
   positioned vertical column pinned to the top-left of the page, which
   overlapped page content at anything below desktop width. */
.appnav {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.appnav::-webkit-scrollbar {
    display: none;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--line);
}

.nav-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    filter: drop-shadow(var(--shadow-1));
    opacity: 0.9;
}

/* The active page is marked with its section colour rather than a generic
   highlight, so the bar doubles as a location indicator. */
.nav-btn-active {
    background: var(--surface-3);
    color: var(--text);
    border-color: var(--line-strong);
    font-weight: 600;
    position: relative;
}

.nav-btn-active::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.85;
}

.nav-btn-vault.nav-btn-active { color: var(--hue-vault); }
.nav-btn-roster.nav-btn-active { color: var(--hue-roster); }
.nav-btn-prof.nav-btn-active { color: var(--hue-prof); }
.nav-btn-decor.nav-btn-active { color: var(--hue-decor); }
.nav-btn-raids.nav-btn-active { color: var(--hue-raids); }
.nav-btn-history.nav-btn-active { color: var(--hue-history); }

.nav-btn-vault:hover { color: var(--hue-vault); }
.nav-btn-roster:hover { color: var(--hue-roster); }
.nav-btn-prof:hover { color: var(--hue-prof); }
.nav-btn-decor:hover { color: var(--hue-decor); }
.nav-btn-raids:hover { color: var(--hue-raids); }
.nav-btn-history:hover { color: var(--hue-history); }

.nav-btn-logout {
    color: var(--text-faint);
}

.nav-btn-logout:hover {
    color: var(--danger);
    border-color: rgba(224, 104, 95, 0.4);
    background: rgba(224, 104, 95, 0.1);
}

/* Forms wrapping POST buttons must not introduce layout of their own. */
.nav-form {
    display: contents;
}

/* ── User bar ────────────────────────────────────────────────────────────── */

.userbar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 4px 4px 4px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    font-family: var(--font-ui);
    font-size: 0.76rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.userbar-tag {
    font-weight: 600;
    color: var(--gold-bright);
}

.userbar-sep { opacity: 0.35; }
.userbar-updated,
.userbar-stale { color: var(--text-faint); }
.userbar-stale { font-style: italic; }

.userbar-refresh {
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.userbar-refresh:hover:not(:disabled) {
    border-color: var(--gold-bright);
    color: var(--gold-bright);
}

.userbar-refresh:disabled {
    opacity: 0.55;
    cursor: progress;
}

/* Per-page headers no longer carry navigation, so the space reserved for the
   old absolute nav column is not needed. */
.header-nav-btns {
    display: contents;
}

/* ── Page shell ──────────────────────────────────────────────────────────── */

/* Each page brought its own .container width. Unify them so navigating between
   pages does not shift the layout. */
.container {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
}

/* The page header is now a compact title block: the branding lives in the bar,
   so a 350px logo above every page was pure vertical cost. */
/* Every page has the same header now: a title on the left, optional metadata
   on the right. Branding lives in the app bar, so a per-page hero logo was
   both redundant and a lot of vertical cost. */
header {
    position: static !important;
    display: flex !important;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    text-align: left !important;
    padding: var(--sp-1) 0 var(--sp-4) !important;
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--sp-5);
}

header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--heading);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    margin: 0 !important;
}

header h1 img {
    vertical-align: middle;
    margin-right: var(--sp-2);
}

/* The right-hand slot of the page header: a timestamp or a one-line subtitle. */
.last-update,
.page-meta {
    font-size: 0.78rem;
    color: var(--text-faint);
}

/* ── Notice banner ───────────────────────────────────────────────────────── */

.notice {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    max-width: 900px;
    margin: 0 auto var(--sp-5);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--line);
    border-left: 3px solid var(--info);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.5;
    box-shadow: var(--shadow-1);
}

.notice-info { border-left-color: var(--info); }
.notice-warn { border-left-color: var(--warn); }
.notice-error { border-left-color: var(--danger); }

.notice-spinner {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border: 2px solid rgba(242, 228, 202, 0.2);
    border-top-color: var(--gold-bright);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Primitives ──────────────────────────────────────────────────────────── */

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: var(--shadow-1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    background: var(--surface-3);
    border-color: var(--gold-bright);
    color: var(--gold-bright);
}

.btn-primary {
    background: linear-gradient(180deg, rgba(200, 160, 80, 0.24), rgba(140, 110, 45, 0.24));
    border-color: var(--gold);
    color: var(--gold-bright);
}

.btn-primary:hover {
    background: linear-gradient(180deg, rgba(200, 160, 80, 0.36), rgba(140, 110, 45, 0.36));
}

.btn:disabled,
.btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Form controls. The originals inherited a serif font and had no focus state. */
input[type="text"],
input[type="search"],
select,
textarea {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    transition: border-color 0.15s ease;
}

input[type="search"]::placeholder {
    color: var(--text-faint);
}

input[type="text"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
    border-color: var(--line-strong);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    :root {
        --appbar-h: 52px;
    }

    .appbar {
        gap: var(--sp-2);
        padding: 0 var(--sp-2);
    }

    /* Collapse labels to icons so the whole nav still fits one row. */
    .appnav .nav-btn {
        padding: 7px 9px;
        gap: 0;
    }

    .appnav .nav-btn .nav-label {
        display: none;
    }

    .userbar-updated,
    .userbar-sep {
        display: none;
    }
}

@media (max-width: 640px) {
    .userbar-tag {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .notice {
        margin-left: var(--sp-2);
        margin-right: var(--sp-2);
    }
}


/* ── Insights ────────────────────────────────────────────────────────────── */

/* Derived observations, computed from data already fetched. */
.insights {
    margin-bottom: var(--sp-5);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-1);
    overflow: hidden;
}

.insights-head {
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
}

.insight {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 11px 16px;
    border-bottom: 1px solid rgba(160, 136, 96, 0.14);
    border-left: 3px solid transparent;
}

.insight:last-child { border-bottom: none; }
.insight-warn { border-left-color: var(--warn); }
.insight-info { border-left-color: var(--info); }

.insight-text { flex: 1; min-width: 0; font-size: 0.85rem; line-height: 1.5; }
.insight-title { font-weight: 600; color: var(--text); margin-right: 6px; }
.insight-body { color: var(--text-dim); }

.insight-link {
    flex-shrink: 0;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.75rem;
    text-decoration: none;
}

.insight-link:hover { border-color: var(--gold-bright); color: var(--gold-bright); }

/* ── Collections ─────────────────────────────────────────────────────────── */

.collections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.collection {
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-1);
}

.collection-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: 9px;
}

.collection-head img { width: 20px; height: 20px; flex-shrink: 0; }
.collection-name { font-size: 0.82rem; color: var(--text); }

.collection-count {
    margin-left: auto;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.collection-bar {
    height: 6px;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.collection-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, #6b4f16, var(--gold) 60%, var(--gold-bright));
}

.collection-foot {
    margin-top: 7px;
    font-size: 0.7rem;
    color: var(--text-faint);
}

/* ── Character card additions ────────────────────────────────────────────── */

.summary-stat-note {
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--text-faint);
}

.stat-value.mplus { color: var(--hue-history); font-weight: 600; }

.raid-progress,
.gear-issues {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid rgba(160, 136, 96, 0.18);
    font-size: 0.75rem;
}

.raid-progress strong,
.gear-issues strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    font-weight: 600;
}

.raid-line {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: 5px;
}

.raid-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
}

.raid-modes { display: flex; gap: 4px; flex-shrink: 0; }

.raid-mode {
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    font-size: 0.66rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.raid-mode.cleared {
    border-color: rgba(99, 196, 122, 0.5);
    background: rgba(99, 196, 122, 0.12);
    color: #b6ebc4;
}

.gear-issue {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: 4px;
}

.gear-slot {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
}

.gear-kind {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-size: 0.66rem;
    white-space: nowrap;
}

.gear-enchant {
    border: 1px solid rgba(220, 182, 70, 0.5);
    color: #f0d78a;
}

.gear-socket {
    border: 1px solid rgba(106, 169, 224, 0.5);
    color: #a6cdf0;
}
/* ── Faction mark ────────────────────────────────────────────────────────── */

/* Rendered by the shared "faction" partial, so the rules belong here rather
   than in a page's style block. It replaced a full-width coloured bar per
   card, which dominated the layout for very little information. */
.faction-badge {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 50%;
}

.faction-badge img {
    width: 15px;
    height: 15px;
}

.faction-alliance {
    border-color: rgba(90, 150, 220, 0.55);
    background: rgba(40, 80, 140, 0.28);
}

.faction-horde {
    border-color: rgba(200, 80, 70, 0.55);
    background: rgba(130, 40, 35, 0.28);
}
/* ── Character tracking ──────────────────────────────────────────────────── */

.tracking-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
    padding: 10px 15px;
    margin-bottom: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-1);
    font-size: 0.82rem;
    color: var(--text-dim);
}

.tracking-info strong { color: var(--gold-bright); }
.tracking-actions { display: flex; gap: var(--sp-2); margin-left: auto; flex-wrap: wrap; }

.btn-sm {
    padding: 5px 11px;
    font-size: 0.76rem;
}

/* Rendered by the shared "trackToggle" partial. */
.track-toggle {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-faint);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.track-toggle:hover {
    border-color: var(--gold-bright);
    color: var(--gold-bright);
}

.track-toggle.on {
    border-color: rgba(99, 196, 122, 0.55);
    color: var(--success);
}

/* An excluded character stays visible, because its gold still counts towards
   the account total, but it is clearly set back. */
.character-card.excluded {
    opacity: 0.55;
}

.character-card.excluded:hover {
    opacity: 0.85;
}

/* Says plainly why the card is dimmed, rather than leaving the reader to
   infer it from the opacity. */
.excluded-note {
    margin-bottom: 7px;
    padding: 4px 8px;
    border-left: 2px solid var(--line-strong);
    border-radius: 0 3px 3px 0;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.7rem;
    font-style: italic;
    color: var(--text-faint);
}
/* ============================================================================
 * Motion
 *
 * Only transform and opacity are animated. Both are composited by the GPU, so
 * they do not trigger layout or paint; animating height, width or top would.
 *
 * Everything here is wrapped by the reduced-motion block at the end of this
 * file, which is the last rule in the cascade so it always wins.
 * ========================================================================= */

:root {
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur-fast: 120ms;
    --dur: 200ms;
    --dur-slow: 420ms;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

@keyframes grow-bar {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes shimmer {
    to { background-position: 200% 0; }
}

@keyframes pop {
    50% { transform: scale(1.18); }
}

/* ── Page entrance ───────────────────────────────────────────────────────── */

.appbar {
    animation: slide-down var(--dur) var(--ease-out) both;
}

header,
.notice,
.insights,
.summary,
.filters,
.week,
.stats-row,
.table-wrap,
.tracking-bar,
.tasks-panel,
.explainer,
.progress-bar {
    animation: rise var(--dur-slow) var(--ease-out) both;
}

/* A short stagger reads as the page settling rather than a list of separate
   animations. Capped at eight so a forty-character account does not spend two
   seconds fading in. */
.characters > *,
.collections > *,
.decor-grid > *,
.vault-grid > *,
.expansion {
    animation: rise 340ms var(--ease-out) both;
}

.characters > *:nth-child(1),  .collections > *:nth-child(1),
.decor-grid > *:nth-child(1),  .vault-grid > *:nth-child(1) { animation-delay: 0ms; }
.characters > *:nth-child(2),  .collections > *:nth-child(2),
.decor-grid > *:nth-child(2),  .vault-grid > *:nth-child(2) { animation-delay: 35ms; }
.characters > *:nth-child(3),  .collections > *:nth-child(3),
.decor-grid > *:nth-child(3),  .vault-grid > *:nth-child(3) { animation-delay: 70ms; }
.characters > *:nth-child(4),  .collections > *:nth-child(4),
.decor-grid > *:nth-child(4),  .vault-grid > *:nth-child(4) { animation-delay: 105ms; }
.characters > *:nth-child(5),  .decor-grid > *:nth-child(5),
.vault-grid > *:nth-child(5) { animation-delay: 140ms; }
.characters > *:nth-child(6),  .decor-grid > *:nth-child(6),
.vault-grid > *:nth-child(6) { animation-delay: 175ms; }
.characters > *:nth-child(7),  .decor-grid > *:nth-child(7),
.vault-grid > *:nth-child(7) { animation-delay: 210ms; }
.characters > *:nth-child(n+8), .decor-grid > *:nth-child(n+8),
.vault-grid > *:nth-child(n+8) { animation-delay: 245ms; }

.insight { animation: fade var(--dur) var(--ease-out) both; }
.insight:nth-child(2) { animation-delay: 40ms; }
.insight:nth-child(3) { animation-delay: 80ms; }
.insight:nth-child(4) { animation-delay: 120ms; }
.insight:nth-child(n+5) { animation-delay: 160ms; }

/* ── Progress bars ───────────────────────────────────────────────────────── */

/* Scale from the left so the fill grows rather than slides. */
.collection-fill,
.progress-fill {
    transform-origin: left center;
    animation: grow-bar var(--dur-slow) var(--ease-out) both;
    animation-delay: 120ms;
}

/* ── Cards and rows ──────────────────────────────────────────────────────── */

.character-card,
.vault-card,
.decor-card,
.collection,
.stat,
.rc {
    transition:
        transform var(--dur) var(--ease-out),
        border-color var(--dur) var(--ease-out),
        background-color var(--dur) var(--ease-out),
        box-shadow var(--dur) var(--ease-out);
    will-change: transform;
}

.character-card:hover,
.vault-card:hover,
.decor-card:hover,
.collection:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

/* An excluded card must not invite interaction as strongly. */
.character-card.excluded:hover {
    transform: none;
    box-shadow: none;
}

.raid,
tbody tr {
    transition: background-color var(--dur-fast) linear;
}

/* ── Controls ────────────────────────────────────────────────────────────── */

.btn,
.nav-btn,
.userbar-refresh,
.chip,
.exp-chip,
.task-chip,
.segmented a {
    transition:
        transform var(--dur-fast) var(--ease-out),
        background-color var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out);
}

/* Press feedback: the control moves under the cursor, so a click feels
   acknowledged even though the page then reloads. */
.btn:active,
.userbar-refresh:active,
.exp-chip:active,
.segmented a:active {
    transform: translateY(1px) scale(0.985);
}

.track-toggle,
.toggle,
.tick {
    transition:
        transform var(--dur-fast) var(--ease-spring),
        border-color var(--dur-fast) linear,
        color var(--dur-fast) linear,
        background-color var(--dur-fast) linear;
}

.track-toggle:hover,
.toggle:hover,
.tick:hover {
    transform: scale(1.12);
}

.track-toggle:active,
.toggle:active,
.tick:active {
    transform: scale(0.92);
}

/* The state a toggle lands in gets a brief pop, so the change is visible even
   though the page reloaded underneath it. */
.track-toggle.on,
.toggle.on,
.tick.on {
    animation: pop 320ms var(--ease-spring) both;
}

/* Nav: the active underline wipes in instead of appearing. */
.nav-btn-active::after {
    transform-origin: left center;
    animation: grow-bar var(--dur) var(--ease-out) both;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

/* Shimmer for the waiting state, which previously was a bare spinner and a
   line of text. */
.loading-message {
    animation: fade var(--dur) var(--ease-out) both;
}

.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 37%,
        var(--surface-2) 63%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

.notice-spinner {
    animation: spin 0.9s linear infinite;
}

/* ── Loading skeleton ────────────────────────────────────────────────────── */

.loading-message {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--sp-5) 0;
    text-align: left;
}

.loading-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: 0.95rem;
    color: var(--text);
}

.loading-note {
    margin-top: 6px;
    margin-left: 27px;
    font-size: 0.8rem;
    color: var(--text-faint);
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-5);
}

.skeleton-card {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-1);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
}

.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-top: 3px;
}

.skeleton-line { height: 9px; }
.w-40 { width: 40%; }
.w-50 { width: 50%; }
.w-60 { width: 60%; }
.w-70 { width: 70%; }
.w-80 { width: 80%; }

/* ── Reduced motion ──────────────────────────────────────────────────────────
 *
 * Last in the file on purpose. Entrance animations are removed outright rather
 * than shortened, because a 0.01s "animation" still flashes. Elements animated
 * with `both` would stay at their from-state without this, so opacity and
 * transform are reset explicitly.
 */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .appbar,
    header,
    .notice,
    .insights,
    .insight,
    .summary,
    .filters,
    .week,
    .stats-row,
    .table-wrap,
    .tracking-bar,
    .tasks-panel,
    .explainer,
    .progress-bar,
    .characters > *,
    .collections > *,
    .decor-grid > *,
    .vault-grid > *,
    .expansion,
    .collection-fill,
    .progress-fill,
    .nav-btn-active::after {
        opacity: 1 !important;
        transform: none !important;
    }

    /* The spinner and the loading skeleton are the only animations that carry
       meaning, so they survive at a calmer pace. */
    .notice-spinner {
        animation: spin 2s linear infinite !important;
    }

    .skeleton {
        animation: shimmer 3s linear infinite !important;
    }
}