/* ==========================================================================
   1. CORE VARIABLES (THE PALETTE)
   ========================================================================== */

/* DEFAULT DARK THEME */
:root,
:root[data-theme="dark"] {
    /* Backgrounds */
    --bg-main: #121416;
    --bg-card: #1D2124;
    /* Borders */
    --border-color: #38332B;
    /* Typography */
    --text-primary: #F1EBDD;
    --text-muted: #C5B99F;
    /* Accents */
    --accent-color: #D6AD48;
    --accent-hover: #E9C66D;
    /* Navigation */
    --header-bg: #1D2124;
    --menu-bg: #181B1E;
    --menu-hover: #292D30;
    --footer-bg: #1D2124;
    /* Typography */
    --font-main: 'Georgia', 'Times New Roman', serif;
    /* Layout */
    --main-header-height: 40px;
    --subheader-height: 40px;
    --footer-height: 40px;
    --menu-background: #1a1a1a;
    --menu-text: #ffffff;
    --menu-border: #2a2a2a;
    --menu-hover: #333333;
}


/* LIGHT THEME */
:root[data-theme="light"] {
    --bg-main: #f8f6f1;
    --bg-card: #ffffff;
    --border-color: #d6cbb8;
    --text-primary: #25221e;
    --text-muted: #62594d;
    --accent-color: #a87900;
    --accent-hover: #c18e00;
    --header-bg: #eee9df;
    --menu-bg: #ffffff;
    --menu-hover: #eee9df;
    --footer-bg: #eee9df;
    --font-main: 'Georgia', 'Times New Roman', serif;
    --main-header-height: 40px;
    --subheader-height: 40px;
    --footer-height: 40px;
    --menu-background: #ffffff;
    --menu-text: #222222;
    --menu-border: #dddddd;
    --menu-hover: #eeeeee;
}


/* ========================================================================== 
   2. GLOBAL RESETS & NAVIGATION LAYOUT 
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    overflow: hidden !important; /* Locks window canvas scrollbars completely */
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1.8;
    font-family: var(--font-main);
    line-height: 1.7;
}

html {
    font-size: 14px;
    scroll-behavior: auto;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* --- FIXED HEADERS ENGINE --- */

/* Fixed Header Base Configuration */
.main-fixed-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--main-header-height);
    background-color: var(--header-bg);
    z-index: 2000 !important;
    box-sizing: border-box;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    position: relative;
}

header-spacer
/* 1. HIDE IT EVERYWHERE BY DEFAULT */
.secondary-header {
    display: none !important;
}

/* 2. FORCE IT TO VISIBLE ONLY INSIDE SUBPAGE CONTEXT */
body.subpage-layout .secondary-header {
    display: flex !important;
    position: fixed !important;
    top: var(--main-header-height) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--subheader-height) !important;
    background-color: var(--bg-main) !important;
    border-bottom: 1px solid var(--border-color);
    z-index: 1900 !important;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.header-stack-wrapper {
    flex-shrink: 0;
    width: 100%;
    z-index: 1000;
}



/* By default, hide the secondary header entirely */
.secondary-header {
    display: none !important;
}

/* Only show the secondary header when inside a subpage layout layout context */
body.subpage-layout .secondary-header {
    display: flex !important; /* Restores the header alignment styles perfectly */
    position: fixed !important;
    top: var(--main-header-height) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--subheader-height);
    background-color: var(--bg-main) !important;
    border-bottom: 1px solid var(--border-color);
    z-index: 1900 !important;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}


body:has(.secondary-header) .main-content-container {
    padding-top: calc(var(--main-header-height) + var(--subheader-height));
}

/* --- ISOLATED VIEWPORT BODY SCROLL --- */
/* Create a flex column that takes up exactly 100% of the screen height */
.app-viewport {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
}

.main-scroll-content {
    height: calc(100vh - var(--main-header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: absolute !important;
    left: 0;
    right: 0;
    -ms-overflow-style: none;
    flex-grow: 1;
    overflow-y: auto; /* Content scrolls inside here, NOT the browser */
    width: 100%;
    padding-top: 20px;
    padding-bottom: 20px;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
    scroll-behavior: auto !important;
}

/* Homepage dynamic padding offset */
body.layout-container .main-scroll-content {
    top: var(--main-header-height) !important;
    height: calc(100vh - var(--main-header-height) - var(--footer-height)) !important;
}

/* Subpage dynamic padding offset */
body.subpage-layout .main-scroll-content {
    top: calc(var(--main-header-height) + var(--subheader-height)) !important;
    height: calc(100vh - var(--main-header-height) - var(--subheader-height) - var(--footer-height)) !important;
}

.main-content-container {
    height: calc(100vh - var(--main-header-height));
    overflow-y: auto; /* Only this specific region scrolls */
    box-sizing: border-box;
}

/* Optional: WebKit scrollbar styling (Chrome, Edge, Safari) */ 
.main-scroll-webkit-scrollbar {
    width: 12px;
}

.main-scroll-webkit-scrollbar-track {
    background: transparent;
}

.main-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.4);
    border-radius: 6px;
    border: 3px solid transparent;
    background-clip: padding-box;
}


/* Fixed Footer Configuration */
.app-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--footer-height);
    line-height: calc(var(--footer-height) - 5px);
    background-color: var(--footer-bg);
    color: var(--text-primary);
    z-index: 2000 !important;
}

/* Fixed Footer Configuration */
/*.app-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--footer-height);
    line-height: calc(var(--footer-height) - 5px);
    background-color: #333;
    z-index: 2000 !important;
}*/

/* Brand, typography, and focus resets */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}


.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}




h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: normal; /* Classic literary styling uses lighter font weights */
    letter-spacing: 0.02em;
    margin-top: 0;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}


#brand-title {
    margin: 0;
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
}


#header-text {
    display: inline-block;
    padding-top: 8px;
    padding-left: 20px;
}



#footer-text {
    display: inline-block;
    padding-left: 20px;
}

#privacy-link {
    display: inline-block;
    padding-right: 20px;
}


/* Fixed Footer Configuration */
/*.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--footer-height);*/ /* Control footer height */
    /*background-color: #333;
    color: #333;
    z-index: 1000;
}*/


.section-wrapper {
    scroll-margin-top: var(--main-header-height); /* Match your sticky header height */
}

/* Keep section headings closer to their content */
.section-wrapper h2 {
    margin-bottom: 0.5rem;
}

/* Control spacing around horizontal dividers */
hr {
    margin: 1rem 0;
}

.newsletter-section {
    scroll-margin-top: var(--main-header-height); /* Match your sticky header height */
}

.section-subtitle {
    text-indent: 2ch;
}

/* ==========================================================================
   3. RESPONSIVE TWO-COLUMN SIDEBAR LAYOUT
   ========================================================================== */
.layout-container {
    display: grid;
    grid-template-rows: auto 1fr auto; /* Header (auto), Content (fills remaining), Footer (auto) */
    flex-direction: column; /* Default vertical stack for mobile phones */
    height: auto;
    gap: 1rem;
    max-width: 1100px;
    margin: 1rem auto;
    padding-left: 1.5rem
}

.sidebar {
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.sidebar h3 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 0.75rem;
}

.sidebar a {
    color: var(--text-muted);
    cursor: pointer;
}

.sidebar a:hover {
    color: var(--accent-color);
}

.content-area {
    width: 100%;
    max-width: 65ch; /* Locks reading text width to prevent eye tracking fatigue */
    margin: 0 auto;
}


/* ==========================================================================
   4. PURE CSS RESPONSIVE BOOK GRID
   ========================================================================== */

/* 1. Main Container: Enforces a strict, centered single-column layout */
#live-book-grid.book-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 2.5rem;
    max-width: 650px; /* Kept narrow so text doesn't stretch out too wide */
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* 2. Individual Cards: Stacked vertically by default (Mobile Layout) */
#live-book-grid .book-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #ffffff;
    box-sizing: border-box;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none; /* Clears default underline styles if wrapped in an anchor */
    color: inherit; /* Keeps your standard text colors intact */
}

/* Adds a clean interactive hover feedback effect */
#live-book-grid .book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 3. Hide the Amazon Buy Button entirely */
#live-book-grid .buy-button {
    display: none !important;
}

/* 4. Element Reordering: Forces specific items below the picture */
#live-book-grid .book-cover {
    order: 1; /* First element: Image */
    width: 100%;
    max-width: 220px; /* Keeps the book cover crisp and uniformly sized */
    height: auto;
    margin: 0 auto 1.25rem auto; /* Centers the cover and adds spacing below */
    border-radius: 4px;
}

#live-book-grid .book-title {
    order: 3; /* Third element: Main book title */
    text-align: center;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

#live-book-grid small {
    order: 2; /* Second element: Series title */
    display: block;
    text-align: center;
    margin-bottom: 0.25rem;
}

#live-book-grid .book-description {
    order: 4; /* Fourth element: Summary description text */
    text-align: left; /* Kept left-aligned for easier reading */
    margin: 0;
    line-height: 1.6;
}

/* 5. Wide Screen Switch (Desktop Layout) */
@media (min-width: 600px) {
    /* If you want the summary text to shift to the right side on wide viewports, 
       while leaving the image and titles neatly stacked on the left: */
    #live-book-grid .book-card {
        display: grid;
        grid-template-columns: 220px 1fr; /* 220px left column, remaining space right */
        gap: 2rem;
    }

    #live-book-grid .book-cover {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 0.5rem;
    }

    #live-book-grid small {
        grid-column: 1;
        grid-row: 2;
        text-align: center;
    }

    #live-book-grid .book-title {
        grid-column: 1;
        grid-row: 3;
        text-align: center;
        margin-bottom: 0;
    }

    #live-book-grid .book-description {
        grid-column: 2;
        grid-row: 1 / span 3; /* Stretches the text to occupy the full right height */
        align-self: start;
    }
}

.book-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3; /* Matches physical book dimensions */
    background-color: var(--bg-main);
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.book-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.book-description {
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    flex-grow: 1; /* Aligns all buy buttons perfectly along the bottom row */
    display: block;
    position: static;
    order: initial;
    margin-top: 0;
}

.book-introduction {
    display: block;
    position: static;
    order: initial;
    overflow: hidden;
    margin: 8px 0;
    line-height: 1.4;
}

.buy-button {
    grid-row: 3;
    align-self: end;
}

.buy-button:hover {
    background-color: var(--accent-color);
    color: var(--bg-main); /* Flips typography text color against the golden background */
}


/* ========================================================
   BOOK CATALOG RENDERING FIX
   ======================================================== */
.book-card, a.book-card {
    /* Changes background from browser default white to dark obsidian */
    background-color: var(--bg-card, #18130f) !important;
    /* Applies a solid 2-pixel wide leather/bronze themed border outline */
    border: 2px solid var(--border-color, #42352b) !important;
    /* Text color and decoration resets */
    color: var(--text-primary, #ffffff) !important;
    text-decoration: none !important;
}

/* ==========================================================================
   RESPONSIVE BOOK CATALOG
   ========================================================================== */

/* Main book grid */
#live-book-grid.book-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Individual book cards */
#live-book-grid .book-card {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 2rem;
    width: 100%;
    padding: 2rem;
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 2px solid var(--border-color) !important;
    border-radius: 10px;
    text-decoration: none !important;
    box-sizing: border-box;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

    /* Card hover */
    #live-book-grid .book-card:hover {
        transform: translateY(-3px);
        border-color: var(--accent-color) !important;
        box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
    }

/* --------------------------------------------------
   LEFT COLUMN: BOOK COVER ONLY
   -------------------------------------------------- */

#live-book-grid .book-media-column {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
}

#live-book-grid .book-cover {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    margin: 0 !important;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

/* --------------------------------------------------
   RIGHT COLUMN: TITLE, SERIES AND TEXT
   -------------------------------------------------- */

#live-book-grid .book-content-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

/* Title and series */
#live-book-grid .book-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Main book title */
#live-book-grid .book-title {
    display: block;
    width: 100%;
    max-width: 100%;
    font-size: clamp(2rem, 3vw, 2.8rem);
    line-height: 1.2;
    font-weight: bold;
    text-align: center;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    overflow-wrap: break-word;
}

/* Series name */
#live-book-grid .book-series {
    display: block;
    font-size: 1.3rem;
    line-height: 1.4;
    font-style: italic;
    text-align: center;
    color: var(--text-muted);
    margin: 0;
}

/* --------------------------------------------------
   DESCRIPTION AND INTRODUCTION
   -------------------------------------------------- */

#live-book-grid .book-text-content {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Book description */
#live-book-grid .book-description {
    display: block;
    font-size: 1.25rem;
    line-height: 1.7;
    font-weight: normal;
    color: var(--text-primary);
    text-align: left;
    margin: 0 0 1.25rem 0;
}

/* Introduction */
#live-book-grid .book-introduction {
    display: block;
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--text-primary);
    text-align: left;
    margin: 0;
    overflow: hidden;
}

    /* Introduction label */
    #live-book-grid .book-introduction strong {
        color: var(--accent-color);
    }

/* Hide Amazon button */
#live-book-grid .buy-button {
    display: none !important;
}

/* ==========================================================================
   MOBILE BOOK CARD LAYOUT
   ========================================================================== */

@media (max-width: 599px) {

    #live-book-grid .book-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        padding: 1.25rem;
    }

    /* Image at the top */
    #live-book-grid .book-media-column {
        width: 100%;
        justify-content: center;
    }

    #live-book-grid .book-cover {
        width: 65%;
        max-width: 240px;
        margin: 0 auto !important;
    }

    /* All text below image */
    #live-book-grid .book-content-column {
        width: 100%;
    }

    #live-book-grid .book-heading {
        margin-bottom: 1.25rem;
    }

    #live-book-grid .book-title {
        font-size: 2rem;
    }

    #live-book-grid .book-series {
        font-size: 1.15rem;
    }

    #live-book-grid .book-description {
        font-size: 1.15rem;
    }

    #live-book-grid .book-introduction {
        font-size: 1.1rem;
    }
}

/* ==========================================================================
   INTERMEDIATE SCREEN SIZES
   ========================================================================== */

@media (min-width: 600px) and (max-width: 850px) {

    #live-book-grid .book-card {
        grid-template-columns: 180px minmax(0, 1fr);
        gap: 1.5rem;
        padding: 1.5rem;
    }

    #live-book-grid .book-title {
        font-size: 2rem;
    }

    #live-book-grid .book-description {
        font-size: 1.1rem;
    }

    #live-book-grid .book-introduction {
        font-size: 1.05rem;
    }
}


/* ========================================================
DYNAMIC CARD INTERACTION: BRIGHTEN BORDER ON MOUSE OVER
======================================================== */
.book-card:hover, a.book-card:hover {
    /* Muted gold with built-in transparency to blend into the black background */
    border-color: #8c7355aa !important;
    /* Adds a soft, smoky lighting transition speed change */
    transition: border-color 0.1s ease-in-out !important;
}

/* ==========================================================
   FINAL BOOK CATALOG ORDER OVERRIDES
   ========================================================== */

/* Keep title above series */
#live-book-grid .book-heading {
    display: flex !important;
    flex-direction: column !important;
}

#live-book-grid .book-title {
    order: 1 !important;
}

#live-book-grid .book-series {
    order: 2 !important;
}

/* Keep description above introduction */
#live-book-grid .book-text-content {
    display: flex !important;
    flex-direction: column !important;
}

#live-book-grid .book-description {
    order: 1 !important;
}

#live-book-grid .book-introduction {
    order: 2 !important;
}

/* Preserve mobile stacking */
@media (max-width: 599px) {
    #live-book-grid .book-card {
        display: flex !important;
        flex-direction: column !important;
    }

    #live-book-grid .book-media-column {
        order: 1 !important;
    }

    #live-book-grid .book-content-column {
        order: 2 !important;
    }
}


/* ==========================================================================
   FREE CONTENT STORY GRID
   ========================================================================== */

#live-free-content-grid.free-content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 850px;
    width: 100%;
    margin: 1.5rem auto;
    box-sizing: border-box;
}

#live-free-content-grid .free-content-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem;
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

    #live-free-content-grid .free-content-card:hover {
        border-color: var(--accent-color);
        transform: translateY(-2px);
    }

/* Free Content Card Typography */

#live-free-content-grid .free-content-title {
    font-size: 2rem;
    line-height: 1.2;
    font-weight: bold;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

#live-free-content-grid .free-content-summary {
    font-size: 1.25rem;
    line-height: 1.7;
    margin: 0 0 0.75rem;
    color: var(--text-muted);
}

#live-free-content-grid .free-content-card-navigation a {
    font-size: 1.2rem;
}

#live-free-content-grid .free-content-latest-link {
    font-size: 1.2rem;
}

#live-free-content-grid .free-content-chapter-title {
    font-size: 1.2rem;
    line-height: 1.5;
}

#live-free-content-grid .free-content-date {
    font-size: 1rem;
}

.free-content-latest-heading {
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
    color: var(--accent-color);
}

.free-content-chapter-title {
    margin: 0;
    font-size: 1.05rem;
}

.free-content-chapter-blurb {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.free-content-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.free-content-read-link {
    display: inline-block;
    align-self: flex-start;
    margin-top: 0.5rem;
    color: var(--accent-color);
}

.free-content-card:hover .free-content-read-link {
    color: var(--accent-hover);
}

@media (min-width: 600px) {
    #live-free-content-grid.free-content-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


.free-content-card-navigation {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 1rem;
}

    .free-content-card-navigation a,
    .free-content-latest-link {
        color: var(--accent-color);
        text-decoration: none;
        font-weight: 600;
    }

        .free-content-card-navigation a:hover,
        .free-content-latest-link:hover {
            text-decoration: underline;
        }

.free-content-latest-box {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.free-content-latest-link {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.free-content-latest-box .free-content-chapter-title {
    margin: 0.25rem 0;
    font-weight: 600;
}

.free-content-latest-box .free-content-date {
    display: block;
    font-size: 0.85rem;
    opacity: 0.75;
    margin-top: 0.35rem;
}


.free-content-latest-box {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

    .free-content-latest-box:hover {
        border-color: var(--accent-color);
        transform: translateY(-2px);
    }

    .free-content-latest-box a:hover {
        text-decoration: underline;
    }

.free-content-chapter {
    scroll-margin-top: calc( var(--main-header-height) + var(--subheader-height) + 20px );
}

/* ==========================================================================
   5. SEMANTIC NEWSLETTER SIGN-UP CARD
   ========================================================================== */

.newsletter-section {
    margin: 5rem auto;
    max-width: 65ch;
}

.newsletter-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2.5rem;
    text-align: center;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

#subscriber-email {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: var(--font-main);
    font-size: 1rem;
    flex-grow: 1;
}

#subscriber-email:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15); /* Soft gold halo focus effect */
}

#submit-btn {
    background-color: var(--accent-color);
    color: var(--bg-main);
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

#submit-btn:hover {
    background-color: var(--accent-hover);
}

.hidden-field {
    display: none;
}

.form-message {
    font-size: 0.95rem;
    margin-top: 1rem;
    display: none;
}

.form-message.success {
    color: #27ae60;
    display: block;
}

.form-message.error {
    color: #eb5757;
    display: block;
}


/* ==========================================================================
   6. LARGESCREEN / DESKTOP WIDESCREEN ENHANCEMENTS
   ========================================================================== */

@media (min-width: 769px) {
    body {
        padding: 3rem;
    }

    .layout-container {
        flex-direction: row; /* Shifts serial text and menu sidebar side-by-side */
        gap: 4rem;
    }

    .sidebar {
        width: 250px;
        flex-shrink: 0;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding-bottom: 0;
        padding-right: 2rem;
        position: sticky; /* Keeps the table of contents floating as the user scrolls text */
        top: 3rem;
    }

    .form-group {
        flex-direction: row; /* Email input and button snap horizontal on desktop */
    }
}


/* ==========================================
   Pure CSS Checkbox Engine & Animations
   ========================================== */
.menu-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Three line icon building block */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 18px;
    cursor: pointer;
    z-index: 1002;
}

.hamburger .bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #ffffff;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile Dropdown Styling Configuration */
.menu-links {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--menu-bg) !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.menu-links a, div.menu-links a {
    color: var(--text-primary) !important;
    text-decoration: none;
    padding: 1rem 2rem;
    border-bottom: 1px solid #2a2a2a;
    transition: background 0.2s ease;
}

.menu-links a:hover {
    background-color: var(--menu-hover) !important;
}

/* ==========================================
   Interactive Interaction State (Checked)
   ========================================== */

/* Toggle menu slide down visibility */
.menu-toggle:checked ~ .menu-links {
    max-height: 400px; /* Safe bounds to display your links */
}

/* Transform icon to dynamic close dynamic visual */
.menu-toggle:checked ~ .hamburger .bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.menu-toggle:checked ~ .hamburger .bar:nth-child(2) {
    opacity: 0;
}

.menu-toggle:checked ~ .hamburger .bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ==========================================
   Responsive Viewport Scaling Framework
   ========================================== */
/* ==========================================
   HEADER LAYOUT - ALL SCREEN SIZES
   ========================================== */
@media (min-width: 768px) {
    .hamburger {
        display: flex !important;
    }

    .header-spacer {
        display: none !important;
    }
}


.subpage-content {
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
}

.subpage-content .markdown-viewer {
    scroll-margin-top: calc( var(--main-header-height) + var(--sub-header-height) + 16px );
}

/* Book-style paragraph formatting */
.subpage-content .markdown-viewer p {
    text-indent: 2em;
    margin-top: 0;
    margin-bottom: 0;
    font-size: inherit;
    line-height: 1.8;
}


/* ==========================================================
   GLOBAL FIX: Navigation links should only be as wide as text
   ========================================================== */

a.subpage-navigation-link {
    display: inline-block !important;
    width: fit-content !important;
    max-width: 100%;
    flex: 0 0 auto !important;
    justify-self: start;
    align-self: start;
    box-sizing: border-box;
}

/* Keep navigation links compact inside all content sections */
.layout-container > a.subpage-navigation-link {
    width: fit-content !important;
    justify-self: start;
    align-self: start;
}


.chapter-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

    .chapter-navigation a {
        font-size: 0.9rem;
        text-decoration: none;
    }

        .chapter-navigation a:hover {
            text-decoration: underline;
        }



/* Mobile pull-to-refresh indicator */
#pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transform: translate(-50%, -60px);
    pointer-events: none;
    transition: opacity 0.15s ease;
}

    #pull-refresh-indicator.visible {
        opacity: 1;
    }

    #pull-refresh-indicator .refresh-circle {
        width: 23px;
        height: 23px;
        border: 3px solid #d8d8d8;
        border-top-color: #1877f2;
        border-radius: 50%;
    }

    #pull-refresh-indicator.refreshing .refresh-circle {
        animation: pull-refresh-spin 0.7s linear infinite;
    }

@keyframes pull-refresh-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    #pull-refresh-indicator.refreshing .refresh-circle {
        animation-duration: 1.5s;
    }
}

/* ==========================================================================
   HAMBURGER MENU - LIGHT / DARK MODE SWITCH
   ========================================================================== */

.theme-switch-container {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.8rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    gap: 0.8rem;
}

.theme-switch-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    padding: 0.9rem 1rem;
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

    .theme-toggle:hover {
        background-color: var(--menu-hover);
        border-color: var(--accent-color);
    }

#theme-icon {
    color: var(--accent-color);
    font-size: 1.4rem;
    line-height: 1;
}

#theme-text {
    color: var(--text-primary);
}


/* Smooth theme transitions */

html,
body,
.main-fixed-header,
.app-footer,
.menu-links,
.menu-links a,
.book-card,
.free-content-card,
.newsletter-card,
.newsletter-section {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}


/* ==========================================================================
   INDIVIDUAL BOOK PAGE
   ========================================================================== */

/* Main book reading container */
.single-book-container {
    display: flow-root;
    width: 100%;
    max-width: 1300px;
    margin: 2rem auto;
    padding: 2rem;
    box-sizing: border-box;
    color: var(--text-primary);
    font-family: var(--font-main);
}

/* --------------------------------------------------
   BOOK COVER
   -------------------------------------------------- */

.single-book-cover {
    float: left;
    display: block;
    width: 250px;
    max-width: 35%;
    height: auto;
    margin: 0 2rem 1.5rem 0;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* --------------------------------------------------
   TITLE AND SERIES
   -------------------------------------------------- */

.single-book-heading {
    text-align: left;
    margin-bottom: 2rem;
}

.single-book-title {
    font-size: clamp(2.5rem, 4vw, 3.5rem);
    line-height: 1.2;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
}

.single-book-series {
    font-size: 1.5rem;
    line-height: 1.4;
    font-style: italic;
    font-weight: normal;
    color: var(--text-muted);
    margin: 0;
}

/* --------------------------------------------------
   BOOK TEXT
   -------------------------------------------------- */

.single-book-text {
    width: 100%;
    font-size: 1.35rem;
    line-height: 1.85;
    color: var(--text-primary);
}

.single-book-summary {
    font-size: 1.4rem;
    line-height: 1.85;
    margin: 0 0 2rem 0;
    text-align: left;
}

/* Introduction and synopsis */
.single-book-section {
    margin-bottom: 2.5rem;
}

    .single-book-section h3 {
        font-size: 1.8rem;
        font-weight: bold;
        color: var(--accent-color);
        margin: 0 0 0.75rem 0;
    }

    .single-book-section p {
        font-size: 1.3rem;
        line-height: 1.85;
        margin: 0;
        text-align: left;
    }

/* --------------------------------------------------
   PURCHASE BUTTON
   -------------------------------------------------- */

.single-book-purchase {
    clear: both;
    padding-top: 1rem;
    text-align: center;
}

    .single-book-purchase hr {
        border: 0;
        border-top: 1px solid var(--border-color);
        margin-bottom: 2rem;
    }

.primary-buy-button {
    display: inline-block;
    background-color: #ff9900;
    color: #111111;
    padding: 1rem 2.5rem;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 25px;
    text-decoration: none;
    transition: background 0.2s ease;
}

    .primary-buy-button:hover {
        background-color: #e68a00;
        color: #111111;
    }

/* ==========================================================================
   MOBILE BOOK PAGE
   ========================================================================== */

@media (max-width: 650px) {

    .single-book-container {
        padding: 1.25rem;
        margin: 1rem auto;
    }

    /* Image moves above all text */
    .single-book-cover {
        float: none;
        display: block;
        width: 65%;
        max-width: 250px;
        margin: 0 auto 2rem auto;
    }

    .single-book-heading {
        margin-bottom: 1.75rem;
    }

    .single-book-title {
        font-size: 2.2rem;
    }

    .single-book-series {
        font-size: 1.2rem;
    }

    .single-book-text {
        font-size: 1.15rem;
        line-height: 1.75;
    }

    .single-book-summary {
        font-size: 1.2rem;
        line-height: 1.75;
    }

    .single-book-section h3 {
        font-size: 1.5rem;
    }

    .single-book-section p {
        font-size: 1.15rem;
        line-height: 1.75;
    }
}

/* ==========================================================================
   MARKDOWN CONTENT TYPOGRAPHY - HOMEPAGE SECTIONS
   ========================================================================== */

/* Main Markdown text */
.markdown-viewer {
    font-size: 1.25rem;
    line-height: 1.8;
    color: var(--text-primary);
}

    /* Paragraphs */
    .markdown-viewer p {
        font-size: inherit;
        line-height: 1.8;
        margin-bottom: 1rem;
    }

    /* Headings */
    .markdown-viewer h1 {
        font-size: 2.4rem;
        line-height: 1.2;
    }

    .markdown-viewer h2 {
        font-size: 2rem;
        line-height: 1.3;
    }

    .markdown-viewer h3 {
        font-size: 1.6rem;
        line-height: 1.4;
    }

    .markdown-viewer h4 {
        font-size: 1.35rem;
        line-height: 1.4;
    }

    /* Lists */
    .markdown-viewer li {
        font-size: inherit;
        line-height: 1.8;
        margin-bottom: 0.5rem;
    }

    /* Links */
    .markdown-viewer a {
        font-size: inherit;
    }

    /* Blockquotes */
    .markdown-viewer blockquote {
        font-size: inherit;
        line-height: 1.8;
        color: var(--text-muted);
    }

/* ==========================================================================
   MOBILE MARKDOWN TYPOGRAPHY
   ========================================================================== */

@media (max-width: 599px) {

    .markdown-viewer {
        font-size: 1.15rem;
        line-height: 1.75;
    }

        .markdown-viewer p,
        .markdown-viewer li {
            font-size: inherit;
            line-height: 1.75;
        }

        .markdown-viewer h1 {
            font-size: 2rem;
        }

        .markdown-viewer h2 {
            font-size: 1.75rem;
        }

        .markdown-viewer h3 {
            font-size: 1.45rem;
        }

        .markdown-viewer h4 {
            font-size: 1.25rem;
        }
}


@media (min-width: 769px) {
    #news .layout-container {
        flex-direction: column;
        gap: 0.5rem;
    }
}

#news .layout-container h3 {
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    line-height: 1.2;
}

.news-archive-heading {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.news-archive-date {
    font-weight: 600;
    white-space: nowrap;
}

.news-archive-link {
    font-weight: 600;
    text-decoration: none;
}


.news-preview-navigation {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.news-preview-navigation a:last-child {
    margin-left: auto;
    text-align: right;
}


@media (max-width: 480px) {
    .nav-container {
        padding: 0.8rem 1rem !important;
    }

    .header-newsletter {
        font-size: 0.7rem !important;
    }

    #brand-title,
    a#brand-title {
        font-size: 1.1rem !important;
    }
}
