/**
 * Webnovel Reading Styles
 *
 * Minimalistic, elegant typography for webnovel reading, list formatting,
 * quotes, and anti-scraping guard shells.
 *
 * @package FictioneerChild
 * @subpackage CSS
 */

:root {
    --novel-font-serif: 'Source Serif 4', Georgia, serif;
    --novel-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --novel-text-primary: #212529;
    --novel-text-secondary: #6c757d;
    --novel-border-color: #e9ecef;
    --novel-bg-subtle: #f8f9fa;
    --novel-accent-color: #495057;
    --novel-heavy-weight: 800;
    --blockquote-rule-color: #9a9a9a;
    --blockquote-quote-color: #a63232;
    --blockquote-bg: rgba(73,80,87,0.03);
}

[data-mode='dark'] {
    --novel-text-primary: #f8f9fa;
    --novel-text-secondary: #adb5bd;
    --novel-border-color: #343a40;
    --novel-bg-subtle: #212529;
    --novel-accent-color: #adb5bd;
    --blockquote-rule-color: rgba(255,255,255,0.25);
    --blockquote-quote-color: #e06b6b;
    --blockquote-bg: rgba(255,255,255,0.02);
}

.fcn-chapter-guard {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 8px;
    max-width: 720px;
    margin: 0 auto 18px;
    padding: 2px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.fcn-chapter-guard__button {
    appearance: none;
    justify-self: center;
    min-width: 0;
    padding: 7px 16px;
    border: 1px solid var(--fcn-guard-button-border, rgba(20, 24, 34, 0.12));
    border-radius: 999px;
    background: var(--fcn-guard-button-background, rgba(0, 0, 0, 0.04));
    color: var(--fcn-guard-button-color, var(--fg-800, #2a2a2a));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 0 0 0 rgba(101, 122, 255, 0);
    font-family: var(--novel-font-sans);
    font-size: 0.69rem;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.fcn-chapter-guard__button::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 38%, rgba(170, 190, 255, 0.12) 72%, rgba(255, 255, 255, 0.18));
    opacity: 0.9;
    pointer-events: none;
}

.fcn-chapter-guard__button:hover {
    background: var(--fcn-guard-button-background-hover, rgba(0, 0, 0, 0.065));
    border-color: var(--fcn-guard-button-border-hover, rgba(20, 24, 34, 0.18));
    color: var(--fcn-guard-button-color-hover, var(--fg-900, #111));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), 0 0 0 3px var(--fcn-guard-button-glow, rgba(101, 122, 255, 0.08)), 0 0 24px var(--fcn-guard-button-luminance, rgba(122, 145, 255, 0.16));
    transform: translateY(-1px);
}

.fcn-chapter-guard__button:active {
    transform: translateY(0);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 0 0 2px var(--fcn-guard-button-glow-strong, rgba(101, 122, 255, 0.12)), 0 0 16px var(--fcn-guard-button-luminance, rgba(122, 145, 255, 0.16));
}

.fcn-chapter-guard__button:focus-visible {
    outline: 2px solid var(--fcn-guard-button-focus, var(--primary-500, #4a90e2));
    outline-offset: 2px;
}

.fcn-chapter-guard__button[disabled] {
    cursor: wait;
    opacity: 0.7;
}

.fcn-chapter-guard__status {
    min-height: 1.1rem;
    margin: 0;
    color: var(--fcn-guard-status, var(--fg-600, var(--novel-text-secondary)));
    font-family: var(--novel-font-sans);
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
}

.fcn-chapter-guard__content[hidden] {
    display: none !important;
}

.fcn-chapter-guard__content {
    width: 100%;
    justify-self: stretch;
}

.fcn-scrape-marker {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    user-select: none !important;
}

.fcn-chapter-protection-shell {
    display: grid;
    place-items: center;
    min-height: 180px;
    padding: 24px 18px;
    border: 1px solid color-mix(in srgb, var(--novel-border-color) 82%, transparent);
    border-radius: 14px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--novel-bg-subtle) 92%, transparent), color-mix(in srgb, var(--novel-bg-subtle) 78%, transparent)),
        repeating-linear-gradient(-32deg, transparent 0 34px, color-mix(in srgb, var(--novel-border-color) 18%, transparent) 34px 35px);
    text-align: center;
}

.fcn-chapter-protection-shell__status {
    margin: 0;
    color: var(--novel-text-secondary);
    font-family: var(--novel-font-sans);
    font-size: 0.86rem;
    line-height: 1.6;
}

body[data-mode="light"] .fcn-chapter-guard {
    --fcn-guard-text: rgba(35, 40, 50, 0.82);
    --fcn-guard-status: rgba(70, 76, 88, 0.82);
    --fcn-guard-button-background: linear-gradient(180deg, rgba(237, 241, 255, 0.9), rgba(226, 231, 248, 0.92));
    --fcn-guard-button-background-hover: linear-gradient(180deg, rgba(229, 235, 255, 0.98), rgba(214, 222, 247, 0.98));
    --fcn-guard-button-border: rgba(108, 122, 178, 0.26);
    --fcn-guard-button-border-hover: rgba(99, 116, 183, 0.38);
    --fcn-guard-button-color: rgba(57, 68, 109, 0.92);
    --fcn-guard-button-color-hover: rgba(41, 51, 89, 0.98);
    --fcn-guard-button-glow: rgba(113, 130, 214, 0.14);
    --fcn-guard-button-glow-strong: rgba(113, 130, 214, 0.2);
    --fcn-guard-button-luminance: rgba(150, 168, 255, 0.22);
    --fcn-guard-button-focus: rgba(88, 108, 201, 0.9);
}

body[data-mode="dark"] .fcn-chapter-guard {
    --fcn-guard-text: rgba(230, 234, 240, 0.82);
    --fcn-guard-status: rgba(192, 198, 210, 0.8);
    --fcn-guard-button-background: linear-gradient(180deg, rgba(66, 76, 116, 0.22), rgba(37, 43, 71, 0.28));
    --fcn-guard-button-background-hover: linear-gradient(180deg, rgba(79, 91, 138, 0.28), rgba(48, 55, 89, 0.34));
    --fcn-guard-button-border: rgba(144, 160, 232, 0.2);
    --fcn-guard-button-border-hover: rgba(165, 180, 245, 0.28);
    --fcn-guard-button-color: rgba(235, 239, 250, 0.92);
    --fcn-guard-button-color-hover: #ffffff;
    --fcn-guard-button-glow: rgba(130, 148, 255, 0.14);
    --fcn-guard-button-glow-strong: rgba(130, 148, 255, 0.22);
    --fcn-guard-button-luminance: rgba(148, 165, 255, 0.26);
    --fcn-guard-button-focus: rgba(164, 180, 255, 0.92);
}

.fcn-chapter-content {
    max-width: 720px;
    margin: 0 auto;
    color: var(--novel-text-primary);
}

/* Lists: Minimalistic, Stylish, Compact */
.fcn-chapter-content ul,
.fcn-chapter-content ol {
    list-style: none;
    padding-left: 0;
    margin: 0.6em 0;
}

.fcn-chapter-content ul li,
.fcn-chapter-content ol li {
    position: relative;
    padding: 0.15em 0.5em 0.15em 2.2em;
    margin: 0.15em 0;
    font-size: 1em;
    line-height: 1.5;
    color: var(--novel-text-primary);
    border-radius: 2px;
}

.fcn-chapter-content ul li::before {
    content: '•';
    position: absolute;
    left: 0.5em;
    top: 0.3em;
    font-family: var(--novel-font-sans);
    font-size: 0.85em;
    line-height: 1.5;
    color: var(--novel-accent-color);
}

.fcn-chapter-content ul ul li::before,
.fcn-chapter-content ol ul li::before {
    content: '◦';
    color: var(--novel-text-secondary);
    top: 0.25em;
}

.fcn-chapter-content ul ul ul li::before,
.fcn-chapter-content ol ul ul li::before {
    content: '–';
    top: 0.25em;
}

.fcn-chapter-content ol {
    counter-reset: ol-level-1;
}

.fcn-chapter-content ol li::before {
    counter-increment: ol-level-1;
    content: counter(ol-level-1) ".";
    position: absolute;
    left: 0.5em;
    top: 0.35em;
    font-family: var(--novel-font-sans);
    font-weight: 500;
    font-size: 0.8em;
    line-height: 1.5;
    color: var(--novel-accent-color);
    width: 1.8em;
    text-align: right;
}

.fcn-chapter-content ol ol {
    counter-reset: ol-level-2;
    margin-left: 1.2em;
}

.fcn-chapter-content ol ol li::before {
    counter-increment: ol-level-2;
    content: counter(ol-level-1) "." counter(ol-level-2) ".";
    font-size: 0.75em;
    color: var(--novel-text-secondary);
    top: 0.3em;
    width: 2.4em;
}

.fcn-chapter-content ol ol ol {
    counter-reset: ol-level-3;
}

.fcn-chapter-content ol ol ol li::before {
    counter-increment: ol-level-3;
    content: counter(ol-level-1) "." counter(ol-level-2) "." counter(ol-level-3) ".";
    font-size: 0.7em;
    top: 0.25em;
    width: 3em;
}

.fcn-chapter-content ul ul,
.fcn-chapter-content ol ul,
.fcn-chapter-content ul ol {
    margin: 0.2em 0 0.2em 1.2em;
}

.fcn-chapter-content ul ul li,
.fcn-chapter-content ol ul li {
    font-size: 0.95em;
}

.fcn-chapter-content ul ul ul li,
.fcn-chapter-content ol ul ul li {
    font-size: 0.9em;
}

.fcn-chapter-content .fcn-bullet-container {
    padding: 0.3em 0.5em;
    margin: 0.8em 0;
    outline: 1px solid var(--novel-border-color);
    border-radius: 2px;
}

.fcn-chapter-content .fcn-bullet-container > ul,
.fcn-chapter-content .fcn-bullet-container > ol {
    margin: 0.15em 0;
}

.fcn-chapter-content .fcn-bullet-container > *:first-child { margin-top: 0; }
.fcn-chapter-content .fcn-bullet-container > *:last-child { margin-bottom: 0; }

/* Blockquote */
.fcn-chapter-content blockquote {
    margin: 2rem 0 1rem 3rem;
    padding: 1rem 1.2rem;
    border-left: 1px solid var(--blockquote-rule-color);
    background: var(--blockquote-bg);
    color: var(--novel-text-primary);
    border-radius: 5px;
    font-style: normal;
    font-size: 1.4rem;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 300;
    line-height: 1.8;
    position: relative;
}

.fcn-chapter-content blockquote::before {
    content: "\201C";
    position: absolute;
    left: -4rem;
    top: 0;
    font-size: 5rem;
    line-height: 1;
    color: var(--blockquote-quote-color);
    font-weight: 700;
    font-family: "Times New Roman", Times, serif;
    pointer-events: none;
}

.fcn-chapter-content blockquote p {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
}

.fcn-chapter-content blockquote cite {
    display: block;
    margin-top: 0.5rem;
    font-style: normal;
    font-size: 0.95rem;
    color: var(--novel-text-secondary);
    font-family: Georgia, "Times New Roman", serif;
}

.fcn-chapter-content blockquote cite a {
    color: var(--novel-accent-color);
    text-decoration: underline;
}

/* Heavy-bold Enforcement */
.fcn-chapter-content .fcn-heavy {
    font-weight: var(--novel-heavy-weight);
    font-family: var(--novel-font-serif);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.fcn-chapter-content strong,
.fcn-chapter-content b {
    font-weight: var(--novel-heavy-weight);
}

.fcn-chapter-content [style*="font-weight: 700"],
.fcn-chapter-content [style*="font-weight:700"],
.fcn-chapter-content [style*="font-weight: 800"],
.fcn-chapter-content [style*="font-weight:800"],
.fcn-chapter-content [style*="font-weight: bold"],
.fcn-chapter-content [style*="font-weight:bold"] {
    font-weight: var(--novel-heavy-weight);
}

/* Responsive Adjustments */
@media screen and (max-width: 768px) {
    .fcn-chapter-content ul li,
    .fcn-chapter-content ol li {
        padding-left: 2em;
        font-size: 0.95em;
    }

    .fcn-bullet-container ul ul li,
    .fcn-bullet-container ol ul li {
        padding-left: 2.4em !important;
    }

    .fcn-bullet-container ul ul ul li,
    .fcn-bullet-container ol ul ul li {
        padding-left: 2.8em !important;
    }

    .fcn-chapter-content ol li::before,
    .fcn-chapter-content ol ol li::before,
    .fcn-chapter-content ol ol ol li::before {
        left: 0.4em;
    }

    .fcn-chapter-content blockquote {
        margin-left: 2rem;
        font-size: 1.2rem;
        padding: 0.8rem 1rem;
    }

    .fcn-chapter-content blockquote::before {
        left: -3rem;
        font-size: 4rem;
    }

    .fcn-chapter-content .fcn-bullet-container {
        padding: 0.2em 0.4em;
    }
}

@media screen and (max-width: 480px) {
    .fcn-chapter-content ul li,
    .fcn-chapter-content ol li {
        padding-left: 1.9em;
        font-size: 0.9em;
        line-height: 1.4;
    }

    .fcn-bullet-container ul ul li,
    .fcn-bullet-container ol ul li {
        padding-left: 2.3em !important;
    }

    .fcn-bullet-container ul ul ul li,
    .fcn-bullet-container ol ul ul li {
        padding-left: 2.7em !important;
    }

    .fcn-chapter-content blockquote {
        margin-left: 1.5rem;
        font-size: 1rem;
        padding: 0.6rem 0.8rem;
    }

    .fcn-chapter-content blockquote::before {
        left: -2rem;
        font-size: 3rem;
        top: 0.1em;
    }

    .fcn-chapter-content .fcn-bullet-container {
        margin: 0.6em 0;
        padding: 0.15em 0.3em;
    }
}

@media only screen and (max-width: 640px) {
    .fcn-chapter-guard {
        gap: 7px;
        margin-bottom: 16px;
    }

    .fcn-chapter-guard__button {
        padding: 6px 13px;
        font-size: 0.64rem;
        letter-spacing: 0.09em;
    }
}

/* Print Styles */
@media print {
    :root {
        --novel-text-primary: #000;
        --novel-text-secondary: #444;
        --novel-border-color: #ccc;
        --novel-bg-subtle: #fff;
        --novel-accent-color: #000;
    }

    .fcn-chapter-content {
        max-width: 100%;
    }

    .fcn-chapter-content .fcn-bullet-container {
        outline: 1px solid #eee;
    }

    .fcn-chapter-content ul li,
    .fcn-chapter-content ol li {
        padding: 0.1em 0 0.1em 1.6em;
    }

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

    .fcn-chapter-content blockquote {
        background: transparent;
        border-left-color: #ddd;
    }
}
