/* ==========================================================================
   SHADOWS OF A SILVER SUN — AUTHOR HUB STYLES
   Unified Dual-Orientation Architecture:
   - Square Image for both Landscape & Portrait
   - Three Vertically Stacked Codex Panels alongside image in Landscape
   - Same Vertically Stacked Codex Panels underneath image in Portrait
   ========================================================================== */

/* ── Design Variables & Fonts ─────────────────────────────────────────── */
:root {
    --font-heading: 'Cinzel', 'Playfair Display', 'Libre Bodoni', serif;
    --font-body: 'Lora', 'Georgia', serif;
    --transition: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── 1. Nocturnal Frost Theme (Default / Subtle Cool) ─────────────────── */
:root, [data-theme="frost"] {
    --bg-page: #080d14;
    --bg-card: rgba(13, 20, 30, 0.82);
    --bg-card-hover: rgba(20, 30, 44, 0.94);
    --border-card: rgba(160, 195, 225, 0.35);
    --border-card-hover: rgba(205, 230, 255, 0.82);

    --filigree-inner: rgba(160, 195, 225, 0.22);
    --filigree-inner-hover: rgba(205, 230, 255, 0.55);

    --text-heading: #f0f5fc;
    --text-lead: #c0d0e2;
    --text-desc: #9bb0c8;
    --text-footer: #65778c;

    --gold-primary: #9ec2e6;
    --gold-light: #dce9f8;
    --gold-dark: #507599;
    --gold-glow: rgba(158, 194, 230, 0.32);

    --icon-fill: rgba(160, 195, 225, 0.08);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --modal-bg: #0c121b;
    --modal-border: rgba(160, 195, 225, 0.32);
}

/* ── 2. Candlelight Warm Theme (Subtle Warm) ──────────────────────────── */
[data-theme="candlelight"] {
    --bg-page: #100b08;
    --bg-card: rgba(24, 18, 13, 0.84);
    --bg-card-hover: rgba(38, 27, 19, 0.95);
    --border-card: rgba(229, 169, 59, 0.35);
    --border-card-hover: rgba(245, 215, 127, 0.85);

    --filigree-inner: rgba(229, 169, 59, 0.24);
    --filigree-inner-hover: rgba(245, 215, 127, 0.55);

    --text-heading: #fff4e3;
    --text-lead: #d6c2aa;
    --text-desc: #b8a087;
    --text-footer: #7d6b5c;

    --gold-primary: #e5a93b;
    --gold-light: #fed88b;
    --gold-dark: #a86c12;
    --gold-glow: rgba(229, 169, 59, 0.38);

    --icon-fill: rgba(229, 169, 59, 0.09);

    --border-subtle: rgba(255, 255, 255, 0.07);
    --modal-bg: #19110b;
    --modal-border: rgba(229, 169, 59, 0.35);
}

/* ── 3. High Visibility Black & White Mode (Accessibility) ────────────── */
[data-theme="high-contrast"] {
    --bg-page: #000000;
    --bg-card: #0a0a0a;
    --bg-card-hover: #161616;
    --border-card: #ffffff;
    --border-card-hover: #ffffff;

    --filigree-inner: rgba(255, 255, 255, 0.45);
    --filigree-inner-hover: #ffffff;

    --text-heading: #ffffff;
    --text-lead: #ffffff;
    --text-desc: #f0f0f0;
    --text-footer: #e0e0e0;

    --gold-primary: #ffffff;
    --gold-light: #ffffff;
    --gold-dark: #cccccc;
    --gold-glow: rgba(255, 255, 255, 0.5);

    --icon-fill: rgba(255, 255, 255, 0.15);

    --border-subtle: #ffffff;
    --modal-bg: #000000;
    --modal-border: #ffffff;
}

/* ── Reset & Base Setup ────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-page);
    background-image: radial-gradient(circle at 50% 25%, #0f1826 0%, #06090e 100%);
    color: var(--text-desc);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

[data-theme="candlelight"] body {
    background-image: radial-gradient(circle at 50% 25%, #1c120a 0%, #0a0604 100%);
}

[data-theme="high-contrast"] body {
    background-color: #000000;
    background-image: none;
    color: #ffffff;
}

/* ── Ambient Falling Snow Canvas ───────────────────────────────────────── */
#snowCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Passes all clicks, taps, and mouseover directly through to panels */
    z-index: 20;
    transition: opacity var(--transition);
}

[data-theme="high-contrast"] #snowCanvas {
    display: none;
}

/* Accessible focus ring */
a:focus-visible, button:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--gold-light);
    outline-offset: 3px;
    border-radius: 6px;
}

[data-theme="high-contrast"] a:focus-visible,
[data-theme="high-contrast"] button:focus-visible,
[data-theme="high-contrast"] [tabindex="0"]:focus-visible {
    outline: 3px solid #ffffff !important;
    outline-offset: 4px !important;
}

/* ── Main Layout Container ────────────────────────────────────────────── */
.hub-main {
    position: relative;
    z-index: 2;
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2.5rem 2rem;
}

.hub-container {
    max-width: 1380px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(340px, 48%) 1fr;
    gap: 3.5rem;
    align-items: center;
}

/* ── Left Pane: Square Artwork (Identical Image in Both Modes) ────────── */
.hub-art-pane {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hub-art-wrapper {
    position: relative;
    width: 100%;
    max-width: 580px;
    aspect-ratio: 1 / 1; /* Always 1:1 Square */
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid var(--border-card);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 28px var(--gold-glow), inset 0 0 0 1px var(--filigree-inner);
    transition: border-color var(--transition), box-shadow var(--transition);
}

[data-theme="high-contrast"] .hub-art-wrapper {
    border: 2px solid #ffffff;
    box-shadow: 0 8px 30px rgba(255, 255, 255, 0.25);
}

.hub-art-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none; /* No clickable links on the image */
    transition: opacity 0.4s ease;
}

/* ── Right Pane: The Codex (Vertically Stacked Panels) ─────────────────── */
.hub-codex-pane {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 660px;
    width: 100%;
}

/* "Codex" Header */
.codex-header-block {
    margin-bottom: 1.75rem;
    text-align: center;
}

/* "Codex" sits centred beneath the main title */
.codex-subtitle {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    margin: 0.35rem 0 0;
    padding-left: 0.32em; /* balances trailing letter-spacing so it centres truly */
    opacity: 0.9;
}

[data-theme="high-contrast"] .codex-subtitle {
    color: #ffffff;
    opacity: 1;
}

.codex-main-title {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 700;
    color: #b8e4f5; /* ice blue */
    letter-spacing: 0.08em;
    line-height: 1.15;
    margin-bottom: 0;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7), 0 0 24px var(--gold-glow);
    transition: color var(--transition), text-shadow var(--transition);
}

[data-theme="high-contrast"] .codex-main-title {
    color: #ffffff;
    text-shadow: none;
    font-weight: 800;
}

/* ── Vertically Stacked Panels Stack ──────────────────────────────────── */
.codex-panels-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* Main "Journey into Winter" panel spans the full width */
.codex-panels-stack > .codex-panel:not(.codex-panel--small) {
    grid-column: 1 / -1;
}

/* Maps & Characters: compact half-width tiles, title only */
.codex-panel--small {
    padding: 1.05rem 1.25rem;
    gap: 1rem;
}

.codex-panel--small .panel-icon {
    width: 40px;
    height: 40px;
}

.codex-panel--small .panel-header {
    margin-bottom: 0;
}

/* Individual Panel: Parchment Texture, Themed Wash Overlay, Filigree & Themed Borders */
.codex-panel {
    position: relative;
    background-color: var(--bg-card);
    background-image: 
        radial-gradient(ellipse at 15% 20%, rgba(160, 195, 225, 0.10) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 80%, rgba(74, 111, 148, 0.12) 0%, transparent 65%),
        linear-gradient(135deg, rgba(16, 24, 38, 0.88) 0%, rgba(10, 15, 24, 0.92) 100%),
        url('assets/faded-parchment-1024.webp');
    background-position: center;
    background-size: cover;
    background-blend-mode: screen, multiply, normal, normal;
    border: 1.5px solid var(--border-card);
    border-radius: 9px;
    padding: 1.45rem 1.65rem;
    display: flex;
    align-items: center;
    gap: 1.45rem;
    backdrop-filter: blur(8px);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), inset 0 0 16px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

/* Mouseover Effect (Frost Default) */
.codex-panel:hover {
    transform: translateY(-3px);
    border-color: var(--border-card-hover);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.65), 0 0 24px var(--gold-glow), inset 0 0 22px rgba(160, 195, 225, 0.1);
    background-color: var(--bg-card-hover);
    background-image: 
        radial-gradient(ellipse at 15% 20%, rgba(200, 225, 255, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 80%, rgba(100, 145, 190, 0.20) 0%, transparent 65%),
        linear-gradient(135deg, rgba(22, 33, 48, 0.84) 0%, rgba(14, 21, 32, 0.88) 100%),
        url('assets/faded-parchment-1024.webp');
}

/* Candlelight Panel Background Overrides */
[data-theme="candlelight"] .codex-panel {
    background-color: var(--bg-card);
    background-image: 
        radial-gradient(ellipse at 15% 20%, rgba(229, 169, 59, 0.13) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 80%, rgba(139, 88, 38, 0.16) 0%, transparent 65%),
        linear-gradient(135deg, rgba(38, 26, 17, 0.88) 0%, rgba(20, 14, 9, 0.92) 100%),
        url('assets/faded-parchment-1024.webp');
}

[data-theme="candlelight"] .codex-panel:hover {
    background-color: var(--bg-card-hover);
    background-image: 
        radial-gradient(ellipse at 15% 20%, rgba(254, 216, 139, 0.20) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 80%, rgba(180, 115, 50, 0.22) 0%, transparent 65%),
        linear-gradient(135deg, rgba(48, 32, 20, 0.84) 0%, rgba(26, 17, 10, 0.88) 100%),
        url('assets/faded-parchment-1024.webp');
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.65), 0 0 24px var(--gold-glow), inset 0 0 22px rgba(229, 169, 59, 0.1);
}

/* High Visibility Black & White Panel Overrides */
[data-theme="high-contrast"] .codex-panel {
    background-color: #0c0c0c;
    background-image: none;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
}

[data-theme="high-contrast"] .codex-panel:hover {
    background-color: #1a1a1a;
    background-image: none;
    border-color: #ffffff;
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.5), inset 0 0 8px rgba(255, 255, 255, 0.2);
}

/* Filigree Inner Inset Frame */
.codex-panel::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid var(--filigree-inner);
    border-radius: 6px;
    pointer-events: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.codex-panel:hover::before {
    border-color: var(--filigree-inner-hover);
    box-shadow: inset 0 0 14px var(--gold-glow);
}

[data-theme="high-contrast"] .codex-panel::before {
    border: 1px solid rgba(255, 255, 255, 0.4);
}

[data-theme="high-contrast"] .codex-panel:hover::before {
    border-color: #ffffff;
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.2);
}

/* Filigree Corner Flourishes (Frost Default) */
.codex-panel::after {
    content: "";
    position: absolute;
    inset: 3px;
    pointer-events: none;
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 20V7a5 5 0 0 1 5-5h13' stroke='%23a0c3e1' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M5 16V9a4 4 0 0 1 4-4h7' stroke='%23dce9f8' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='9' cy='9' r='1.2' fill='%23a0c3e1'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 20V7a5 5 0 0 0-5-5H8' stroke='%23a0c3e1' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M23 16V9a4 4 0 0 0-4-4h-7' stroke='%23dce9f8' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='19' cy='9' r='1.2' fill='%23a0c3e1'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 8v13a5 5 0 0 0 5 5h13' stroke='%23a0c3e1' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M5 12v7a4 4 0 0 0 4 4h7' stroke='%23dce9f8' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='9' cy='19' r='1.2' fill='%23a0c3e1'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 8v13a5 5 0 0 1-5 5H8' stroke='%23a0c3e1' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M23 12v7a4 4 0 0 1-4 4h-7' stroke='%23dce9f8' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='19' cy='19' r='1.2' fill='%23a0c3e1'/%3E%3C/svg%3E");
    background-position: top left, top right, bottom left, bottom right;
    background-repeat: no-repeat;
    opacity: 0.72;
    transition: opacity var(--transition), filter var(--transition);
}

.codex-panel:hover::after {
    opacity: 1;
    filter: drop-shadow(0 0 5px var(--gold-glow));
}

/* Filigree Corner Flourishes (Candlelight Warm Theme) */
[data-theme="candlelight"] .codex-panel::after {
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 20V7a5 5 0 0 1 5-5h13' stroke='%23e5a93b' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M5 16V9a4 4 0 0 1 4-4h7' stroke='%23fed88b' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='9' cy='9' r='1.2' fill='%23e5a93b'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 20V7a5 5 0 0 0-5-5H8' stroke='%23e5a93b' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M23 16V9a4 4 0 0 0-4-4h-7' stroke='%23fed88b' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='19' cy='9' r='1.2' fill='%23e5a93b'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 8v13a5 5 0 0 0 5 5h13' stroke='%23e5a93b' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M5 12v7a4 4 0 0 0 4 4h7' stroke='%23fed88b' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='9' cy='19' r='1.2' fill='%23e5a93b'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 8v13a5 5 0 0 1-5 5H8' stroke='%23e5a93b' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M23 12v7a4 4 0 0 1-4 4h-7' stroke='%23fed88b' stroke-width='0.8' stroke-linecap='round' opacity='0.7'/%3E%3Ccircle cx='19' cy='19' r='1.2' fill='%23e5a93b'/%3E%3C/svg%3E");
}

/* Filigree Corner Flourishes (High Visibility Black & White Mode) */
[data-theme="high-contrast"] .codex-panel::after {
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 20V7a5 5 0 0 1 5-5h13' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M5 16V9a4 4 0 0 1 4-4h7' stroke='%23ffffff' stroke-width='1' stroke-linecap='round' opacity='0.9'/%3E%3Ccircle cx='9' cy='9' r='1.5' fill='%23ffffff'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 20V7a5 5 0 0 0-5-5H8' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M23 16V9a4 4 0 0 0-4-4h-7' stroke='%23ffffff' stroke-width='1' stroke-linecap='round' opacity='0.9'/%3E%3Ccircle cx='19' cy='9' r='1.5' fill='%23ffffff'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M2 8v13a5 5 0 0 0 5 5h13' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M5 12v7a4 4 0 0 0 4 4h7' stroke='%23ffffff' stroke-width='1' stroke-linecap='round' opacity='0.9'/%3E%3Ccircle cx='9' cy='19' r='1.5' fill='%23ffffff'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28' fill='none'%3E%3Cpath d='M26 8v13a5 5 0 0 1-5 5H8' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M23 12v7a4 4 0 0 1-4 4h-7' stroke='%23ffffff' stroke-width='1' stroke-linecap='round' opacity='0.9'/%3E%3Ccircle cx='19' cy='19' r='1.5' fill='%23ffffff'/%3E%3C/svg%3E");
    opacity: 0.9;
}

[data-theme="high-contrast"] .codex-panel:hover::after {
    filter: drop-shadow(0 0 6px #ffffff);
}

/* Panel Gold SVG Icon */
.panel-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55));
    transition: transform var(--transition), filter var(--transition);
}

.panel-icon svg defs linearGradient stop {
    transition: stop-color var(--transition);
}

.panel-icon svg defs linearGradient stop:nth-child(1) {
    stop-color: var(--gold-light);
}
.panel-icon svg defs linearGradient stop:nth-child(2) {
    stop-color: var(--gold-primary);
}
.panel-icon svg defs linearGradient stop:nth-child(3) {
    stop-color: var(--gold-dark);
}

.codex-panel:hover .panel-icon svg {
    filter: drop-shadow(0 0 12px var(--gold-glow));
    transform: scale(1.05);
}

/* High Visibility Icon Styling */
[data-theme="high-contrast"] .panel-icon svg path,
[data-theme="high-contrast"] .panel-icon svg circle,
[data-theme="high-contrast"] .panel-icon svg polygon {
    stroke: #ffffff !important;
}

[data-theme="high-contrast"] .panel-icon svg [fill]:not([fill="none"]):not([class~="map-compass-center"]) {
    fill: rgba(255, 255, 255, 0.16) !important;
}

[data-theme="high-contrast"] .panel-icon svg .map-compass-center {
    fill: #000000 !important;
    stroke: #ffffff !important;
}

[data-theme="high-contrast"] .codex-panel:hover .panel-icon svg {
    filter: drop-shadow(0 0 10px #ffffff);
}

/* Panel Content Body */
.panel-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.32rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: 0.03em;
    transition: color var(--transition), text-shadow var(--transition);
}

.codex-panel:hover .panel-title {
    color: var(--gold-light);
    text-shadow: 0 0 14px var(--gold-glow);
}

.panel-desc {
    font-family: var(--font-body);
    font-size: 0.94rem;
    line-height: 1.62;
    color: var(--text-lead);
    margin-bottom: 0;
    transition: color var(--transition);
}

.codex-panel:hover .panel-desc {
    color: var(--text-heading);
}

[data-theme="high-contrast"] .panel-title {
    color: #ffffff;
    font-weight: 700;
}

[data-theme="high-contrast"] .codex-panel:hover .panel-title {
    color: #ffffff;
    text-decoration: underline;
    text-shadow: none;
}

[data-theme="high-contrast"] .panel-desc {
    color: #f0f0f0;
    font-size: 0.98rem;
    line-height: 1.65;
}

[data-theme="high-contrast"] .codex-panel:hover .panel-desc {
    color: #ffffff;
}

/* ── Bottom Footer Row ────────────────────────────────────────────────── */
.hub-bottom-bar {
    width: 100%;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    transition: border-color var(--transition);
}

.footer-copy {
    font-size: 0.82rem;
    color: var(--text-footer);
    transition: color var(--transition);
}

.footer-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.footer-action-link {
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.84rem;
    color: var(--text-lead);
    cursor: pointer;
    text-decoration: none;
    transition: color var(--transition), background-color var(--transition), border-color var(--transition);
    padding: 0.25rem 0.45rem;
    border-radius: 4px;
}

.footer-action-link:hover {
    color: var(--gold-light);
}

.theme-toggle-mini {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-lead);
    min-width: 36px;
    height: 32px;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle-mini:hover {
    border-color: var(--gold-primary);
    color: var(--gold-light);
    box-shadow: 0 0 10px var(--gold-glow);
}

/* High Visibility Footer Overrides */
[data-theme="high-contrast"] .hub-bottom-bar {
    border-top: 2px solid #ffffff;
}

[data-theme="high-contrast"] .footer-copy {
    color: #e0e0e0;
    font-weight: 500;
}

[data-theme="high-contrast"] .footer-action-link {
    color: #ffffff;
    font-weight: 600;
    border: 1px solid #ffffff;
    border-radius: 4px;
    padding: 0.35rem 0.65rem;
}

[data-theme="high-contrast"] .footer-action-link:hover {
    background: #ffffff;
    color: #000000;
}

[data-theme="high-contrast"] .theme-toggle-mini {
    background: #000000;
    border: 2px solid #ffffff;
    color: #ffffff;
    font-size: 1rem;
    font-weight: bold;
}

[data-theme="high-contrast"] .theme-toggle-mini:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
    box-shadow: 0 0 12px #ffffff;
}

/* ── Modals (Support & Author Tools) ──────────────────────────────────── */
.hub-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.hub-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.hub-modal {
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
    max-width: 520px;
    width: 100%;
    padding: 2rem;
    position: relative;
    transform: translateY(12px) scale(0.98);
    transition: transform var(--transition);
    color: var(--text-heading);
}

.hub-modal-overlay.active .hub-modal {
    transform: translateY(0) scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-lead);
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--gold-light);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    color: var(--gold-light);
    margin-bottom: 0.5rem;
}

.modal-header p {
    font-size: 0.9rem;
    color: var(--text-lead);
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.modal-links-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-link-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.15rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-heading);
    text-decoration: none;
    transition: all var(--transition);
}

.modal-link-item:hover {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--gold-primary);
    transform: translateX(3px);
}

.modal-link-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.modal-link-title {
    font-weight: 600;
    font-size: 0.98rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-link-desc {
    font-size: 0.82rem;
    color: var(--text-lead);
}

.modal-link-arrow {
    font-size: 1.1rem;
    color: var(--gold-primary);
}

/* High Visibility Modal Overrides */
[data-theme="high-contrast"] .hub-modal-overlay {
    background: rgba(0, 0, 0, 0.92);
}

[data-theme="high-contrast"] .hub-modal {
    background: #000000;
    border: 2px solid #ffffff;
    box-shadow: 0 0 35px rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

[data-theme="high-contrast"] .modal-close-btn {
    color: #ffffff;
    font-size: 2rem;
}

[data-theme="high-contrast"] .modal-close-btn:hover {
    color: #ffffff;
    text-shadow: 0 0 8px #ffffff;
}

[data-theme="high-contrast"] .modal-header h3 {
    color: #ffffff;
    font-weight: 700;
}

[data-theme="high-contrast"] .modal-header p {
    color: #f0f0f0;
    font-size: 0.95rem;
}

[data-theme="high-contrast"] .modal-link-item {
    background: #000000;
    border: 2px solid #ffffff;
    color: #ffffff;
}

[data-theme="high-contrast"] .modal-link-item:hover {
    background: #ffffff;
    color: #000000;
}

[data-theme="high-contrast"] .modal-link-item:hover .modal-link-title,
[data-theme="high-contrast"] .modal-link-item:hover .modal-link-desc,
[data-theme="high-contrast"] .modal-link-item:hover .modal-link-arrow {
    color: #000000 !important;
}

[data-theme="high-contrast"] .modal-link-desc {
    color: #e0e0e0;
}

[data-theme="high-contrast"] .modal-link-arrow {
    color: #ffffff;
}

/* ==========================================================================
   PORTRAIT PHONE LAYOUT
   Activated when viewport width is <= 960px or portrait orientation
   - Uses the EXACT same square image
   - Uses the EXACT same 3 vertically stacked panels below the image
   ========================================================================== */
@media (max-width: 960px), (orientation: portrait) and (max-width: 1024px) {
    .hub-main {
        padding: 1.75rem 1.25rem 2.5rem;
        align-items: flex-start;
    }

    .hub-container {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        max-width: 580px;
    }

    /* Square Image centered at top */
    .hub-art-pane {
        width: 100%;
    }

    .hub-art-wrapper {
        max-width: 440px;
        margin: 0 auto;
        border-radius: 10px;
    }

    /* Codex Pane below image */
    .hub-codex-pane {
        max-width: 100%;
        padding: 0;
    }

    .codex-header-block {
        margin-bottom: 1.25rem;
    }

    .codex-main-title {
        font-size: 2.3rem;
        margin-bottom: 0;
    }

    .codex-panels-stack {
        gap: 1rem;
        margin-bottom: 1.75rem;
    }

    .codex-panel {
        padding: 1.2rem 1.25rem;
        gap: 1.15rem;
    }

    .panel-icon {
        width: 44px;
        height: 44px;
    }

    .panel-title {
        font-size: 1.2rem;
    }

    .panel-desc {
        font-size: 0.88rem;
    }

    .hub-bottom-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .footer-actions {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .hub-art-wrapper {
        max-width: 100%;
    }

    .codex-main-title {
        font-size: 2rem;
    }

    .codex-panel {
        padding: 1.05rem 1.1rem;
        gap: 0.95rem;
    }

    .panel-icon {
        width: 40px;
        height: 40px;
    }

    .panel-title {
        font-size: 1.15rem;
    }

    .panel-desc {
        font-size: 0.84rem;
        margin-bottom: 0;
    }
}

/* Phones: stack icon above title in the half-width tiles so long words fit */
@media (max-width: 600px) {
    .codex-panel--small {
        flex-direction: column;
        text-align: center;
        gap: 0.55rem;
        padding: 1rem 0.75rem;
    }

    .codex-panel--small .panel-header {
        justify-content: center;
    }

    .codex-panel--small .panel-title {
        font-size: 1.1rem;
    }
}
