/* Theme Shells: structural layout changes per theme pack.
   Loaded after base/page CSS so it can remap page composition. */

/* Aurora: sidebar inherits base layout, no structural override needed */

[data-theme-pref="aurora"] main {
    width: min(1280px, 94vw);
}

[data-theme-pref="aurora"] .footer {
    width: min(1280px, 94vw);
}

[data-theme-pref="aurora"] body[data-page="features"] main {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 16px;
}

[data-theme-pref="aurora"] body[data-page="features"] main > section:nth-of-type(1),
[data-theme-pref="aurora"] body[data-page="features"] main > section:nth-of-type(4) {
    grid-column: 1 / -1;
}

[data-theme-pref="aurora"] body[data-page="features"] main > section:nth-of-type(2),
[data-theme-pref="aurora"] body[data-page="features"] main > section:nth-of-type(3) {
    margin-top: 0;
}

[data-theme-pref="aurora"] body[data-page="leaderboard"] .lb-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
}

[data-theme-pref="aurora"] body[data-page="leaderboard"] .lb-tabs {
    display: grid;
    gap: 8px;
    align-content: start;
}

[data-theme-pref="aurora"] body[data-page="messages"] .msg-layout {
    grid-template-columns: 320px minmax(0, 1fr);
}

[data-theme-pref="aurora"] body[data-page="profile"] .profile-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

[data-theme-pref="aurora"] body[data-page="stats"] .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Ember: sidebar styling (warm tones) */
[data-theme-pref="ember"] .sidebar {
    background: rgba(18, 9, 10, 0.96);
    border-right-color: rgba(255, 174, 125, 0.3);
}

[data-theme-pref="ember"] main {
    width: min(1320px, 95vw);
    margin-top: 20px;
}

[data-theme-pref="ember"] .footer {
    width: min(1320px, 95vw);
    margin-bottom: 122px;
}

[data-theme-pref="ember"] body[data-page="features"] main {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
}

[data-theme-pref="ember"] body[data-page="features"] main > section:nth-of-type(1),
[data-theme-pref="ember"] body[data-page="features"] main > section:nth-of-type(4) {
    grid-column: 1 / -1;
}

[data-theme-pref="ember"] body[data-page="features"] main > section:nth-of-type(2) {
    grid-column: 1 / span 5;
}

[data-theme-pref="ember"] body[data-page="features"] main > section:nth-of-type(3) {
    grid-column: 6 / span 7;
}

[data-theme-pref="ember"] body[data-page="leaderboard"] .lb-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

[data-theme-pref="ember"] body[data-page="leaderboard"] .lb-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

[data-theme-pref="ember"] body[data-page="stats"] .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    grid-template-areas: "conversation inbox";
    gap: 10px;
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-conversation {
    grid-area: conversation;
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-inbox {
    grid-area: inbox;
}

[data-theme-pref="ember"] body[data-page="profile"] .profile-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Graphite: sidebar styling (steel tones) */
[data-theme-pref="graphite"] .sidebar {
    background: rgba(10, 14, 23, 0.98);
    border-right-color: rgba(143, 170, 214, 0.24);
}

/* Graphite main/footer width handled by base sidebar layout */

[data-theme-pref="graphite"] body[data-page="features"] main {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 12px;
}

[data-theme-pref="graphite"] body[data-page="features"] main > section:nth-of-type(1),
[data-theme-pref="graphite"] body[data-page="features"] main > section:nth-of-type(4) {
    grid-column: 1 / -1;
}

[data-theme-pref="graphite"] body[data-page="features"] main > section:nth-of-type(2),
[data-theme-pref="graphite"] body[data-page="features"] main > section:nth-of-type(3) {
    margin-top: 0;
}

[data-theme-pref="graphite"] body[data-page="features"] .search-section {
    position: static;
}

[data-theme-pref="graphite"] body[data-page="leaderboard"] .lb-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 10px;
}

[data-theme-pref="graphite"] body[data-page="leaderboard"] .lb-tabs {
    display: grid;
    gap: 8px;
}

[data-theme-pref="graphite"] body[data-page="stats"] .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

[data-theme-pref="graphite"] body[data-page="messages"] .msg-layout {
    grid-template-columns: 280px minmax(0, 1fr);
}

[data-theme-pref="graphite"] body[data-page="profile"] .profile-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Responsive: sidebar is always sidebar, no topbar fallback needed */
@media (max-width: 1180px) {
    [data-theme-pref="aurora"] body[data-page="features"] main,
    [data-theme-pref="ember"] body[data-page="features"] main,
    [data-theme-pref="graphite"] body[data-page="features"] main {
        display: block;
    }
}

@media (max-width: 900px) {
    [data-theme-pref="ember"] body[data-page="messages"] .msg-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "inbox"
            "conversation";
    }
}

/* Full-site shell extensions */
[data-theme-pref="aurora"] body[data-page-group],
[data-theme-pref="ember"] body[data-page-group],
[data-theme-pref="graphite"] body[data-page-group] {
    min-height: 100vh;
}

[data-theme-pref="aurora"] body[data-page-group="site"] main,
[data-theme-pref="ember"] body[data-page-group="site"] main,
[data-theme-pref="graphite"] body[data-page-group="site"] main {
    display: grid;
    gap: 18px;
}

[data-theme-pref="aurora"] body[data-page-group="site"] main > .hero,
[data-theme-pref="ember"] body[data-page-group="site"] main > .hero,
[data-theme-pref="graphite"] body[data-page-group="site"] main > .hero {
    margin-bottom: 0;
}

/* Aurora page shells */
[data-theme-pref="aurora"] body[data-page-group="site"] main > .section,
[data-theme-pref="aurora"] body[data-page-group="site"] main > .profile-search-section,
[data-theme-pref="aurora"] body[data-page-group="site"] main > .profile-container {
    border: 1px solid rgba(144, 166, 255, 0.3);
    border-radius: 18px;
    background:
        radial-gradient(circle at 12% 8%, rgba(77, 216, 255, 0.12), transparent 34%),
        radial-gradient(circle at 86% 12%, rgba(184, 118, 255, 0.11), transparent 38%),
        rgba(10, 14, 36, 0.78);
    padding: 14px;
    box-shadow: 0 16px 32px rgba(7, 10, 28, 0.44);
}

[data-theme-pref="aurora"] body[data-page="stats"] #statsGrid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

[data-theme-pref="aurora"] body[data-page="stats"] #recordsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

[data-theme-pref="aurora"] body[data-page="stats"] .stats-charts-grid {
    grid-template-columns: 1.25fr 0.75fr;
}

[data-theme-pref="aurora"] body[data-page="changelog"] .section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

[data-theme-pref="aurora"] body[data-page="spectate"] .spec-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-theme-pref="aurora"] body[data-page="messages"] .msg-layout {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 12px;
}

[data-theme-pref="aurora"] body[data-page="profile"] .profile-search-section {
    position: sticky;
    top: 92px;
    z-index: 20;
}

[data-theme-pref="aurora"] body[data-page="profile"] .profile-container {
    margin-top: 0;
}

[data-theme-pref="aurora"] body[data-page="login"] .auth-shell {
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
}

[data-theme-pref="aurora"] body[data-page="login"] .auth-card {
    border-radius: 18px;
    border: 1px solid rgba(145, 161, 243, 0.38);
    background: rgba(10, 14, 36, 0.84);
}

[data-theme-pref="aurora"] body[data-page="account"] .account-shell,
[data-theme-pref="aurora"] body[data-page="admin"] .account-shell,
[data-theme-pref="aurora"] body[data-page="admin-user"] .account-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
}

[data-theme-pref="aurora"] body[data-page="moderator"] .mod-container {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
}

[data-theme-pref="aurora"] body[data-page="admin-compare"] .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* Ember page shells */
[data-theme-pref="ember"] body[data-page-group="site"] main > .section,
[data-theme-pref="ember"] body[data-page-group="site"] main > .profile-search-section,
[data-theme-pref="ember"] body[data-page-group="site"] main > .profile-container {
    border: 1px solid rgba(255, 168, 114, 0.32);
    border-radius: 14px;
    background:
        radial-gradient(circle at 14% 10%, rgba(255, 200, 133, 0.12), transparent 35%),
        radial-gradient(circle at 86% 16%, rgba(255, 111, 97, 0.12), transparent 36%),
        rgba(22, 10, 10, 0.82);
    padding: 13px;
    box-shadow: 0 16px 34px rgba(12, 6, 6, 0.48);
}

[data-theme-pref="ember"] body[data-page="features"] main > .section:nth-of-type(1) {
    order: 2;
}

[data-theme-pref="ember"] body[data-page="features"] main > .section:nth-of-type(2) {
    order: 1;
}

[data-theme-pref="ember"] body[data-page="features"] main > .section:nth-of-type(3) {
    order: 3;
}

[data-theme-pref="ember"] body[data-page="stats"] #statsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-theme-pref="ember"] body[data-page="stats"] #recordsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-theme-pref="ember"] body[data-page="stats"] .stats-charts-grid {
    grid-template-columns: 1fr;
}

[data-theme-pref="ember"] body[data-page="changelog"] .section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-layout {
    grid-template-columns: 1.15fr 0.85fr;
    grid-template-areas: "conversation inbox";
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-conversation {
    grid-area: conversation;
}

[data-theme-pref="ember"] body[data-page="messages"] .msg-inbox {
    grid-area: inbox;
}

[data-theme-pref="ember"] body[data-page="account"] .account-shell,
[data-theme-pref="ember"] body[data-page="admin"] .account-shell,
[data-theme-pref="ember"] body[data-page="admin-user"] .account-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

[data-theme-pref="ember"] body[data-page="account"] .account-menu,
[data-theme-pref="ember"] body[data-page="admin"] .account-menu,
[data-theme-pref="ember"] body[data-page="admin-user"] .account-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

[data-theme-pref="ember"] body[data-page="moderator"] .mod-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

[data-theme-pref="ember"] body[data-page="moderator"] .mod-sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

[data-theme-pref="ember"] body[data-page="admin-compare"] .compare-grid {
    grid-template-columns: 1fr;
}

[data-theme-pref="ember"] body[data-page="spectate"] .spec-list {
    grid-template-columns: 1fr;
}

[data-theme-pref="ember"] body[data-page="login"] .auth-card {
    border-radius: 14px;
    border-color: rgba(255, 159, 97, 0.42);
    box-shadow: 0 12px 32px rgba(26, 10, 7, 0.45);
}

/* Graphite page shells */
[data-theme-pref="graphite"] body[data-page-group="site"] main > .section,
[data-theme-pref="graphite"] body[data-page-group="site"] main > .profile-search-section,
[data-theme-pref="graphite"] body[data-page-group="site"] main > .profile-container {
    border: 1px solid rgba(142, 168, 214, 0.3);
    border-radius: 12px;
    background:
        linear-gradient(160deg, rgba(17, 24, 37, 0.94), rgba(10, 14, 22, 0.96));
    padding: 12px;
    box-shadow: 0 18px 34px rgba(4, 7, 12, 0.56);
}

[data-theme-pref="graphite"] body[data-page="stats"] #statsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

[data-theme-pref="graphite"] body[data-page="stats"] #recordsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

[data-theme-pref="graphite"] body[data-page="stats"] .stats-charts-grid {
    grid-template-columns: 1fr 1fr;
}

[data-theme-pref="graphite"] body[data-page="messages"] .msg-layout {
    grid-template-columns: 280px minmax(0, 1fr);
}

[data-theme-pref="graphite"] body[data-page="changelog"] .section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

[data-theme-pref="graphite"] body[data-page="account"] .account-shell,
[data-theme-pref="graphite"] body[data-page="admin"] .account-shell,
[data-theme-pref="graphite"] body[data-page="admin-user"] .account-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 10px;
}

[data-theme-pref="graphite"] body[data-page="moderator"] .mod-container {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 10px;
}

[data-theme-pref="graphite"] body[data-page="admin-compare"] .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

[data-theme-pref="graphite"] body[data-page="spectate"] .spec-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-theme-pref="graphite"] body[data-page="login"] .auth-shell {
    max-width: 960px;
}

[data-theme-pref="graphite"] body[data-page="login"] .auth-card {
    border-radius: 12px;
    border-color: rgba(142, 168, 214, 0.34);
    background: rgba(11, 16, 26, 0.9);
}

/* Game page shells */
[data-theme-pref="aurora"] body[data-page-group="games"] main,
[data-theme-pref="ember"] body[data-page-group="games"] main,
[data-theme-pref="graphite"] body[data-page-group="games"] main {
    width: min(1400px, 96vw);
}

[data-theme-pref="aurora"] body[data-page-group="games"] main > .section > [class*="-layout"],
[data-theme-pref="aurora"] body[data-page-group="games"] main > .section > [class*="-wrap"],
[data-theme-pref="aurora"] body[data-page-group="games"] main > .section > [class*="-grid"],
[data-theme-pref="ember"] body[data-page-group="games"] main > .section > [class*="-layout"],
[data-theme-pref="ember"] body[data-page-group="games"] main > .section > [class*="-wrap"],
[data-theme-pref="ember"] body[data-page-group="games"] main > .section > [class*="-grid"],
[data-theme-pref="graphite"] body[data-page-group="games"] main > .section > [class*="-layout"],
[data-theme-pref="graphite"] body[data-page-group="games"] main > .section > [class*="-wrap"],
[data-theme-pref="graphite"] body[data-page-group="games"] main > .section > [class*="-grid"] {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: rgba(7, 12, 23, 0.76);
}

[data-theme-pref="aurora"] body[data-page-group="games"] .hero h1,
[data-theme-pref="ember"] body[data-page-group="games"] .hero h1,
[data-theme-pref="graphite"] body[data-page-group="games"] .hero h1 {
    letter-spacing: 0.02em;
}

[data-theme-pref="ember"] body[data-page-group="games"] .hero {
    text-align: center;
}

/* Graphite game-page sidebar: no structural overrides needed */

@media (max-width: 1100px) {
    [data-theme-pref="aurora"] body[data-page="account"] .account-shell,
    [data-theme-pref="aurora"] body[data-page="admin"] .account-shell,
    [data-theme-pref="aurora"] body[data-page="admin-user"] .account-shell,
    [data-theme-pref="aurora"] body[data-page="moderator"] .mod-container,
    [data-theme-pref="graphite"] body[data-page="account"] .account-shell,
    [data-theme-pref="graphite"] body[data-page="admin"] .account-shell,
    [data-theme-pref="graphite"] body[data-page="admin-user"] .account-shell,
    [data-theme-pref="graphite"] body[data-page="moderator"] .mod-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    [data-theme-pref="aurora"] body[data-page="stats"] #statsGrid,
    [data-theme-pref="aurora"] body[data-page="stats"] #recordsGrid,
    [data-theme-pref="ember"] body[data-page="stats"] #statsGrid,
    [data-theme-pref="ember"] body[data-page="stats"] #recordsGrid,
    [data-theme-pref="graphite"] body[data-page="stats"] #statsGrid,
    [data-theme-pref="graphite"] body[data-page="stats"] #recordsGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    [data-theme-pref="aurora"] body[data-page="messages"] .msg-layout,
    [data-theme-pref="ember"] body[data-page="messages"] .msg-layout,
    [data-theme-pref="graphite"] body[data-page="messages"] .msg-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "inbox"
            "conversation";
    }

    [data-theme-pref="aurora"] body[data-page="profile"] .profile-search-section {
        position: static;
    }

    [data-theme-pref="aurora"] body[data-page="spectate"] .spec-list,
    [data-theme-pref="graphite"] body[data-page="spectate"] .spec-list {
        grid-template-columns: 1fr;
    }
}
