:root {
    --gold: #c8a46a;
    --gold-light: #e0c891;
    --bg: #0a1018;
    --panel: rgba(12, 18, 26, .78);
    --font-serif: Georgia, "Times New Roman", serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Always reserve the scrollbar gutter so page width stays constant
   between short pages and tall (scrolling) pages like Lore.
   The dark background-color keeps the canvas from flashing white when
   the fixed body background lags behind a fast scroll on mobile. */
html {
    scrollbar-gutter: stable;
    background-color: var(--bg);
}

body {
    min-height: 100vh;
    color: #d9c19a;
    background:
        linear-gradient(#071019, #1c4368),
        url("../assets/images/hero-background.webp");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-color: var(--bg);
    font-family: var(--font-serif);
    /* Establishes a stacking context so body's own background sits below
       body::before's cross-hatch texture instead of painting over it. */
    isolation: isolate;
}

/* Fixed diamond cross-hatch texture, layered behind all content */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            30deg,
            rgba(200, 164, 106, .06) 0,
            rgba(200, 164, 106, .06) 1px,
            transparent 1px,
            transparent 28px
        ),
        repeating-linear-gradient(
            150deg,
            rgba(200, 164, 106, .06) 0,
            rgba(200, 164, 106, .06) 1px,
            transparent 1px,
            transparent 28px
        );
}

.background-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(
            circle at center,
            transparent 20%,
            rgba(0, 0, 0, .45) 100%
        );
    pointer-events: none;
}

/* ── Back to top ──────────────────────────────── */
/* Shared across Rules and Lore — the left offset assumes a centered
   content column with a max-width of 1100px. */

.back-to-top {
    position: fixed;
    left: max(20px, calc(50% - 610px));
    bottom: 30px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(200, 164, 106, .5);
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
    color: var(--gold);
    cursor: pointer;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity .3s ease, transform .3s ease, visibility .3s ease,
                background .25s ease, box-shadow .25s ease, color .25s ease;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    color: var(--gold-light);
    background: rgba(200, 164, 106, .18);
    box-shadow: 0 0 16px rgba(200, 164, 106, .3);
}

.back-to-top svg {
    width: 22px;
    height: 22px;
}

/* Shared panel chrome, reused by .lore-entry, .rule-section, .sidebar,
   and .main-panel in the page-specific stylesheets */
.lore-entry,
.rule-section,
.sidebar,
.main-panel {
    background: var(--panel);
    border: 1px solid rgba(200, 164, 106, .35);
    backdrop-filter: blur(8px);
}

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

/* TODO: .nav-frame and .nav-ornament are in the HTML but have no styles */

.top-nav {
    width: 100%;
    padding: 30px 60px;
}

.top-nav nav {
    display: flex;
    border: 1px solid rgba(200, 164, 106, .5);
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
}

.top-nav a {
    flex: 1;
    text-align: center;
    padding: 18px 8px;
    border-right: 1px solid rgba(200, 164, 106, .4);
    text-decoration: none;
    color: var(--gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: .85rem;
    transition: .25s;
    position: relative;
}

.top-nav a:last-child {
    border-right: none;
}

.top-nav a:hover {
    color: var(--gold-light);
    text-shadow: 0 0 10px rgba(224, 200, 145, .5);
}

.top-nav a.active {
    color: var(--gold-light);
    background: rgba(200, 164, 106, .12);
    text-shadow: 0 0 10px rgba(224, 200, 145, .4);
}

.top-nav a.active::before {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -10px;
    height: 2px;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(200, 164, 106, .65);
}

.top-nav a.active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -16px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--gold);
    filter: drop-shadow(0 0 4px rgba(200, 164, 106, .6));
}

/* Hamburger toggle — hidden on desktop, shown at the mobile breakpoint */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 46px;
    height: 46px;
    padding: 11px;
    background: rgba(0, 0, 0, .35);
    border: 1px solid rgba(200, 164, 106, .5);
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--gold);
    border-radius: 1px;
    transition: transform .25s, opacity .25s;
}

/* ── Hero ─────────────────────────────────────── */

.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 0 8%;
    text-align: center;
    overflow-x: clip;
}

.hero-content {
    max-width: 920px;
}

.presents {
    display: block;
    color: #a89070;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: clamp(1.05rem, 4.5vw, 2.5rem);
    margin-bottom: 18px;
}

.presents .tm {
    font-size: .42em;
    vertical-align: super;
    letter-spacing: 0;
}

.eyebrow {
    display: block;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: clamp(2rem, 7vw, 5rem);
    margin: clamp(12px, 3vw, 24px) 0;
}

.hero-title {
    position: relative;
    display: inline-block;
}

.hero-logo {
    display: block;
    width: min(680px, 88vw);
    height: auto;
}

/* Secret link tucked behind the centre of the logo.
   Default cursor so hovering gives no hint that it's clickable. */
.secret-u {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.7em;
    height: 0.9em;
    z-index: 2;
    cursor: default;
}

.hero p {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #d5d5d5;
    margin-bottom: 40px;
}

.btn-primary,
.btn-secondary {
    padding: 14px 32px;
    border: 1px solid var(--gold);
    color: white;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
    transition: .25s;
}

.btn-primary {
    background: rgba(200, 164, 106, .15);
}

.btn-secondary {
    background: rgba(0, 0, 0, .35);
}

.btn-primary:hover,
.btn-secondary:hover {
    background: rgba(200, 164, 106, .25);
    box-shadow: 0 0 20px rgba(200, 164, 106, .25);
}

/* ── Cards ────────────────────────────────────── */

.cards,
.rule-hub {
    width: min(1400px, 90%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
}

.cards {
    margin: auto;
}

.card {
    position: relative;
    background: var(--panel);
    border: 1px solid rgba(200, 164, 106, .45);
    backdrop-filter: blur(8px);
    padding: 30px;
    transition: .3s;
    text-align: center;
    overflow: hidden;
}

/* Cards that are links inherit the panel styling without link decoration */
a.card {
    text-decoration: none;
    color: inherit;
}

/* Merged from two duplicate .card:hover declarations */
.card:hover {
    transform: translateY(-6px);
    border-color: var(--gold);
    box-shadow:
        0 0 30px rgba(200, 164, 106, .15),
        inset 0 0 20px rgba(200, 164, 106, .05);
}

.card-icon {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 25px auto;
}

.card-icon::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 30px;
    height: 30px;
    border-top: 1px solid var(--gold);
    border-left: 1px solid var(--gold);
    transform: translateX(-50%) rotate(45deg);
    opacity: .6;
}

.card:hover .card-icon {
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px rgba(200, 164, 106, .45));
}

.card::before,
.card::after,
.lore-entry::before,
.lore-entry::after {
    content: "";
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
}

.card::before,
.lore-entry::before {
    top: 10px;
    left: 10px;
    border-top: 2px solid var(--gold);
    border-left: 2px solid var(--gold);
}

.card::after,
.lore-entry::after {
    bottom: 10px;
    right: 10px;
    border-bottom: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
}

.card h3 {
    position: relative;
    margin-bottom: 20px;
    color: var(--gold-light);
}

.card h3::before,
.card h3::after {
    content: "◆";
    position: absolute;
    color: var(--gold);
    font-size: .7rem;
    top: 50%;
    transform: translateY(-50%);
}

.card h3::before { left: -18px; }
.card h3::after  { right: -18px; }

.card p {
    color: #cfcfcf;
    line-height: 1.6;
}

/* ── Feature Grid (unused — no matching HTML yet) ─ */

.feature-grid {
    width: min(1400px, 90%);
    margin: 50px auto 100px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.feature-box {
    text-align: center;
    padding: 35px;
    background: var(--panel);
    border: 1px solid rgba(200, 164, 106, .35);
    backdrop-filter: blur(8px);
}

.feature-box h4 {
    color: var(--gold);
    letter-spacing: 2px;
}

/* ── Particles ────────────────────────────────── */

.particles {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.particles span {
    position: absolute;
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(224, 200, 145, .8);
    box-shadow: 0 0 8px rgba(224, 200, 145, .8);
    animation: floatParticle 15s linear infinite;
    animation-fill-mode: backwards;
}

.particles span:nth-child(1) { left: 10%; animation-delay: 0s; }
.particles span:nth-child(2) { left: 20%; animation-delay: 2s; }
.particles span:nth-child(3) { left: 35%; animation-delay: 4s; }
.particles span:nth-child(4) { left: 50%; animation-delay: 6s; }
.particles span:nth-child(5) { left: 65%; animation-delay: 1s; }
.particles span:nth-child(6) { left: 75%; animation-delay: 3s; }
.particles span:nth-child(7) { left: 85%; animation-delay: 5s; }
.particles span:nth-child(8) { left: 95%; animation-delay: 7s; }

@keyframes floatParticle {
    0%   { transform: translateY(100vh) translateX(0);   opacity: 0; }
    10%  { opacity: .7; }
    50%  { transform: translateY(50vh)  translateX(20px); }
    100% { transform: translateY(-20vh) translateX(-20px); opacity: 0; }
}

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

@media (max-width: 1200px) {
    .cards,
    .feature-grid,
    .rule-hub {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 16px;
    }

    .nav-frame {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .nav-ornament {
        display: none;
    }

    .nav-toggle {
        display: flex;
        margin-left: auto;
    }

    /* Animate the bars into an X when open */
    .top-nav.open .nav-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .top-nav.open .nav-toggle span:nth-child(2) {
        opacity: 0;
    }

    .top-nav.open .nav-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* The link list collapses into a dropdown below the bar */
    .top-nav nav {
        display: none;
        order: 3;
        flex-basis: 100%;
        flex-direction: column;
        margin-top: 12px;
    }

    .top-nav.open nav {
        display: flex;
    }

    .top-nav a {
        flex: none;
        text-align: left;
        border-right: none;
        border-bottom: 1px solid rgba(200, 164, 106, .25);
        padding: 14px 18px;
    }

    .top-nav a:last-child {
        border-bottom: none;
    }

    .top-nav a.active::before,
    .top-nav a.active::after {
        display: none;
    }

    .cards,
    .feature-grid,
    .rule-hub {
        grid-template-columns: 1fr;
    }

    .back-to-top {
        left: 16px;
        bottom: 16px;
        width: 42px;
        height: 42px;
    }
}