body {
    padding-top: 50px;
    background-color: #101311;
    background-image: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.3)), url(../img/staffan-kjellvestad-y1qOT82fd8k-unsplash.jpg);
    background-position: center 67%, center 67%;
    background-repeat: no-repeat, no-repeat;
    background-attachment: fixed, fixed;
    -webkit-background-size: auto, cover;
    -moz-background-size: auto, cover;
    background-size: auto, cover;
    -o-background-size: auto, cover;
}

/* Images never exceed their container (fixes the oversized map on phones) */
img { max-width: 100%; height: auto; }

/* Mobile contents button + backdrop: hidden on desktop, shown in the media query below */
#toc-toggle, #toc-backdrop { display: none; }

.primer-page {
    min-height: calc(100vh - 50px);
    background: transparent;
}

.primer-header {
    padding: 70px 0 54px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    background: transparent;
}

.primer-header .container {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 64px;
}

.navbar-custom,
.navbar-custom.top-nav-collapse {
    padding: 0;
    border-bottom: 1px solid rgba(255,255,255,.3);
    background: #000;
}

.primer-kicker,
.primer-toc-title,
.section-number {
    color: #3bb8b3;
    font-family: Kelvinch, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.primer-kicker {
    margin: 0 0 12px;
}

.primer-header h1 {
    grid-column: 2;
    justify-self: center;
    width: 100%;
    max-width: 1000px;
    margin: 50px 0 0px;
    font-family: GondolaSwash, Georgia, serif;
    font-size: 52px;
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
    text-transform: none;
}

.primer-deck {
    max-width: 620px;
    margin: 0 auto;
    color: rgba(255,255,255,.72);
    font-size: 18px;
    text-align: center;
}

.primer-layout {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 64px;
    direction: ltr;
    padding-bottom: 100px;
}

.primer-toc {
    grid-column: 1;
    position: sticky;
    top: 92px;
    align-self: start;
    padding: 24px 16px;
    background: rgba(0,0,0,.62);
    max-height: calc(100vh - 112px); /* 92px top offset + 20px bottom gap */
    overflow-y: auto;
    overscroll-behavior: contain;    /* page doesn't scroll when you reach the end of the sidebar */
    scrollbar-width: thin;
    scrollbar-color: rgba(59,184,179,.5) transparent;
}

.primer-toc-group + .primer-toc-group {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,.16);
}

.primer-toc-title {
    margin: 0 0 14px;
    text-align: center;
}

.primer-toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.primer-toc li {
    margin: 0;
    border-left: 1px solid rgba(255,255,255,.18);
}

.primer-toc a {
    display: block;
    padding: 8px 12px;
    color: rgba(255,255,255,.68);
    font-size: 15px;
    transition: color .2s ease, border-color .2s ease;
}

.codex-toc a {
    color: #3bb8b3;
}

.codex-subtoc {
    margin: 4px 0 8px 12px;
}

.codex-subtoc li {
    border-left: 0;
}

.codex-subtoc a {
    padding: 6px 12px 6px 16px;
    color: #fff;
    font-size: 13px;
}
.primer-toc a:hover,
.primer-toc a:focus {
    border-left: 2px solid #3bb8b3;
    color: #fff;
    text-decoration: none;
}

.primer-content {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 64px;
    padding: 28px 24px;
    background: rgba(0,0,0,.62);
}

.primer-article {
    max-width: 1000px;
    width: 86%;
}

.primer-article details {
    border-bottom: 1px solid rgba(255,255,255,.16);
    scroll-margin-top: 84px;
}

.primer-article details:first-child {
    border-top: 1px solid rgba(255,255,255,.16);
}

.primer-article summary {
    position:relative;
    display: block;
    text-align:center;
    grid-template-columns: 150px minmax(0, 1fr) 32px;
    align-items: center;
    padding: 24px 0;
    color: #fff;
    cursor: pointer;
    font-family: Kelvinch, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 27px;
    font-weight: 700;
    list-style: none;
}

.codex-content > details > summary {
    color: #3bb8b3;
}

.primer-article summary::-webkit-details-marker {
    display: none;
}

.primer-article summary::after {
    content: "+";
    font-family: Kelvinch, sans-serif;
    font-size: 24px;
    font-weight: 400;
}

/* ">" matters: without it, every closed box nested inside an open one
   would also match and show the minus sign. */
.primer-article details[open] > summary::after {
    content: "\2212";   /* minus sign, same width as the + */
}

.primer-article .codex-subcategory > summary {
    position: relative;
    display: block;
    padding: 25px 0;
    font-size: 22px;
    letter-spacing: 0;
    text-align: center;
    text-transform: none;
}

.primer-article .codex-subcategory > summary::after {
    position: absolute;
    top: 50%;
    right: 2%;
    transform: translateY(-50%);
}

.codex-subcategory-copy {
    padding: 0  32px 50px;
}

.codex-subcategory-copy h3 {
    margin: 24px 0 10px;
    color: #fff;
    font-size: 20px;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
}

.codex-subcategory-copy h4 {
    margin: 20px 0 10px;
    color: rgba(255,255,255,.92);
    font-size: 16px;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
}

.delve-symbol-key {
    margin: 22px 0 0 20px;
    padding-left: 18px;
    border-left: 1px solid rgba(59,184,179,.5);
}

.delve-symbol-key h4 {
    margin: 14px 0 0;
    font-size: 18px;
}

.delve-symbol-key h4:first-child {
    margin-top: 0;
}

.journey-rules-list {
    margin: 0 0 24px;
    padding-left: 28px;
    font-size: 18px;
    line-height: 1.4;
}

.journey-rules-list li {
    margin-bottom: 18px;
}

.journey-rules-list li::marker {
    color: #3bb8b3;
    font-weight: 700;
}

.codex-game-actions {
    margin: 0 0 20px;
    padding-left: 22px;
    font-size: 18px;
    line-height: 1.4;
}

.codex-game-actions > li {
    margin-bottom: 18px;
}

.codex-rule-block {
    margin: 16px 0 20px;
    padding: 14px 18px;
    border: 1px solid rgba(255,255,255,.16);
    border-left: 3px solid #3bb8b3;
    border-radius: 0;
    background: rgba(0,0,0,.5);
    color: #fff;
    white-space: pre-wrap;
    word-break: normal;
}

.codex-rule-block code {
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
}

.journey-example-callout {
    position: relative;
    margin: 30px 0 30px 20px;
    padding: 24px 20px 18px;
    border: 1px solid rgba(59,184,179,.35);
    background: rgba(0,0,0,.5);
}

.journey-example-tab {
    position: absolute;
    top: -11px;
    left: 16px;
    padding: 2px 8px;
    color: #3bb8b3;
    background: #101311;
    font-family: Kelvinch, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.primer-copy .journey-example-callout p {
    margin: 0 0 18px;
    text-align: left;
    text-align-last: left;
}

.primer-copy .journey-example-callout p:last-child {
    margin-bottom: 0;
}

.round-cycle-callout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin: 22px 0 20px 20px;
    padding-left: 18px;
    border-left: 1px solid rgba(59,184,179,.5);
}

.codex-subcategory-copy .round-cycle-callout p {
    margin: 0;
    color: #fff;
    text-align: left;
    text-align-last: left;
}

.codex-arrow-list {
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    font-size: 18px;
    line-height: 1.4;
}

.codex-arrow-list li {
    margin: 0 0 8px;
}

.codex-figure {
    margin: 20px 0 28px;
}

.codex-figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.section-number {
    text-align: left;
}

.primer-copy {
    max-width: 1000px;
    padding: 0 0 24px 0px;
    color: rgba(255,255,255,.78);
}

.primer-copy p {
    margin: 10px 0 0;
    text-align: justify;
    text-align-last: center;
}

.primer-copy p:last-child {
    margin-bottom: 0;
}

.primer-copy h3,
.primer-copy h4,
.codex-subcategory-copy h3,
.codex-subcategory-copy h4 {
    text-align: center;
}

.delve-symbol-key h4,
.delve-symbol-key p {
    text-align: left;
}

.delve-symbol-key p {
    text-align-last: left;
}

#the-world .primer-copy h3,
.play-modes .primer-copy h3,
#the-world .primer-copy h4,
.play-modes .primer-copy h4,
.mechanics-list {
    margin: 0;
    padding-left: 22px;
    padding-top: 22px;
    line-height: 1.4;
}

.mechanics-list li + li {
    margin-top: 14px;
}

.primer-footer {
    padding: 22px 0;
    border-top: 1px solid rgba(255,255,255,.14);
    background: rgba(8,10,9,.78);
    font-size: 16px;
}

.primer-footer .container {
    display: flex;
    justify-content: space-between;
}

.primer-footer a {
    color: rgba(255,255,255,.72);
}

.primer-footer a:hover,
.primer-footer a:focus {
    color: #3bb8b3;
}

/* ================= MOBILE ================= */
@media (max-width: 767px) {
    /* Nothing may push the page wider than the screen.
       Kept inside the media query so desktop sticky sidebar is unaffected. */
    html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }

    body { background-attachment: scroll; }

    .primer-header { padding: 30px 0 20px; }

    .primer-header .container {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .primer-header h1 {
        grid-column: 1;
        margin-top: 10px;
        font-size: 34px;
    }

    .primer-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding-top: 16px;
        padding-bottom: 80px;
    }

    /* Sidebar becomes a slide-in drawer opened by the Contents button */
    .primer-toc {
        position: fixed;
        top: 50px; left: 0; right: auto; bottom: auto;
        align-self: auto;                          /* undo the desktop grid alignment */
        width: min(85vw, 320px);
        /* Explicit height (not top+bottom) so overflow-y reliably scrolls on phones.
           100dvh follows the mobile browser toolbars where supported. */
        height: calc(100vh - 50px);
        height: calc(100dvh - 50px);
        max-height: none;
        padding: 20px 14px 90px;
        background: rgba(16,19,17,.98);   /* opaque; primer-book.css sets the light-theme colour */
        box-shadow: 2px 0 16px rgba(0,0,0,.3);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-105%);
        transition: transform .25s ease;
        z-index: 1050;
    }
    body.toc-open .primer-toc { transform: none; }

    .primer-toc ol { display: block; }
    .primer-toc a { padding: 8px 12px; }

    #toc-backdrop {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.4);
        opacity: 0; visibility: hidden;
        transition: opacity .25s ease;
        z-index: 1040;
    }
    body.toc-open #toc-backdrop { opacity: 1; visibility: visible; }

    #toc-toggle {
        display: flex; align-items: center; gap: 8px;
        position: fixed;
        top: 8px;                                  /* vertically centred in the 50px navbar */
        left: 14px;
        height: 34px; padding: 0 14px;
        border-radius: 17px;
        border: 1px solid rgba(255,255,255,.7);
        background: #1d6f7a; color: #fff;
        font-family: Kelvinch, "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-weight: 700; font-size: 14px;
        box-shadow: 0 3px 12px rgba(0,0,0,.35);
        z-index: 9998;
    }

    /* Navbar: the hamburger stays at the top right. When opened, Home + Primer drop
       down as a small panel under it, on the right, instead of a full-width list
       that runs under the Contents button on the left. */
    .navbar-custom .navbar-collapse {
        position: absolute;
        top: 50px; right: 0; left: auto;
        width: auto;
        min-width: 150px;
        padding: 0;
        border: 0;
        background: #000;
        box-shadow: 0 4px 12px rgba(0,0,0,.3);
    }
    .navbar-custom .navbar-nav { margin: 0; float: none; }
    .navbar-custom .navbar-nav > li > a {
        padding: 12px 20px;
        text-align: right;
    }

    .primer-content { grid-column: 1; gap: 32px; padding: 14px 10px; }
    .primer-article { width: 100%; }

    .primer-article summary {
        padding: 18px 26px 18px 0;
        font-size: 20px;
        letter-spacing: .5px;
    }
    .primer-article .codex-subcategory > summary {
        padding: 18px 26px 18px 6px;
        font-size: 18px;
    }
    .codex-subcategory-copy { padding: 0 4px 32px; }

    .primer-copy p { text-align: left; text-align-last: left; }
    .primer-copy, .codex-rule-block { overflow-wrap: anywhere; }

    .journey-example-callout,
    .round-cycle-callout,
    .delve-symbol-key { margin-left: 0; }

    .journey-rules-list,
    .codex-game-actions { padding-left: 20px; font-size: 16px; }
}

/* ================= PATH ENTRIES ================= */
.path-entry {
  --p-panel: #221d16; --p-panel-2: #2a231a87; --p-line: #3a3123;
  --p-gold: #d9a441; --p-teal: #4aa397; --p-blood: #c0555c; --p-dark-page: #c09aa7;
  --p-cream: #efe6d2; --p-muted: #8a8070;
  --p-mono: ui-monospace, Menlo, Consolas, monospace;
}
.path-entry h3 { margin-top: 1.6em; }
.path-label {
  display: block; font-family: var(--p-mono); font-size: 0.65em;
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--p-muted);
  margin-bottom: 0.6em;
}
.path-top { display: flex; gap: 1.5em; align-items: flex-start; margin-bottom: 1em; }
.path-portrait { flex: 0 0 240px; max-width: 40%; margin: 0; padding: 8px; background: var(--p-panel); border: 1px solid var(--p-line); }
.path-portrait img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border: 1px solid var(--p-gold); }
.path-portrait figcaption { margin-top: 0.6em; font-size: 0.8em; font-style: italic; color: var(--p-muted); text-align: center; }
.path-lore { flex: 1; padding: 1em 1.4em; background: var(--p-panel); border: 1px solid var(--p-line); color: var(--p-cream); }
.path-quote strong { color: var(--p-gold); font-size: 1em; }
.path-lore hr { border: none; border-top: 1px solid var(--p-line); margin: 1em 0; }

.path-creation { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1em; }
.path-panel { padding: 1em 1.2em; background: var(--p-panel); border: 1px solid var(--p-line); color: var(--p-cream); }
.path-table { width: 100%; border-collapse: collapse; }
.path-table th {
  font-family: var(--p-mono); font-size: 0.65em; font-weight: 400; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--p-muted); border-bottom: 1px solid var(--p-line); padding: 0.5em 0.6em; text-align: left;
}
.path-table td { background: var(--p-panel-2); border-bottom: 1px solid var(--p-line); padding: 0.35em 0.6em; }
.path-table td:first-child { font-family: var(--p-mono); font-size: 0.75em; letter-spacing: 0.18em; text-transform: uppercase; color: var(--p-gold); }
.path-list { list-style: none; padding: 0; margin: 0; }
.path-list li { padding: 0.3em 0; border-bottom: 1px solid var(--p-line); }
.path-list li::before { content: "◊ "; color: var(--p-gold); }

.path-feature, .path-feat, .path-gift {
border-left: 5px solid var(--p-gold);
  padding: 0.8em 1.2em; margin-bottom: 0.8em; color: var(--p-cream); 
  background: var(--p-panel);
}
.path-feature { border-left-color: var(--p-gold); overflow: auto; }
.path-feature h4 { color: var(--p-gold); margin-top: 0; }
.path-feat h4 { color: var(--p-gold); margin-top: 0; }
.path-feat summary { color: var(--p-gold); font-size: 1.3em; cursor: pointer; }
.path-feat .path-flavor { margin-top: 0.4em; }
.path-table-side { float: right; width: 220px; margin: 0 0 0.8em 1.2em; }
.path-gift { border-left-color: var(--p-blood); }
.path-gift summary { color: var(--p-blood); font-size: 1.3em; cursor: pointer; }
.path-flavor { font-style: italic; color: var(--p-muted); }
.path-meta { color: var(--p-cream); }

@media (max-width: 700px) {
  .path-top { flex-direction: column; }
  .path-portrait { flex: none; max-width: 100%; width: 100%; }
  .path-table-side { float: none; width: 100%; margin: 0 0 0.8em; }
}
