
/* ==========================================================
   TORMENTED CHAOS
   Premium Book Reader Stylesheet
   ========================================================== */

/* ----------------------------------------------------------
   1. COLOR THEMES
   ---------------------------------------------------------- */

:root,
html[data-theme="dark"] {
    --bg: #15110f;
    --panel: #211a16;
    --text: #eee9e3;
    --muted: #aaa09a;
    --line: #3a302a;
    --accent: #d89b61;
    --reader-size: 20px;
}

html[data-theme="light"] {
    --bg: #f6f1e8;
    --panel: #ffffff;
    --text: #26211d;
    --muted: #6d655e;
    --line: #d7cfc4;
    --accent: #8c4e24;
}

html[data-theme="sepia"] {
    --bg: #f0e2c6;
    --panel: #f8ecd3;
    --text: #3b2c20;
    --muted: #756251;
    --line: #cfb994;
    --accent: #8b4b24;
}

/* ----------------------------------------------------------
   2. GLOBAL RESET
   ---------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

/* ----------------------------------------------------------
   3. READING PROGRESS BAR
   ---------------------------------------------------------- */

.progress-track {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 100;
    background: var(--line);
}

.progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.15s linear;
}

/* ----------------------------------------------------------
   4. READER TOOLBAR
   ---------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
}

.topbar-inner {
    max-width: 1050px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar a,
.topbar .tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.topbar a:hover,
.topbar .tool:hover {
    background: var(--bg);
    border-color: var(--accent);
}

.topbar .book-name {
    margin-right: auto;
    font-weight: 700;
}

.topbar .percent {
    margin-left: auto;
    color: var(--muted);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ----------------------------------------------------------
   5. MAIN READER CONTAINER
   ---------------------------------------------------------- */

.reader {
    width: 100%;
    max-width: 740px;
    margin: 0 auto;
    padding: 65px 28px 100px;
}

/* ----------------------------------------------------------
   6. CHAPTER HEADING
   ---------------------------------------------------------- */

.chapter-number {
    margin-bottom: 18px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.reader > h1 {
    margin: 0 auto 65px;
    max-width: 680px;
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(32px, 5vw, 44px);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.025em;
    text-align: center;
    text-wrap: balance;
}

/* ----------------------------------------------------------
   7. MANUSCRIPT TYPOGRAPHY
   ---------------------------------------------------------- */

.chapter-content {
    width: 100%;
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
    font-size: var(--reader-size);
    font-weight: 400;
    line-height: 1.85;
    letter-spacing: 0.005em;
    overflow-wrap: break-word;
    hyphens: none;
}

/* Standard book paragraphs */

.chapter-content p {
    margin: 0 0 1.5em;
    padding: 0;
    text-align: left;
    text-indent: 0;
}

/* No extra spacing after the final paragraph */

.chapter-content p:last-child {
    margin-bottom: 0;
}

/* Emphasis */

.chapter-content em,
.chapter-content i {
    font-style: italic;
}

.chapter-content strong,
.chapter-content b {
    font-weight: 700;
}

/* Subheadings within chapters */

.chapter-content h2 {
    margin: 2.5em 0 1em;
    font-size: 1.35em;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
}

.chapter-content h3 {
    margin: 2em 0 0.8em;
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.4;
}

/* Block quotations */

.chapter-content blockquote {
    margin: 2em 1.5em;
    padding: 0.5em 0 0.5em 1.25em;
    border-left: 3px solid var(--accent);
    color: var(--muted);
    font-style: italic;
}

.chapter-content blockquote p {
    margin-bottom: 1em;
}

/* Lists */

.chapter-content ul,
.chapter-content ol {
    margin: 1.5em 0;
    padding-left: 2em;
}

.chapter-content li {
    margin-bottom: 0.6em;
}

/* Images */

.chapter-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2em auto;
    border-radius: 4px;
}

/* Scene breaks */

.chapter-content hr {
    width: 75px;
    height: 1px;
    margin: 3em auto;
    border: 0;
    background: var(--line);
}

/* Links within the manuscript */

.chapter-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ----------------------------------------------------------
   8. CHAPTER NAVIGATION
   ---------------------------------------------------------- */

.chapter-nav {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-top: 70px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
}

.chapter-nav a {
    display: block;
    max-width: 48%;
    color: var(--accent);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    line-height: 1.6;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.chapter-nav a:hover {
    opacity: 0.75;
}

.chapter-nav .next {
    margin-left: auto;
    text-align: right;
}

.chapter-nav .locked-note {
    color: var(--muted);
}

/* ----------------------------------------------------------
   9. END OF CHAPTER CARD
   ---------------------------------------------------------- */

.end-card {
    margin-top: 45px;
    padding: 35px 30px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: center;
}

.end-card h2 {
    margin: 0 0 20px;
    color: var(--text);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.4;
}

.end-card p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 16px;
}

.end-card a {
    display: inline-block;
    color: var(--accent);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

.end-card a:hover {
    text-decoration: underline;
}

/* ----------------------------------------------------------
   10. LOCKED CHAPTER / NOTICES
   ---------------------------------------------------------- */

.locked,
.notice {
    margin: 35px 0;
    padding: 40px 30px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: center;
}

.locked h2,
.notice h2 {
    margin: 0 0 20px;
    font-size: 27px;
    font-weight: 400;
}

.locked p,
.notice p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 16px;
}

.locked a,
.notice a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.locked a:hover,
.notice a:hover {
    text-decoration: underline;
}

/* ----------------------------------------------------------
   11. TABLETS
   ---------------------------------------------------------- */

@media (max-width: 800px) {

    .reader {
        max-width: 100%;
        padding: 48px 30px 75px;
    }

    .reader > h1 {
        margin-bottom: 50px;
    }

    .topbar-inner {
        gap: 8px;
    }
}

/* ----------------------------------------------------------
   12. MOBILE READER
   ---------------------------------------------------------- */

@media (max-width: 600px) {

    body {
        line-height: 1.7;
    }

    .topbar {
        padding: 10px 12px;
    }

    .topbar-inner {
        gap: 6px;
    }

    .topbar a,
    .topbar .tool {
        min-height: 34px;
        padding: 6px 9px;
        font-size: 12px;
    }

    .topbar .book-name {
        margin-right: 6px;
    }

    .topbar .percent {
        margin-left: 6px;
    }

    .reader {
        padding: 38px 20px 65px;
    }

    .chapter-number {
        margin-bottom: 14px;
        font-size: 11px;
        letter-spacing: 0.2em;
    }

    .reader > h1 {
        margin-bottom: 42px;
        font-size: 32px;
        line-height: 1.3;
    }

    .chapter-content {
        font-size: calc(var(--reader-size) - 2px);
        line-height: 1.75;
        letter-spacing: 0;
    }

    .chapter-content p {
        margin-bottom: 1.35em;
    }

    .chapter-content blockquote {
        margin: 1.5em 0.5em;
        padding-left: 1em;
    }

    .chapter-nav {
        flex-direction: column;
        gap: 24px;
        margin-top: 50px;
    }

    .chapter-nav a {
        max-width: 100%;
        font-size: 16px;
    }

    .chapter-nav .next {
        margin-left: 0;
        text-align: left;
    }

    .end-card,
    .locked,
    .notice {
        padding: 28px 20px;
    }

    .end-card h2 {
        font-size: 22px;
    }
}

/* ----------------------------------------------------------
   13. SMALL PHONES
   ---------------------------------------------------------- */

@media (max-width: 380px) {

    .reader {
        padding-left: 16px;
        padding-right: 16px;
    }

    .reader > h1 {
        font-size: 29px;
    }

    .topbar a,
    .topbar .tool {
        padding: 5px 7px;
        font-size: 11px;
    }
}

/* ----------------------------------------------------------
   14. ACCESSIBILITY
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ==========================================================
   END — TORMENTED CHAOS READER CSS
   ========================================================== */


/* =========================================================
   TORMENTED CHAOS — HIDDEN LETTERS
   ========================================================= */

.hidden-letter {
    display: flex;
    align-items: center;
    gap: 22px;
    max-width: 650px;
    margin: 45px auto;
    padding: 25px 28px;
    background: linear-gradient(145deg, #f0dfbf, #d9c39c);
    color: #38291e;
    border: 1px solid #b59a72;
    border-radius: 3px;
    box-shadow:
        3px 5px 0 rgba(80, 56, 35, .12),
        0 12px 30px rgba(0, 0, 0, .22);
    transform: rotate(-1deg);
}

.hidden-letter-symbol {
    font-family: Georgia, serif;
    font-size: 48px;
    color: #805438;
    flex-shrink: 0;
}

.hidden-letter-content {
    flex: 1;
}

.hidden-letter-kicker {
    display: block;
    font-family: Georgia, serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #806348;
    margin-bottom: 8px;
}

.hidden-letter h3 {
    font-family: Georgia, serif;
    font-size: 23px;
    font-weight: normal;
    color: #39271b;
    margin: 0 0 8px;
}

.hidden-letter p {
    font-family: Georgia, serif;
    font-size: 15px;
    line-height: 1.6;
    color: #624b37;
    margin: 0 0 12px;
}

.hidden-letter-warning {
    border-left: 3px solid #9d6655;
    padding-left: 10px;
    font-style: italic;
}

.hidden-letter-link {
    display: inline-block;
    margin-top: 8px;
    color: #704127;
    font-family: Georgia, serif;
    font-size: 16px;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.hidden-letter-link:hover {
    color: #a04d30;
}

@media (max-width: 600px) {
    .hidden-letter {
        gap: 14px;
        padding: 20px;
        transform: none;
    }

    .hidden-letter-symbol {
        font-size: 34px;
    }

    .hidden-letter h3 {
        font-size: 20px;
    }
}

