/* ==========================================================================
   The People's RP — theme tokens
   Dark is the default. [data-theme="light"] is applied by the early script
   in header.php (stored choice, else OS preference, else dark).
   ========================================================================== */

:root {
    color-scheme: dark;

    --bg: #121316;
    --bg-raised: #1a1b1f;
    --bg-inset: #0d0e10;
    --navbar-bg: rgba(16, 17, 20, 0.9);

    --text: #ebe8e3;
    --text-muted: #9a9a94;

    --border: rgba(255, 255, 255, 0.09);
    --stamp-line: rgba(235, 232, 227, 0.26);

    --accent: #d5483f;
    --accent-strong: #a5322b;
    --gold: #e4b23e;

    --shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
    --toggler-filter: invert(1);

    --font-body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Barlow Condensed", "Rubik", system-ui, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
    color-scheme: light;

    --bg: #e8e6e2;
    --bg-raised: #f3f2ef;
    --bg-inset: #dcd9d3;
    --navbar-bg: rgba(232, 230, 226, 0.9);

    --text: #1b1a18;
    --text-muted: #5d5952;

    --border: rgba(20, 18, 16, 0.16);
    --stamp-line: rgba(27, 26, 24, 0.22);

    --accent: #bf3a30;
    --accent-strong: #9a2f27;
    --gold: #9c6b1c;

    --shadow: 0 16px 40px rgba(45, 40, 34, 0.14);
    --toggler-filter: none;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
}

a {
    color: inherit;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

h1,
h2,
h3,
.navbar-brand strong,
.state-stamp strong,
.topic-label {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Navbar
   -------------------------------------------------------------------------- */

.site-navbar {
    background: var(--navbar-bg);
    border-top: 3px solid var(--accent);
    border-bottom: 1px solid var(--border);
    min-height: 70px;
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(14px);
}

.nav-shell {
    position: relative;
}

.navbar-brand {
    align-items: center;
    border-right: 1px solid var(--border);
    gap: 0.7rem;
    margin-right: 1.4rem;
    padding-right: 1.4rem;
    text-decoration: none;
}

.navbar-brand span {
    display: flex;
    flex-direction: column;
}

.brand-logo {
    border-radius: 50%;
    object-fit: contain;
}

.mobile-community-mark .brand-logo {
    border: 1px solid var(--border);
}

.navbar-brand strong {
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1;
}

.navbar-brand small {
    color: var(--text-muted);
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    margin-top: 0.28rem;
    text-transform: uppercase;
}

.navbar-nav {
    gap: 0.2rem;
}

.navbar-nav .nav-link {
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.7rem 0.85rem;
    position: relative;
    text-transform: uppercase;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: var(--text);
}

.navbar-nav .nav-link.active::after {
    background: var(--accent);
    bottom: 0.35rem;
    content: "";
    height: 2px;
    left: 0.85rem;
    position: absolute;
    right: 0.85rem;
}

.theme-toggle {
    align-items: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 1.02rem;
    height: 40px;
    justify-content: center;
    margin-left: auto;
    transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
    width: 40px;
}

.theme-toggle:hover {
    border-color: var(--text-muted);
    color: var(--text);
    transform: translateY(-2px);
}

.theme-toggle .bi-sun-fill {
    display: none;
}

:root[data-theme="light"] .theme-toggle .bi-sun-fill {
    display: inline-block;
}

:root[data-theme="light"] .theme-toggle .bi-moon-stars-fill {
    display: none;
}

.discord-link {
    align-items: center;
    background: #5865f2;
    border-radius: 50%;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 1.2rem;
    height: 40px;
    justify-content: center;
    margin-left: 0.6rem;
    text-decoration: none;
    transition: transform 160ms ease, background 160ms ease;
    width: 40px;
}

.discord-link:hover {
    background: #7580f5;
    color: #fff;
    transform: translateY(-2px);
}

.navbar-toggler {
    filter: var(--toggler-filter);
    padding-left: 0;
}

/* --------------------------------------------------------------------------
   Shared bits
   -------------------------------------------------------------------------- */

.eyebrow {
    align-items: center;
    color: var(--text-muted);
    display: flex;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 500;
    gap: 0.55rem;
    letter-spacing: 0.14em;
    margin-bottom: 1.1rem;
    text-transform: uppercase;
}

.eyebrow span {
    color: var(--accent);
    font-size: 0.85rem;
    line-height: 1;
}

.eyebrow span::before {
    content: "\2605"; /* ★ */
}

.btn-primary-civic,
.btn-outline-civic {
    border-radius: 0;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.8rem 1.2rem;
    text-transform: uppercase;
}

.btn-primary-civic {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #fff;
}

.btn-primary-civic:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
}

.btn-outline-civic {
    border: 1px solid var(--text-muted);
    color: var(--text);
}

.btn-outline-civic:hover {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

.section-pad {
    padding: 5rem 0;
}

.section-heading {
    margin-bottom: 2.5rem;
}

.section-heading h2,
.power-section h2,
.manifesto-panel h2 {
    font-size: clamp(1.7rem, 3vw, 2.5rem);
    line-height: 1.05;
}

.section-heading em {
    color: var(--accent);
    font-style: normal;
}

/* --------------------------------------------------------------------------
   Home — hero
   -------------------------------------------------------------------------- */

.hero-section {
    align-items: center;
    background: radial-gradient(circle at 82% 45%, rgba(213, 72, 63, 0.12), transparent 40%), var(--bg);
    display: flex;
    min-height: 56vh;
    overflow: hidden;
    padding: 4.5rem 0;
    position: relative;
}

.hero-section::after {
    background: var(--accent);
    bottom: -22%;
    content: "";
    height: 60%;
    opacity: 0.05;
    position: absolute;
    right: -9%;
    transform: rotate(-18deg);
    width: 24%;
}

.hero-grid {
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 56px 56px;
    inset: 0;
    mask-image: linear-gradient(to bottom, black, transparent 88%);
    opacity: 0.25;
    position: absolute;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-section h1 {
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    line-height: 1.02;
    margin: 0;
    max-width: 720px;
}

.hero-lead {
    color: var(--text-muted);
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.7;
    margin: 1.75rem 0 0;
    max-width: 680px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.9rem;
}

.state-stamp {
    aspect-ratio: 1;
    border: 2px solid var(--stamp-line);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: auto;
    max-width: 270px;
    padding: 2.5rem;
    position: relative;
    transform: rotate(2deg);
}

.state-stamp::before,
.state-stamp::after {
    border: 1px dashed var(--stamp-line);
    border-radius: 50%;
    content: "";
    inset: 0.6rem;
    position: absolute;
}

.state-stamp::after {
    border-color: var(--accent);
    border-style: solid;
    inset: 1.05rem;
}

.state-stamp span,
.state-stamp small {
    color: var(--text-muted);
    font-family: var(--font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.state-stamp strong {
    font-size: 2rem;
    line-height: 0.9;
    margin: 0.9rem 0;
}

.state-stamp small {
    font-size: 0.6rem;
}

/* --------------------------------------------------------------------------
   Home — principles
   -------------------------------------------------------------------------- */

.principles-section {
    background: var(--bg-inset);
    color: var(--text);
}

.principle-card {
    border-left: 2px solid var(--accent);
    padding: 0.5rem 1.5rem 0.5rem 1.5rem;
}

.card-number {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
}

.principle-card h3 {
    font-size: 1.3rem;
    margin: 1.75rem 0 0.75rem;
}

.principle-card p,
.section-copy,
.manifesto-copy > p:last-child {
    color: var(--text-muted);
    line-height: 1.8;
}

/* --------------------------------------------------------------------------
   Home — power flow
   -------------------------------------------------------------------------- */

.power-section {
    background: var(--bg-raised);
}

.section-copy {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 1.25rem;
}

.power-flow {
    border-top: 1px solid var(--border);
}

.power-step {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 52px 1fr;
    padding: 1.35rem 0;
}

.power-step > span {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
}

.power-step h3 {
    font-size: 1.2rem;
    margin-bottom: 0.35rem;
}

.power-step p {
    color: var(--text-muted);
    line-height: 1.65;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Home — manifesto (stays red in both themes)
   -------------------------------------------------------------------------- */

.manifesto-section {
    background: var(--accent-strong);
    color: #fdf3f1;
}

.manifesto-panel {
    display: grid;
    gap: 4rem;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.manifesto-panel .eyebrow,
.manifesto-panel .manifesto-copy > p:last-child {
    color: rgba(255, 255, 255, 0.75);
}

.manifesto-panel .eyebrow span {
    color: #fff;
}

.manifesto-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.manifesto-list li {
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.24);
    display: flex;
    gap: 0.8rem;
    line-height: 1.5;
    padding: 1rem 0;
}

.manifesto-list i {
    color: #fff;
}

/* --------------------------------------------------------------------------
   Interior page heroes
   -------------------------------------------------------------------------- */

.page-hero {
    background: radial-gradient(circle at 85% 30%, rgba(213, 72, 63, 0.14), transparent 38%), var(--bg);
    border-bottom: 1px solid var(--border);
}

.compact-hero {
    padding: 4.5rem 0 3.5rem;
}

.compact-hero h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.05;
    max-width: 820px;
}

.compact-hero > .container-xxl > p:last-child {
    color: var(--text-muted);
    line-height: 1.7;
    margin: 1.25rem 0 0;
    max-width: 720px;
}

/* --------------------------------------------------------------------------
   Rules
   -------------------------------------------------------------------------- */

.rules-layout {
    background: var(--bg-inset);
    color: var(--text);
}

.rule-topics {
    position: sticky;
    top: 100px;
}

.topic-label {
    color: var(--text-muted);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    margin-bottom: 0.8rem;
}

.rule-topic {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 600;
    gap: 0.75rem;
    padding: 0.85rem 0.3rem;
    text-align: left;
    text-transform: uppercase;
    transition: color 150ms ease, padding 150ms ease;
    width: 100%;
}

.rule-topic span {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.rule-topic:hover,
.rule-topic.active {
    color: var(--text);
    padding-left: 0.75rem;
}

.rule-category {
    margin-bottom: 4rem;
    scroll-margin-top: 100px;
}

.rule-category:last-child {
    margin-bottom: 0;
}

.rule-category-heading {
    align-items: flex-start;
    display: grid;
    gap: 1rem;
    grid-template-columns: 42px 1fr;
    margin-bottom: 1.5rem;
}

.rule-category-heading > span {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
    padding-top: 0.4rem;
}

.rule-category-heading h2 {
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
}

.rule-category-heading p {
    color: var(--text-muted);
    margin: 0;
}

.civic-accordion {
    border-top: 2px solid var(--text);
}

.civic-accordion .accordion-item {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.civic-accordion .accordion-button,
.civic-accordion .accordion-button:not(.collapsed) {
    background: transparent;
    box-shadow: none;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    gap: 1rem;
    padding: 1.1rem 0;
    text-transform: uppercase;
}

.civic-accordion .accordion-button:not(.collapsed) {
    color: var(--accent);
}

.rule-index {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.civic-accordion .accordion-body {
    color: var(--text-muted);
    line-height: 1.75;
    max-width: 800px;
    padding: 0 3rem 1.4rem;
}

/* --------------------------------------------------------------------------
   Departments
   -------------------------------------------------------------------------- */

.departments-list {
    background: var(--bg);
}

.department-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 230px 1fr;
    margin-bottom: 1.75rem;
    overflow: hidden;
    position: relative;
}

.department-card::before {
    background: var(--department-accent);
    content: "";
    height: 4px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.department-mark {
    align-items: center;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent), #16171a;
    border-right: 1px solid var(--border);
    display: flex;
    justify-content: center;
    min-height: 300px;
    padding: 2rem;
}

.department-mark img {
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.45));
    height: auto;
    max-width: 158px;
    width: 100%;
}

.department-mark span {
    align-items: center;
    aspect-ratio: 1;
    border: 2px solid var(--department-accent);
    border-radius: 50%;
    color: var(--department-accent);
    display: flex;
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 800;
    justify-content: center;
    letter-spacing: 0.05em;
    position: relative;
    width: 132px;
}

.department-mark span::after {
    border: 1px dashed var(--department-accent);
    border-radius: 50%;
    content: "";
    inset: 8px;
    opacity: 0.6;
    position: absolute;
}

.department-content {
    padding: 2.5rem;
}

.department-title-block p {
    color: var(--department-accent);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

:root[data-theme="light"] .department-title-block p {
    color: color-mix(in srgb, var(--department-accent) 52%, #2a2622);
}

.department-title-block h2 {
    color: var(--text);
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    line-height: 1;
}

.department-description {
    color: var(--text-muted);
    line-height: 1.75;
    margin: 1.25rem 0 1.75rem;
    max-width: 930px;
}

.department-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.department-actions a {
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.7rem 0.95rem;
    text-decoration: none;
    text-transform: uppercase;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.department-actions a:hover {
    background: var(--department-accent);
    border-color: var(--department-accent);
    color: #16171a;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
    background: var(--bg-inset);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
}

.footer-inner {
    align-items: center;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
}

.footer-inner > div {
    align-items: center;
    display: flex;
    font-family: var(--font-display);
    font-weight: 700;
    gap: 0.6rem;
    text-transform: uppercase;
}

.footer-inner > div::before {
    color: var(--accent);
    content: "\2605"; /* ★ */
}

.footer-inner p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0;
}

.footer-inner a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-inner a:hover {
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .site-navbar {
        min-height: 62px;
    }

    .nav-shell {
        justify-content: space-between;
    }

    .navbar-collapse {
        background: var(--bg-raised);
        border: 1px solid var(--border);
        left: 0.75rem;
        padding: 0.75rem;
        position: absolute;
        right: 0.75rem;
        top: calc(100% + 0.35rem);
    }

    .navbar-nav .nav-link {
        padding: 0.85rem 0.75rem;
    }

    .navbar-nav .nav-link.active::after {
        bottom: 0.5rem;
        left: 0.75rem;
        right: auto;
        width: 30px;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .mobile-community-mark {
        align-items: center;
        border-top: 1px solid var(--border);
        color: var(--text-muted);
        display: flex;
        font-family: var(--font-display);
        font-weight: 700;
        gap: 0.65rem;
        margin-top: 0.5rem;
        padding: 1rem 0.75rem 0.35rem;
        text-transform: uppercase;
    }

    .hero-section {
        min-height: auto;
        padding: 4rem 0;
    }

    .state-stamp {
        margin: 1rem auto 0 0;
    }

    .manifesto-panel {
        gap: 2.5rem;
        grid-template-columns: 1fr;
    }

    .rule-topics {
        background: var(--bg-inset);
        position: static;
    }

    .rule-topics nav {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .rule-topic {
        border: 1px solid var(--border);
        flex: 0 0 auto;
        padding: 0.7rem 0.9rem;
        width: auto;
    }

    .rule-topic:hover,
    .rule-topic.active {
        background: var(--text);
        color: var(--bg);
        padding-left: 0.9rem;
    }

    .department-card {
        grid-template-columns: 170px 1fr;
    }

    .department-mark {
        min-height: 100%;
        padding: 1.5rem;
    }

    .department-mark img {
        max-width: 120px;
    }

    .department-mark span {
        font-size: 1.5rem;
        width: 110px;
    }
}

@media (max-width: 767.98px) {
    .section-pad {
        padding: 4rem 0;
    }

    .hero-section h1 {
        font-size: clamp(2rem, 9vw, 2.8rem);
    }

    .state-stamp {
        max-width: 240px;
        padding: 2.2rem;
    }

    .state-stamp strong {
        font-size: 1.8rem;
    }

    .compact-hero {
        padding: 3.5rem 0 2.75rem;
    }

    .compact-hero h1 {
        font-size: clamp(1.9rem, 8vw, 2.6rem);
    }

    .department-card {
        grid-template-columns: 1fr;
    }

    .department-mark {
        border-bottom: 1px solid var(--border);
        border-right: 0;
        min-height: 200px;
    }

    .department-content {
        padding: 2rem 1.4rem;
    }

    .department-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .department-actions a {
        text-align: center;
    }

    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
