@import url('https://fonts.googleapis.com/css2?family=Amatic+SC:wght@400;700&display=swap');

:root {
    --bg-page:    #1a1a1a;
    --bg-section: #202020;
    --bg-card:    #313131;
    --bg-card-hover: #3a3a3a;
    --border:     #444444;
    --border-accent: #9B4646;
    --text-primary:   #FFFFFF;
    --text-secondary: #C8BEB8;
    --text-muted:     #888080;
    --accent-red:  #9B4646;
    --accent-gold: #469B83;
    --accent-purple: #74419B;
    --radius: 0;
}

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

html { scroll-behavior: smooth; font-size: 20px; }

section[id] { scroll-margin-top: 20px; }

/* ── Layout with sidebar ── */
body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Amatic SC', Georgia, serif;
    font-size: 20px;
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    max-width: none;
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }

#sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#sidebar ul ul {
    margin: 0;
    padding: 0;
}

#sidebar ul li {
    margin: 0;
    padding: 0;
}

#sidebar a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    font-family: 'Amatic SC', serif;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    padding: 0.3rem 1.25rem;
    transition: color 0.15s, background 0.15s, padding-left 0.2s;
    line-height: 1.4;
    padding-top: 0;
    padding-bottom: 0;
}

#sidebar a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    padding-left: 1.6rem;
}
#sidebar ul ul a:hover {
    padding-left: 2.35rem;
}
#sidebar ul ul ul a:hover {
    padding-left: 3.85rem;
}

#sidebar a.active {
    color: var(--accent-gold);
    border-left: 2px solid var(--accent-red);
    padding-left: calc(1.25rem - 2px);
}

#sidebar a.nav-top {
    font-size: 1.10rem;
    color: var(--text-white);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
    border-bottom: 0.5px solid var(--border);
    margin: 0 1rem 0.75rem;
    padding: 0;
    padding-left: 5px;
    display: block;
}

#sidebar a.nav-section {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
#sidebar a.nav-section.active {
    color: var(--accent-gold);
}

#sidebar ul ul a {
    padding-left: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0.02em;
}

#sidebar ul ul ul a {
    padding-left: 3.5rem;
}

#sidebar > ul > li {
    margin-bottom: 0.1rem;
}

#main-content {
    margin-left: 280px;
    padding: 40px 48px;
    width: calc(100% - 280px);
    min-width: 480px;
    min-height: 100vh;
}

/* ── Sections ── */
section.section {
    margin-bottom: 3rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
}
section.subsection {
    margin-top: 1.5rem;
}
.grid > section.subsection {
    margin-top: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* ── Typography ── */
h1 {
    font-family: 'Amatic SC', serif;
    font-size: 3.5rem;
    font-weight: 700;
    text-align: left;
    color: var(--text-primary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.4rem;
}
h2 {
    font-family: 'Amatic SC', serif;
    font-size: 1.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-accent);
    padding-bottom: 0.5rem;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}
h3 {
    font-family: 'Amatic SC', serif;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-gold);
    margin-bottom: 0.75rem;
}
h4 {
    font-family: 'Amatic SC', serif;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    margin-top: 0.75rem;
}
a { color: var(--accent-gold); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s; }
a:hover { border-bottom-color: var(--accent-gold); }

p { margin-bottom: 0.75rem; color: var(--text-primary); }
em { color: var(--text-primary); font-style: italic; }
blockquote em, .intro-quote em { color: var(--text-secondary); }
strong { color: var(--text-primary); font-weight: 600; }

/* ── Lists ── */
ul, ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
    color: var(--text-primary);
}
li { margin-bottom: 0.3rem; }
ul.list-disc { list-style-type: disc; }
ol.list-decimal { list-style-type: decimal; }

/* ── Blockquotes ── */
blockquote {
    border-left: 3px solid var(--border-accent);
    padding: 0.6rem 1rem;
    margin: 0.75rem 0;
    background: rgba(139,26,26,0.06);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
    font-style: italic;
}
blockquote p { color: var(--text-secondary); margin-bottom: 0.4rem; }
blockquote p:last-child { margin-bottom: 0; }
blockquote b { color: var(--text-secondary); font-style: normal; }

/* ── Tables ── */
.table-outer {
    position: relative;
    margin: 1rem 0;
}
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-fade {
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 100%;
    background: linear-gradient(to right, transparent, var(--bg-card));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
    z-index: 1;
}
.scroll-hint {
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-family: 'Amatic SC', serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.5s;
}
table {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 0;
}
th {
    background: var(--bg-section);
    color: var(--accent-gold);
    font-family: 'Amatic SC', serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-accent);
}
td {
    padding: 0.55rem 0.8rem;
    border-bottom: 0.5px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.text-center { text-align: center; }

/* ── Images ── */
img {
    display: block;
    height: auto;
    border-radius: var(--radius);
    max-width: 100%;
}

.img-board {
    width: 100%;
    margin: 0 0 1rem;
    border: 0.5px solid var(--border);
}

.img-token {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 0;
    margin: 0 auto;
}

.img-card {
    width: 100%;
    max-width: 160px;
    margin-bottom: 0.5rem;
}

.img-component {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* ── Grid helpers ── */
.grid { display: grid; gap: 1rem; }
.gap-4 { gap: 1rem; }

/* Cards within grids */
.grid > div {
    background: var(--bg-section) !important;
    border: 0.5px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 1rem !important;
    transition: border-color 0.2s !important;
}
.grid > div:hover { border-color: var(--border-accent); }
.grid > div p {
    font-size: 1.0rem;
    color: var(--text-muted);
    text-align: center;
}

/* Token grid — no card styling */
.grid.token-grid > div {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Faction card grid */
/* Role card grid */
.grid.faction-grid > div,
.grid.role-grid > div,
.grid.power-grid > div,
.grid.quirk-grid > div,
.grid.judgement-grid > div,
.grid.god-example-grid > div { 
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center; 
    align-items: center;
    justify-content: flex-start;
}

/* Component card grid */
.grid.component-grid > div {
    padding: 0.5rem;
    text-align: center;
}

/* ── Intro block ── */
.intro-quote {
    font-size: 1.05rem;
    font-style: italic;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-red);
    padding: 0.75rem 1.25rem;
    margin: 1.25rem 0;
    background: rgba(139,26,26,0.06);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.intro-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}
.intro-meta strong { color: var(--text-primary); }

/* ── Badge-style tags ── */
.tag {
    display: inline-block;
    font-family: 'Amatic SC', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.15rem 0.5rem;
    border-radius: 0;
    margin-left: 0.4rem;
    vertical-align: middle;
}
.tag-wrath  { background: rgba(192,25,26,0.15); color: #e06060; border: 0.5px solid rgba(192,25,26,0.4); }
.tag-favour { background: rgba(196,154,42,0.15); color: #d4a93a; border: 0.5px solid rgba(196,154,42,0.4); }
.tag-omen   { background: rgba(107,63,160,0.15); color: #a070d0; border: 0.5px solid rgba(107,63,160,0.4); }
.tag-silence{ background: rgba(120,110,96,0.15); color: #a09080; border: 0.5px solid rgba(120,110,96,0.4); }

/* ── Section header accent line ── */
section.section > h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--accent-red);
    margin-right: 0.6rem;
    vertical-align: middle;
    border-radius: 0;
}

/* ── Scroll to top button ── */
#scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
#scroll-top:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-gold);
}

/* ── Mobile hamburger button ── */
#nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 300;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px;
}
#nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 0;
    transition: all 0.2s;
}
#nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav-toggle.open span:nth-child(2) { opacity: 0; }
#nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Overlay ── */
#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.2s;
}
#nav-overlay.visible { opacity: 1; }

/* ── Lightbox ── */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox-img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.8);
    cursor: default;
}

/* ── Print ── */
@media print {
    body { background: #fff; color: #000; padding: 20px; }
    h2 { page-break-before: always; }
    h2:first-of-type { page-break-before: avoid; }
    img { page-break-inside: avoid; }
    section.subsection { border: 1px solid #ccc; }
    #nav-toggle, #nav-overlay { display: none !important; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    #nav-toggle { display: flex; }
    #nav-overlay { display: block; pointer-events: none; }
    #nav-overlay.visible { pointer-events: auto; }

    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
    }
    #sidebar.open { transform: translateX(0); }

    #main-content { margin-left: 0; width: 100%; min-width: 0; padding: 60px 16px 20px; }


    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.3rem; }
}
.card-sway {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-muted);
    letter-spacing: 0.03em;
}

.card-num {
    font-size: 1.0em;
    font-weight: 400;
    color: var(--color-muted);
    letter-spacing: 0.05em;
    vertical-align: middle;
}
.card-num::before {
    content: "(";
}

.card-num::after {
    content: ")";
}

/* Sway matrix table */
.sway-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}
.sway-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
}
.sway-legend .sway-t { background: rgba(74, 160, 120, 0.45); color: #fff; }
.sway-legend .sway-c { background: rgba(190, 90, 80, 0.5); color: #fff; }
.sway-legend .sway-n { background: rgba(255, 255, 255, 0.12); color: #fff; }

.sway-matrix {
    font-size: 0.75rem;
    border-collapse: collapse;
}
.sway-matrix th, .sway-matrix td {
    padding: 0.3rem 0.45rem;
    text-align: center !important;
    border: 1px solid var(--color-border);
    min-width: 2.8rem;
}
.sway-matrix thead th { font-weight: 700; background: var(--bg-section); }
.sway-matrix tbody th { font-weight: 700; background: var(--bg-section); text-align: left; padding-right: 0.6rem; position: sticky; left: 0; z-index: 1; }
.sway-matrix td { color: var(--color-muted); }

.sway-matrix td:empty { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); }
.sway-matrix td:empty::after { content: "Neutral"; font-weight: 400; }
.sway-matrix .sway-t, .sway-matrix .sway-c, .sway-matrix .sway-n { color: #fff; }
.sway-matrix .sway-t.sway-mod { background: rgba(74, 160, 120, 0.45); }
.sway-matrix .sway-t.sway-mil { background: rgba(74, 160, 120, 0.25); }
.sway-matrix .sway-c.sway-mod { background: rgba(190, 90, 80, 0.5); }
.sway-matrix .sway-c.sway-mil { background: rgba(190, 90, 80, 0.28); }
.sway-matrix .sway-n.sway-mod { background: rgba(255, 255, 255, 0.18); }
.sway-matrix .sway-n.sway-mil { background: rgba(255, 255, 255, 0.1); }
.sway-matrix .sway-mod { font-weight: 600; }
.sway-matrix .sway-mil { font-weight: 400; }
