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

:root {
    --bg-primary: #1a1a2e;
    --bg-card: rgba(16, 16, 32, 0.85);
    --text-primary: #e0d5c1;
    --text-heading: #f0e6d2;
    --text-muted: #8a8070;
    --accent: #c9a84c;
    --accent-dim: #8a7030;
    --border: rgba(201, 168, 76, 0.2);
    --shadow: rgba(0, 0, 0, 0.5);

    /* State-driven colors — these change via JS based on kingdom state */
    --state-prosperity: #c9a84c;
    --state-corruption: #c9a84c;
    --state-morale: #c9a84c;
    --state-battle: #c9a84c;
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
    /* Background image placeholder — swap based on state later */
    background-image: url('bg-default.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-image 1s ease-in-out;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        rgba(10, 10, 20, 0.7) 0%,
        rgba(10, 10, 20, 0.5) 50%,
        rgba(10, 10, 20, 0.8) 100%
    );
    z-index: 0;
    pointer-events: none;
    transition: background 1s ease-in-out;
}

/* ─── State-driven background tints ──────────────────────────────────────── */
/* These classes are toggled by JS. Later, swap background-image per state. */

body[data-prosperity="thriving"] { --bg-primary: #1a2e1a; }
body[data-prosperity="prosperous"] { --bg-primary: #1e2e1a; }
body[data-prosperity="stable"] { --bg-primary: #1a1a2e; }
body[data-prosperity="struggling"] { --bg-primary: #2e1a1a; }
body[data-prosperity="desolate"] { --bg-primary: #1a0a0a; }

body[data-corruption="lawless"] .overlay {
    background: linear-gradient(180deg, rgba(30, 10, 30, 0.8) 0%, rgba(20, 5, 20, 0.6) 50%, rgba(30, 10, 30, 0.9) 100%);
}
body[data-corruption="corrupt"] .overlay {
    background: linear-gradient(180deg, rgba(25, 10, 25, 0.7) 0%, rgba(15, 5, 15, 0.5) 50%, rgba(25, 10, 25, 0.8) 100%);
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */

header, main, footer {
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    padding: 60px 20px 40px;
}

.title {
    font-size: 2.8em;
    color: var(--text-heading);
    letter-spacing: 0.08em;
    text-shadow: 2px 2px 8px var(--shadow);
    font-variant: small-caps;
}

.subtitle {
    font-size: 1.1em;
    color: var(--accent);
    margin-top: 8px;
    font-style: italic;
    letter-spacing: 0.15em;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.85em;
}

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

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 30px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
}

.card h2 {
    font-size: 1.3em;
    color: var(--accent);
    margin-bottom: 16px;
    font-variant: small-caps;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

/* ─── Herald ──────────────────────────────────────────────────────────────── */

.herald-card .loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.herald-headline {
    font-size: 1.6em;
    color: var(--text-heading);
    margin-bottom: 12px;
    line-height: 1.3;
}

.herald-summary {
    font-size: 1.05em;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.herald-day {
    font-size: 0.85em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 16px;
}

/* ─── State Grid ──────────────────────────────────────────────────────────── */

.state-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.state-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
}

.state-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 4px;
}

.state-value {
    font-size: 1.2em;
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

/* Tier colors */
.tier-thriving, .tier-jubilant, .tier-victory { color: #6abf69; }
.tier-prosperous, .tier-hopeful, .tier-pyrrhic { color: #a8c76a; }
.tier-stable, .tier-clean { color: #c9a84c; }
.tier-struggling, .tier-uneasy, .tier-suspect, .tier-defeat { color: #c97a4c; }
.tier-desolate, .tier-fearful, .tier-despairing, .tier-shady, .tier-corrupt, .tier-lawless, .tier-routed { color: #c94c4c; }

/* ─── Events ──────────────────────────────────────────────────────────────── */

.event-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.event-item:last-child {
    border-bottom: none;
}

.event-category {
    font-size: 0.75em;
    color: var(--accent-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 4px;
}

.event-description {
    font-size: 0.95em;
}

/* ─── History ─────────────────────────────────────────────────────────────── */

.history-entry {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.history-entry:last-child {
    border-bottom: none;
}

.history-day {
    font-size: 0.75em;
    color: var(--accent-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.history-headline {
    font-size: 1.1em;
    color: var(--text-heading);
    margin: 4px 0;
}

.history-summary {
    font-size: 0.9em;
    color: var(--text-muted);
}

/* ─── About ───────────────────────────────────────────────────────────────── */

.about-card p {
    margin-bottom: 12px;
}

.rss-link a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-dim);
}

.rss-link a:hover {
    color: var(--text-heading);
}

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

@media (max-width: 600px) {
    .title { font-size: 2em; }
    .state-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .card { padding: 20px; }
    header { padding: 40px 20px 20px; }
}
