/*
 * =============================================================================
 * Document ID:  WS-HB-CSS-HANDBOOK
 * Title:        Main Stylesheet
 * Status:       Active
 * Version:      1.1
 * Date:         2026-07-31
 *
 * Purpose:
 *   Global application styling: the Rogue One-inspired color palette,
 *   the persistent application shell (header/nav/workspace), left
 *   navigation tree, article typography, illustrated sections,
 *   lightbox, tables, contact cards, and responsive layout. Owns
 *   everything that is NOT specific to the Game Reference component
 *   library (see css/game-reference.css for that).
 *
 *   Character-specific content and images are supplied by the
 *   selected player-data package; shared presentation stays here.
 *
 * Scope / Authority:
 *   Governed by WS-HANDBOOK-ARCH-001 ("Stylesheets should have clear
 *   ownership... do not duplicate styles across multiple files without
 *   justification"). Desktop widths (>700px) use a fixed application
 *   shell where only .handbook-content/.handbook-navigation scroll;
 *   the 700px breakpoint reverts to normal whole-page scroll since nav
 *   and content stack vertically there.
 * =============================================================================
 */


/* =========================================================
   WAYWARD STAR COLOR SYSTEM
   ========================================================= */

:root {
    /* Rogue One-inspired palette */

    --ws-slate-deep: #273941;
    --ws-slate-dark: #2C4E61;
    --ws-steel-blue: #4B7B92;
    --ws-sky-blue: #73A9C7;
    --ws-pale-blue: #B1D0DE;
    --ws-archive-paper: #DFDDD4;
    --ws-steel-gray: #939EA0;
    --ws-rust-brown: #784B26;
    /* Application materials */

    --ws-shell-background: var(--ws-slate-deep);
    --ws-header-background: #203038;
    --ws-navigation-background: #243840;
    --ws-navigation-surface: var(--ws-slate-dark);
    --ws-navigation-hover: var(--ws-steel-blue);
    --ws-navigation-active: var(--ws-sky-blue);
    --ws-document-background: var(--ws-archive-paper);
    --ws-document-surface: var(--ws-pale-blue);
    --ws-document-surface-muted: rgba(177, 208, 222, 0.48);
    --ws-document-surface-hover: rgba(115, 169, 199, 0.34);
    --ws-text-dark: var(--ws-slate-deep);
    --ws-text-medium: var(--ws-slate-dark);
    --ws-text-light: var(--ws-archive-paper);
    --ws-text-muted-light: var(--ws-steel-gray);
    --ws-text-muted-dark: #52656D;
    --ws-border-dark: rgba(177, 208, 222, 0.28);
    --ws-border-medium: var(--ws-steel-gray);
    --ws-border-light: var(--ws-pale-blue);
    --ws-border-accent: var(--ws-steel-blue);
    --ws-accent-primary: var(--ws-rust-brown);
    --ws-accent-secondary: var(--ws-steel-blue);
    --ws-accent-highlight: var(--ws-sky-blue);
    --ws-focus-outline: 2px solid var(--ws-sky-blue);
}


/* =========================================================
   GLOBAL RESET
   ========================================================= */

* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
}


body {
    background: var(--ws-shell-background);
    color: var(--ws-text-light);
    font-family: Arial, Helvetica, sans-serif;
}


button,
select {
    font: inherit;
}


    button:focus-visible,
    select:focus-visible,
    a:focus-visible {
        outline: var(--ws-focus-outline);
        outline-offset: 2px;
    }


/* =========================================================
   HANDBOOK APPLICATION SHELL
   ========================================================= */

.handbook-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--ws-shell-background);
}


/* =========================================================
   HEADER
   ========================================================= */

.handbook-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 92px;
    padding: 20px 30px 20px 110px;
    background: var(--ws-header-background);
    border-bottom: 2px solid var(--ws-rust-brown);
}


    /*
   Wayward Star logo.

   The image is decorative and is inserted through CSS so the
   primary title markup remains focused on handbook identity.
*/

    .handbook-header::before {
        content: "";
        position: absolute;
        left: 24px;
        top: 50%;
        width: 68px;
        height: 68px;
        transform: translateY(-50%);
        background-image: url("../assets/images/StarLogo.png");
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }


.handbook-title h1 {
    margin: 0;
    color: var(--ws-sky-blue);
    font-size: 28px;
    letter-spacing: 4px;
}


.handbook-title p {
    margin: 4px 0 0;
    color: var(--ws-pale-blue);
    font-size: 12px;
    letter-spacing: 3px;
}


.archive-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: right;
    color: var(--ws-steel-gray);
    font-size: 11px;
    letter-spacing: 1px;
}


/* =========================================================
   MAIN HANDBOOK LAYOUT
   ========================================================= */

.handbook-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}


.handbook-navigation {
    flex: 0 0 300px;
    padding: 22px 16px 30px;
    background: var(--ws-navigation-background);
    border-right: 1px solid var(--ws-border-dark);
    overflow-y: auto;
}


.handbook-content {
    flex: 1;
    min-width: 0;
    padding: 40px 60px;
    background: var(--ws-document-background);
    color: var(--ws-text-dark);
    overflow-y: auto;
}


    .handbook-content article {
        width: 100%;
        max-width: 1180px;
    }


/* =========================================================
   TREE NAVIGATION
   ========================================================= */

.navigation-tree {
    margin: 0 0 8px;
}


.tree-heading {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: stretch;
    min-height: 38px;
}


.tree-toggle,
.tree-title,
.tree-item {
    background: transparent;
    border: 0;
    color: var(--ws-pale-blue);
    cursor: pointer;
}


/* =========================================================
   TREE EXPAND / COLLAPSE CONTROL
   ========================================================= */

.tree-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    padding: 0;
    color: var(--ws-steel-gray);
}


    .tree-toggle:hover {
        color: var(--ws-sky-blue);
    }


.tree-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    font-size: 0;
    line-height: 0;
}


    .tree-arrow::before {
        content: "";
        display: block;
        width: 6px;
        height: 6px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform 0.15s ease, color 0.15s ease;
    }


.navigation-tree.collapsed .tree-arrow::before {
    transform: rotate(-45deg);
}


/* =========================================================
   TREE SECTION TITLES
   ========================================================= */

.tree-title {
    width: 100%;
    padding: 10px 8px;
    color: var(--ws-sky-blue);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1.8px;
    text-align: left;
}


    .tree-title:hover {
        background: var(--ws-navigation-surface);
        color: var(--ws-text-light);
    }


    .tree-title.active {
        background: var(--ws-navigation-surface);
        color: var(--ws-text-light);
    }


/* =========================================================
   TREE CHILD ARTICLES
   ========================================================= */

.tree-children {
    position: relative;
    display: block;
    margin: 2px 0 8px 14px;
    padding-left: 14px;
    border-left: 1px solid var(--ws-border-dark);
}


.navigation-tree.collapsed .tree-children {
    display: none;
}


.tree-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 8px 10px 8px 14px;
    border-left: 2px solid transparent;
    color: var(--ws-pale-blue);
    font-size: 13px;
    text-align: left;
}


    .tree-item::before {
        content: "";
        position: absolute;
        left: -15px;
        top: 50%;
        width: 12px;
        border-top: 1px solid var(--ws-border-dark);
    }


    .tree-item:hover {
        background: var(--ws-navigation-surface);
        color: var(--ws-text-light);
    }


    .tree-item.active {
        background: var(--ws-steel-blue);
        border-left-color: var(--ws-sky-blue);
        color: #FFFFFF;
    }


/* =========================================================
   ARTICLE CONTENT
   ========================================================= */


/* ---------------------------------------------------------
   ARTICLE CLASSIFICATION
   --------------------------------------------------------- */

.classification {
    margin: 0 0 10px;
    color: var(--ws-text-muted-dark);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
}


/* ---------------------------------------------------------
   ARTICLE TYPOGRAPHY
   --------------------------------------------------------- */

.handbook-content h2 {
    margin: 0 0 18px;
    color: var(--ws-rust-brown);
    font-size: 27px;
    letter-spacing: 2px;
}


.handbook-content h3 {
    margin: 0 0 12px;
    color: var(--ws-slate-dark);
    font-size: 16px;
    letter-spacing: 1.5px;
}


.handbook-content h4 {
    color: var(--ws-slate-deep);
}


.handbook-content p {
    margin: 0 0 10px;
    color: var(--ws-text-dark);
    font-size: 15px;
    line-height: 1.5;
}


.handbook-content a {
    color: var(--ws-slate-dark);
}


    .handbook-content a:hover {
        color: var(--ws-rust-brown);
    }


/* ---------------------------------------------------------
   ARTICLE SECTION LAYOUT
   --------------------------------------------------------- */

.article-section {
    margin: 0 0 34px;
}


    .article-section:last-child {
        margin-bottom: 0;
    }


/* =========================================================
   ILLUSTRATED ARTICLE LAYOUT
   ========================================================= */

.illustrated-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 45px;
    align-items: start;
    margin: 0 0 50px;
}


    .illustrated-section.reverse {
        grid-template-columns: 340px minmax(0, 1fr);
    }


        .illustrated-section.reverse .section-text {
            order: 2;
        }


        .illustrated-section.reverse .section-images {
            order: 1;
        }


.section-text {
    min-width: 0;
}


.section-images {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}


/* =========================================================
   REFERENCE IMAGES
   ========================================================= */

.reference-image {
    width: 100%;
    margin: 0;
    padding: 10px;
    background: var(--ws-document-surface);
    border: 1px solid var(--ws-border-medium);
}


    .reference-image img {
        display: block;
        width: 100%;
        height: auto;
    }


    .reference-image figcaption {
        padding-top: 8px;
        color: var(--ws-text-medium);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 1.5px;
        line-height: 1.5;
    }


.reference-image-wide {
    width: 100%;
    max-width: 100%;
    margin-top: 30px;
}


.expandable-image {
    cursor: zoom-in;
}


/* =========================================================
   SPACER WISDOM
   ========================================================= */

.spacer-wisdom {
    margin-top: 35px;
    padding: 12px 18px;
    border-left: 4px solid var(--ws-rust-brown);
    background: var(--ws-document-surface-muted);
    color: var(--ws-slate-deep) !important;
    font-weight: bold;
    line-height: 2;
}


/* =========================================================
   HANDBOOK TABLE
   ========================================================= */

.handbook-table {
    width: 100%;
    margin: 1.5rem 0 2rem;
    border-collapse: collapse;
    background: rgba(177, 208, 222, 0.3);
    border: 1px solid var(--ws-border-medium);
}


    .handbook-table th,
    .handbook-table td {
        padding: 0.75rem 1rem;
        text-align: left;
        vertical-align: top;
        border-bottom: 1px solid rgba(75, 123, 146, 0.34);
    }


    .handbook-table th {
        background: var(--ws-slate-dark);
        color: var(--ws-archive-paper);
        font-size: 0.8rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }


    .handbook-table td {
        color: var(--ws-text-dark);
        font-size: 0.95rem;
        line-height: 1.5;
    }


    .handbook-table tbody tr:last-child td {
        border-bottom: none;
    }


    .handbook-table tbody tr:hover {
        background: rgba(115, 169, 199, 0.22);
    }


    .handbook-table th:last-child,
    .handbook-table td:last-child {
        white-space: nowrap;
    }


/* =========================================================
   CONTACT CARDS
   ========================================================= */

.contact-card {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
    margin: 0 0 24px;
    padding: 18px;
    background: var(--ws-document-surface-muted);
    border: 1px solid var(--ws-border-medium);
}


.contact-token {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}


    .contact-token img {
        display: block;
        width: 132px;
        height: 132px;
        object-fit: contain;
    }


.contact-token-placeholder {
    width: 132px;
    height: 132px;
    align-items: center;
    align-self: start;
    background: var(--ws-pale-blue);
    border: 1px solid var(--ws-steel-gray);
    color: var(--ws-slate-dark);
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
}


.contact-details {
    min-width: 0;
}


.contact-heading {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ws-border-medium);
}


    .contact-heading h3 {
        margin-bottom: 5px;
    }


.contact-role {
    margin: 0 !important;
    color: var(--ws-text-muted-dark) !important;
    font-size: 12px !important;
    letter-spacing: 1px;
    text-transform: uppercase;
}


.contact-assessment {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 6px;
    color: var(--ws-text-medium);
    font-size: 12px;
    line-height: 1.4;
    text-align: right;
}


.contact-details p {
    margin-bottom: 12px;
    font-size: 14px;
}


.contact-use {
    margin-bottom: 0 !important;
    color: var(--ws-text-medium) !important;
}


/* =========================================================
   DEVELOPMENT PLAYER PACKAGE SELECTOR
   ========================================================= */

.player-package-selector {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}


    .player-package-selector label {
        color: var(--ws-steel-gray);
        font-size: 9px;
        letter-spacing: 1.4px;
    }


    .player-package-selector select {
        min-width: 150px;
        padding: 5px 8px;
        background: var(--ws-slate-deep);
        border: 1px solid var(--ws-steel-blue);
        color: var(--ws-pale-blue);
        font-size: 11px;
        letter-spacing: 1px;
        cursor: pointer;
    }


        .player-package-selector select:hover,
        .player-package-selector select:focus {
            border-color: var(--ws-sky-blue);
            outline: none;
        }


/* =========================================================
   REFERENCE RESOURCE NAVIGATION
   ========================================================= */

.resource-navigation {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--ws-border-dark);
}


/* =========================================================
   CORE RULEBOOK NAVIGATION
   ========================================================= */

.resource-tree {
    margin-bottom: 10px;
}


.resource-tree-title {
    color: var(--ws-steel-gray);
}


    .resource-tree-title:hover {
        color: var(--ws-sky-blue);
    }


/* =========================================================
   RULEBOOK COVER LINKS
   ========================================================= */

.rulebook-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}


.navigation-tree.collapsed .rulebook-list {
    display: none;
}


.rulebook-link {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 7px;
    color: var(--ws-pale-blue);
    text-decoration: none;
    border: 1px solid transparent;
}


    .rulebook-link:hover {
        background: var(--ws-navigation-surface);
        border-color: var(--ws-steel-blue);
        color: var(--ws-text-light);
    }


    .rulebook-link img {
        display: block;
        width: 48px;
        height: 64px;
        object-fit: cover;
        border: 1px solid var(--ws-steel-gray);
    }


    .rulebook-link span {
        font-size: 10px;
        font-weight: bold;
        letter-spacing: 1.2px;
        line-height: 1.5;
    }


/* =========================================================
   RESOURCE MANUAL SPACING
   ========================================================= */

.resource-navigation .manual-navigation {
    margin-top: 16px;
    padding-top: 0;
    border-top: 0;
}


/* =========================================================
   USER MANUAL NAVIGATION
   ========================================================= */

.manual-navigation {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--ws-border-dark);
}


.manual-navigation-button {
    width: 100%;
    padding: 10px 8px;
    background: transparent;
    border: 0;
    color: var(--ws-steel-gray);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.6px;
    text-align: left;
    cursor: pointer;
}


    .manual-navigation-button:hover {
        background: var(--ws-navigation-surface);
        color: var(--ws-text-light);
    }


    .manual-navigation-button.active {
        background: var(--ws-steel-blue);
        color: #FFFFFF;
    }


/* =========================================================
   FOOTER
   ========================================================= */

.handbook-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px 25px;
    background: var(--ws-header-background);
    border-top: 1px solid var(--ws-border-dark);
    color: var(--ws-steel-gray);
    font-size: 9px;
    letter-spacing: 1px;
}


/* =========================================================
   IMAGE LIGHTBOX
   ========================================================= */

.image-lightbox {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: rgba(20, 31, 36, 0.96);
    z-index: 1000;
}


    .image-lightbox.active {
        display: flex;
    }


    .image-lightbox img {
        max-width: 95%;
        max-height: 95vh;
        object-fit: contain;
        border: 1px solid var(--ws-pale-blue);
    }


.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: transparent;
    border: 0;
    color: var(--ws-sky-blue);
    font-size: 42px;
    cursor: pointer;
}


/* =========================================================
   SKILLS OVERVIEW (skills-overview.js)
   ========================================================= */

.skills-overview-tabs {
    margin-top: 24px;
}


.reference-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}


    .reference-table th {
        padding: 8px 12px;
        background: rgba(41, 81, 101, 0.10);
        border-bottom: 2px solid #8a5a24;
        font-weight: 700;
    }


    .reference-table td {
        padding: 5px 12px;
        vertical-align: top;
    }


        .reference-table th:first-child,
        .reference-table td:first-child {
            width: 220px;
            padding-right: 32px;
            text-align: right;
            white-space: nowrap;
        }


        .reference-table th:last-child,
        .reference-table td:last-child {
            text-align: left;
        }


    .reference-table tbody tr:first-child td {
        padding-top: 12px;
    }


/* =========================================================
   ARTICLE DISCLOSURES

   Generic expandable content used throughout handbook
   articles.

   This component intentionally mirrors the navigation tree
   styling so it feels like part of the application rather
   than a traditional web accordion.
   ========================================================= */

.article-disclosure-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    padding: 6px 8px;
    background: transparent;
    border: 0;
    color: var(--ws-text-medium);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}


    .article-disclosure-toggle:hover {
        background: var(--ws-document-surface-hover);
    }


    .article-disclosure-toggle:focus-visible {
        outline: var(--ws-focus-outline);
    }


    .article-disclosure-toggle[aria-expanded="false"] {
        margin-bottom: 28px;
    }


.article-disclosure-arrow {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    line-height: 1;
}


/* ---------------------------------------------
   Disclosure Arrow Size Compensation

   Unicode ▲ renders optically smaller than ▶
   in most UI fonts. Increase only the expanded
   arrow slightly so both appear the same size.
   --------------------------------------------- */

.article-disclosure-toggle[aria-expanded="false"]
.article-disclosure-arrow {
    font-size: 16px;
}


.article-disclosure-toggle[aria-expanded="true"]
.article-disclosure-arrow {
    font-size: 18px;
}


.article-disclosure-content {
    margin-top: 18px;
    margin-bottom: 28px;
}


    .article-disclosure-content[hidden] {
        display: none;
        margin-bottom: 0;
    }


/* =========================================================
   SKILLS OVERVIEW — ACTION PANEL TABS

   Nested tab group used by "...in Action" sections (Exploration,
   Technology, and future chapters with the same shape). Reuses
   game-reference-tab-list / -tab-button / -tab-panel for the
   actual tab styling (css/game-reference.css) — this rule only
   adds the same top spacing already used for the outer Skills
   Overview category tabs (.skills-overview-tabs), so the nested
   tab bar doesn't sit flush against its "...in Action" heading.
   ========================================================= */

.action-panel-tabs {
    margin-top: 24px;
}


/* =========================================================
   RESPONSIVE LAYOUT
   ========================================================= */

@media (max-width: 1000px) {

    .handbook-navigation {
        flex-basis: 270px;
    }


    .handbook-content {
        padding: 40px;
    }


    .illustrated-section,
    .illustrated-section.reverse {
        grid-template-columns: 1fr;
    }


        .illustrated-section.reverse .section-text,
        .illustrated-section.reverse .section-images {
            order: initial;
        }


    .section-images {
        width: 100%;
        max-width: 600px;
    }
}


@media (max-width: 700px) {

    html,
    body {
        height: auto;
        overflow: visible;
    }


    .handbook-shell {
        height: auto;
        min-height: 100vh;
    }


    .handbook-body {
        flex-direction: column;
        overflow: visible;
    }


    .handbook-navigation {
        flex-basis: auto;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--ws-border-dark);
        overflow-y: visible;
    }


    .handbook-content {
        padding: 30px 25px;
        overflow-y: visible;
    }


    .handbook-header {
        padding-right: 20px;
    }


    .archive-info {
        display: none;
    }


    .contact-card {
        grid-template-columns: 1fr;
    }


    .contact-token {
        justify-content: flex-start;
    }


    .contact-heading {
        flex-direction: column;
        gap: 10px;
    }


    .contact-assessment {
        text-align: left;
    }
}


/*
 * =============================================================================
 * UPDATE LOG (most recent first)
 * -----------------------------------------------------------------------------
 * 2026-07-31  Retrofitted the formal file header and this update log
 *             per the project's code documentation standard.
 * 2026-07-31  Pinned the application shell (html/body/.handbook-shell
 *             to viewport height, .handbook-navigation/.handbook-content
 *             independently scrollable) so the header and nav tree stay
 *             in view while a long article scrolls. Reverted at the
 *             700px breakpoint where nav/content stack vertically.
 * -----          Initial version (predates this log).
 * =============================================================================
 */
