/* VsD SRD Wiki
   Built from character-sheet.html foundations:
   Spellcaster (local), Playfair Display (Google), light-grey body,
   black header bar, #b8860b gold accent. */

/* ── Fonts (copied verbatim from character-sheet.html) ───────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

@font-face {
    font-family: 'Spellcaster';
    src: url('fonts/CC Spellcaster/CCSpellcaster Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Spellcaster';
    src: url('fonts/CC Spellcaster/CCSpellcaster Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Spellcaster';
    src: url('fonts/CC Spellcaster/CCSpellcaster Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

/* ── Variables (from character-sheet.html :root + wiki additions) ─────────── */

:root {
    /* character sheet originals */
    --primary:       #111827;
    --text-main:     #1f2933;
    --text-soft:     rgba(31, 41, 55, 0.72);
    --panel-border:  rgba(15, 23, 42, 0.08);
    --panel-bg:      rgba(255, 255, 255, 0.96);
    --panel-shadow:  0 24px 40px rgba(15, 23, 42, 0.16);
    --transition:    200ms ease;

    /* wiki additions */
    --gold:          #b8860b;
    --gold-dim:      rgba(184, 134, 11, 0.15);
    --ember:         var(--gold);
    --line:          rgba(15, 23, 42, 0.10);
    --line-strong:   rgba(15, 23, 42, 0.18);
    --sidebar-w:     272px;
    --header-h:      64px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
img  { display: block; max-width: 100%; }

/* ── Body (from character-sheet.html) ────────────────────────────────────── */

body {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    line-height: 1.7;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Top bar (character sheet header pattern) ─────────────────────────────── */

.srd-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-h);
    background: rgba(0, 0, 0, 0.93);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    gap: 1rem;
}

.srd-header-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.srd-header-logo svg { flex-shrink: 0; }

.srd-header-title {
    font-family: 'Spellcaster', serif;
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.02em;
}

.srd-header-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.srd-header-sub {
    font-family: 'Playfair Display', serif;
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.srd-header-crumb {
    margin-left: auto;
    font-family: 'Playfair Display', serif;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.04em;
}

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

.shell {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-w);
    grid-template-areas: "main sidebar";
    min-height: calc(100vh - var(--header-h));
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

main     { grid-area: main;    min-width: 0; }
.sidebar { grid-area: sidebar; min-width: 0; }

/* ── Main content ─────────────────────────────────────────────────────────── */

main {
    padding: 3rem 3.5rem 6rem 3.5rem;
    border-right: 1px solid var(--line-strong);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
    background: var(--panel-bg);
    border-left: 1px solid var(--line-strong);
    padding: 1.75rem 1.25rem;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 1.4rem 0 0.4rem 0;
    cursor: pointer;
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ember);
    text-align: left;
}

.nav-group-toggle:first-of-type { margin-top: 0; }

.nav-group-arrow {
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 200ms ease;
    transform: rotate(-90deg);
}

.nav-group-toggle.open .nav-group-arrow {
    transform: rotate(0deg);
}

.nav-collapsed { display: none; }

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.25rem 0;
}

.nav-list li { margin: 0; }

.nav-list a {
    display: block;
    padding: 0.36rem 0.6rem;
    margin: 0.04rem 0;
    font-family: 'Playfair Display', serif;
    font-size: 0.92rem;
    color: var(--text-soft);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 2px;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-list a:hover {
    color: var(--text-main);
    background: rgba(15, 23, 42, 0.05);
}

.nav-list a.current {
    color: var(--gold);
    border-left-color: var(--gold);
    background: var(--gold-dim);
    font-weight: 600;
}

.nav-list .sub-link {
    padding-left: 1rem;
    font-size: 0.85rem;
    color: rgba(31, 41, 55, 0.45);
}

.nav-list .sub-link:hover {
    color: var(--text-soft);
}

/* sidebar brand mark (keep existing SVG from HTML) */
.sidebar-mark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.sidebar-title {
    font-family: 'Spellcaster', serif;
    font-size: 1rem;
    color: var(--text-main);
}

.sidebar-subtitle {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(31, 41, 55, 0.4);
    margin: 0 0 1.25rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line-strong);
}

/* ── Eyebrow ──────────────────────────────────────────────────────────────── */

.eyebrow {
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ember);
    margin: 0 0 0.6rem 0;
}

/* ── Headings ─────────────────────────────────────────────────────────────── */

h1 {
    font-family: 'Spellcaster', serif;
    font-size: clamp(1.9rem, 3.5vw, 2.6rem);
    font-weight: 400;
    color: var(--primary);
    line-height: 1.15;
    margin: 0 0 0.5rem 0;
    letter-spacing: 0.02em;
}

h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin: 2.75rem 0 0.8rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary);
    scroll-margin-top: calc(var(--header-h) + 1rem);
}

h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 1.75rem 0 0.5rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--line-strong);
    scroll-margin-top: calc(var(--header-h) + 1rem);
}

h4 {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-soft);
    margin: 1.25rem 0 0.35rem 0;
}

/* ── Divider under H1 ─────────────────────────────────────────────────────── */

.rule {
    width: 100%;
    height: 3px;
    margin: 0 0 2rem 0;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold) 120px, transparent 420px);
    border-radius: 1px;
}

/* ── SRD hyperlinks (glossary tooltip triggers) ──────────────────────────── */

a.srd-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--gold);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    cursor: pointer;
}
a.srd-link:hover {
    color: var(--gold);
}

/* ── Body text ────────────────────────────────────────────────────────────── */

p { margin: 0 0 1rem 0; color: var(--text-main); }

strong { font-weight: 700; color: var(--primary); }
em     { font-style: italic; color: var(--text-soft); }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 1rem 1.4rem; padding: 0; }
li { margin-bottom: 0.3rem; color: var(--text-main); }

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

/* ── Blockquote ───────────────────────────────────────────────────────────── */

blockquote {
    margin: 1.5rem 0;
    padding: 0.85rem 1.25rem;
    border-left: 3px solid var(--gold);
    background: var(--gold-dim);
    color: var(--text-soft);
    font-size: 0.95rem;
    border-radius: 0 2px 2px 0;
}

blockquote p:last-child { margin-bottom: 0; }

/* ── Quick-rule callout ───────────────────────────────────────────────────── */

.callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border: 1px solid var(--gold);
    background: var(--gold-dim);
    border-radius: 4px;
}

.callout-label {
    display: block;
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.4rem;
}

/* ── Tables (character sheet stat-table aesthetic) ────────────────────────── */

.table-wrap {
    overflow-x: auto;
    margin: 1.25rem 0 1.75rem 0;
    border-radius: 6px;
    box-shadow: var(--panel-shadow);
    border: 1px solid var(--line-strong);
}

table {
    border-collapse: collapse;
    width: 100%;
    font-family: 'Playfair Display', serif;
    font-size: 0.97rem;
    background: white;
}

thead tr {
    background: var(--primary);
}

th {
    padding: 0.5rem 0.85rem;
    text-align: left;
    font-family: 'Playfair Display', serif;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    border: none;
}

td {
    padding: 0.5rem 0.85rem;
    text-align: left;
    color: var(--text-main);
    border-bottom: 1px solid var(--line);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(15, 23, 42, 0.03); }

/* ── Table group-separator rows ─────────────────────────────────────────── */

tr.table-group th {
    background: rgba(15, 23, 42, 0.06);
    color: var(--gold);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    border-top: 2px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

/* ── Shared table column utilities ───────────────────────────────────────── */

td.col-val,
th.col-val { text-align: center; }

td.col-sep,
th.col-sep { border-left: 2px solid var(--line-strong); }


/* ── Kin stat mini-table ─────────────────────────────────────────────────── */

.kin-stat-wrap {
    margin: 0.75rem 0 1.25rem 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.kin-stat-wrap table { font-size: 0.88rem; }
.kin-stat-wrap th    { padding: 0.3rem 0.5rem; font-size: 0.68rem; }
.kin-stat-wrap td    { padding: 0.4rem 0.5rem; font-weight: 600; }

/* scroll-margin for in-page trait anchors */
li[id] {
    scroll-margin-top: calc(var(--header-h) + 1rem);
}

/* ── Page footer nav ──────────────────────────────────────────────────────── */

.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line-strong);
}

.page-nav a {
    flex: 1;
    text-decoration: none;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: white;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.page-nav a:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 16px rgba(184, 134, 11, 0.12);
    text-decoration: none;
}

.page-nav .next { text-align: right; }

.page-nav .dir {
    display: block;
    font-family: 'Playfair Display', serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin-bottom: 0.2rem;
}

.page-nav .label {
    font-family: 'Spellcaster', serif;
    font-size: 1rem;
    color: var(--primary);
}

/* ── Hero cards (index page) ──────────────────────────────────────────────── */

.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.hero-card {
    border: 1px solid var(--line-strong);
    background: white;
    padding: 1.25rem;
    border-radius: 6px;
    text-decoration: none;
    display: block;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.hero-card:hover {
    border-color: var(--gold);
    box-shadow: 0 6px 20px rgba(184, 134, 11, 0.12);
    transform: translateY(-2px);
    text-decoration: none;
}

.hero-card .num {
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ember);
}

.hero-card .name {
    font-family: 'Spellcaster', serif;
    font-size: 1.1rem;
    color: var(--primary);
    margin-top: 0.3rem;
}

.hero-card .desc {
    font-family: 'Playfair Display', serif;
    font-size: 0.92rem;
    color: var(--text-soft);
    margin-top: 0.35rem;
    line-height: 1.5;
}

/* ── License block ────────────────────────────────────────────────────────── */

.license-block {
    border: 1px solid var(--line-strong);
    background: white;
    padding: 1.4rem 1.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-soft);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.license-block ol { padding-left: 1.3rem; }
.license-block li { margin-bottom: 0.55rem; }

/* ── Sticky page title bar + progress ────────────────────────────────────── */

:root { --title-bar-h: 48px; }

.page-title-bar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 39;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--line-strong);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    transform: translateY(-100%);
    transition: none; /* instant hide */
}

.page-title-bar.visible {
    transform: translateY(0);
    transition: transform 220ms ease; /* slide in only */
}

.page-title-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0 3.5rem;
    height: var(--title-bar-h);
    max-width: 1280px;
    margin: 0 auto;
}

.page-title-bar-eyebrow {
    font-family: 'Playfair Display', serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    white-space: nowrap;
}

.page-title-bar-sep {
    color: var(--text-soft);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.page-title-bar-title {
    font-family: 'Spellcaster', serif;
    font-size: 1.05rem;
    color: var(--primary);
    white-space: nowrap;
}

.page-title-bar-h2 {
    font-family: 'Playfair Display', serif;
    font-size: 0.88rem;
    font-style: italic;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.srd-progress-bar {
    position: fixed;
    top: calc(var(--header-h) - 3px);
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 100;
    pointer-events: none;
}

.srd-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gold);
    transition: width 80ms linear;
}

/* bump scroll-margin when title bar is visible */
html.title-bar-on h2,
html.title-bar-on h3 {
    scroll-margin-top: calc(var(--header-h) + var(--title-bar-h) + 0.5rem);
}

/* ── Search ───────────────────────────────────────────────────────────────── */

.srd-search-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-left: auto;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 6px;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    padding: 0.3rem 0.65rem 0.3rem 0.5rem;
    transition: background 150ms, color 150ms, border-color 150ms;
    white-space: nowrap;
}
.srd-search-toggle:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
    border-color: rgba(255,255,255,0.25);
}
.srd-search-shortcut {
    font-size: 0.68rem;
    font-family: 'Playfair Display', serif;
    letter-spacing: 0.03em;
    opacity: 0.7;
}

.srd-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 90px;
}
.srd-search-overlay[hidden] { display: none; }

.srd-search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(4px);
}

.srd-search-modal {
    position: relative;
    z-index: 1;
    width: min(660px, calc(100vw - 2rem));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.06);
    overflow: hidden;
}

.srd-search-inputwrap {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--line);
}
.srd-search-icon { color: var(--text-soft); flex-shrink: 0; }

.srd-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    color: var(--primary);
    background: transparent;
    min-width: 0;
}
.srd-search-input::placeholder { color: rgba(31,41,55,0.4); }
.srd-search-input::-webkit-search-cancel-button { display: none; }

.srd-search-esc {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-family: 'Playfair Display', serif;
    color: var(--text-soft);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
}

.srd-search-results {
    max-height: 440px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.srd-result {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    row-gap: 0.15rem;
    align-items: baseline;
    padding: 0.7rem 1.1rem;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    transition: background 100ms;
}
.srd-result:last-child { border-bottom: none; }
.srd-result:hover,
.srd-result.is-active { background: rgba(184,134,11,0.06); }

.srd-result-tag {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.66rem;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    white-space: nowrap;
}

.srd-result-title {
    grid-column: 2;
    grid-row: 1;
    font-family: 'Spellcaster', serif;
    font-size: 1rem;
    color: var(--primary);
}

.srd-result-body {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.8rem;
    color: var(--text-soft);
    line-height: 1.45;
}

.srd-search-empty,
.srd-search-hint {
    padding: 1.25rem 1.1rem;
    font-size: 0.85rem;
    color: var(--text-soft);
    font-style: italic;
    text-align: center;
}

/* ── Selection ────────────────────────────────────────────────────────────── */

::selection { background: var(--gold); color: white; }

/* ── Mobile hamburger button ──────────────────────────────────────────────── */

.srd-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    border-radius: 6px;
    margin-right: 0.25rem;
    transition: background 150ms, color 150ms;
}
.srd-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ── Nav backdrop (injected by JS, mobile only) ───────────────────────────── */

.srd-nav-backdrop {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 145;
}

body.nav-open .srd-nav-backdrop { display: block; }
body.nav-open { overflow: hidden; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
    .srd-menu-btn { display: flex; }

    .srd-header-sep,
    .srd-header-sub { display: none; }

    .shell {
        display: block; /* sidebar is a fixed overlay, not in grid flow */
    }

    .sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        height: calc(100vh - var(--header-h));
        width: min(288px, 85vw);
        z-index: 150;
        transform: translateX(-100%);
        transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
        border-left: none;
        border-right: 1px solid var(--line-strong);
        border-bottom: none;
        padding-top: 1rem;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    main {
        padding: 2rem 1.25rem 4rem;
        border-right: none;
    }

    h1 { font-size: 1.9rem; }

    .page-title-bar-inner {
        padding: 0 1.25rem;
    }
}
