/* Wild Fiction - Modern Ergonomic Reader Stylesheet */

:root {
    color-scheme: light dark;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: Georgia, "Iowan Old Style", "Source Serif Pro", serif;
    --font-scale: 1;

    /* Light Theme */
    --bg-page: #faf8f5;
    --bg-card: #ffffff;
    --bg-header: #f4efe8;
    --bg-reader-bar: rgba(244, 239, 232, 0.95);
    --text-primary: #292524;
    --text-muted: #66615b;
    --border-color: #e5ded4;
    --border-subtle: #eee8de;

    --accent-primary: #a33e1b;
    --accent-hover: #7f2f13;
    --accent-text: #ffffff;

    --notice-bg: #fdf5ea;
    --notice-border: #f0c997;
    --notice-text: #693e0b;

    --progress-track: #e0d8cb;
    --progress-fill: #a33e1b;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark Theme */
        --bg-page: #191816;
        --bg-card: #22201d;
        --bg-header: #211f1c;
        --bg-reader-bar: rgba(33, 31, 28, 0.95);
        --text-primary: #e6e2db;
        --text-muted: #9e988f;
        --border-color: #38342f;
        --border-subtle: #2d2a25;

        --accent-primary: #d96d43;
        --accent-hover: #f18c64;
        --accent-text: #191816;

        --notice-bg: #2e261b;
        --notice-border: #634a26;
        --notice-text: #f0d5b0;

        --progress-track: #38342f;
        --progress-fill: #d96d43;
    }
}

/* Base Styles */
html {
    font-size: 100%;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

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

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#body {
    flex: 1 0 auto;
    width: 100%;
}

.content-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

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

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Header & Nav */
.site-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.site-branding {
    display: flex;
    align-items: center;
}

.site-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.site-title a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.site-title img {
    height: 40px;
    width: auto;
    display: block;
}

.site-nav ul, #menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-nav a, #menu a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.site-nav a:hover, #menu a:hover {
    color: var(--accent-primary);
    background-color: var(--border-subtle);
}

.site-nav a[aria-current="page"],
.site-nav a.active {
    color: var(--accent-primary);
    background-color: var(--border-subtle);
}

/* Sticky Reader Bar */
.reader-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-reader-bar);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.reader-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    gap: 0.75rem;
}

.reader-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reader-nav-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    min-height: 38px;
    justify-content: center;
}

.reader-nav-link:hover {
    background-color: var(--border-subtle);
    color: var(--accent-hover);
}

.reader-nav-disabled {
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-muted);
    opacity: 0.4;
    padding: 0.35rem 0.6rem;
    min-height: 38px;
    justify-content: center;
    user-select: none;
}

.reader-page-info {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.reader-font-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.font-ctrl-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.font-ctrl-btn:hover {
    background-color: var(--border-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.progress-bar-container {
    height: 3px;
    width: 100%;
    background-color: var(--progress-track);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--progress-fill);
    transition: width 0.3s ease;
}

/* Resume Banner Notice */
.resume-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background-color: var(--notice-bg);
    border-bottom: 1px solid var(--notice-border);
    color: var(--notice-text);
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.resume-text {
    flex: 1 1 280px;
    font-weight: 500;
}

.resume-actions {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.resume-reset-link {
    font-weight: 600;
    color: var(--notice-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.resume-reset-link:hover {
    opacity: 0.8;
}

.resume-close-btn {
    background: transparent;
    border: none;
    color: var(--notice-text);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.resume-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

/* Reader Content & Typography */
.reader-content {
    max-width: 70ch;
    padding: 2.5rem 1.25rem 4rem;
    margin: 0 auto;
}

.chapter-heading {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 1.5rem + 1vw, 2.25rem);
    font-weight: 700;
    text-align: center;
    margin: 0 0 2rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.word-doc-page {
    font-family: var(--font-serif);
    font-size: calc(clamp(1.125rem, 1rem + 0.5vw, 1.25rem) * var(--font-scale, 1));
    line-height: 1.75;
    color: var(--text-primary);
    margin: 0 0 2.5rem;
    word-break: break-word;
}

.bottom-nav {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 1rem;
    color: var(--text-muted);
}

.bottom-nav p {
    margin: 0;
}

.bottom-nav a {
    margin: 0 0.25rem;
    font-weight: 600;
}

/* Home Page */
.home-main {
    padding: 3rem 1.25rem 4rem;
}

.hero-section {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 3rem;
    align-items: center;
}

.hero-cover {
    display: flex;
    justify-content: center;
}

.cover-image {
    width: 100%;
    max-width: 360px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    object-fit: cover;
    display: block;
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.hero-title {
    font-family: var(--font-serif);
    font-size: clamp(2.25rem, 2rem + 1.5vw, 3rem);
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.hero-blurb {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    min-height: 48px;
    border: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--accent-text);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: var(--accent-text);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
}

.btn-secondary:hover {
    background-color: var(--border-subtle);
}

.chapter-jump-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    max-width: 380px;
}

.chapter-jump-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chapter-jump-form label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.jump-input-group {
    display: flex;
    gap: 0.5rem;
}

.jump-input-group input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-width: 0;
}

.btn-jump {
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--accent-primary);
    color: var(--accent-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-height: 42px;
}

.btn-jump:hover {
    background-color: var(--accent-hover);
}

/* About Page */
.about-main {
    padding: 2.5rem 1.25rem 4rem;
}

.page-title {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 1.75rem + 1vw, 2.5rem);
    margin: 0 0 2rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.about-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.about-article {
    color: var(--text-primary);
}

.author-sketch {
    float: right;
    margin: 0 0 1.5rem 1.5rem;
    max-width: 220px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
}

.about-article p {
    font-size: 1.125rem;
    line-height: 1.75;
    margin: 0 0 1.25rem;
    color: var(--text-primary);
}

.about-aside {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.about-aside h3 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.about-aside ul {
    margin: 0;
    padding-left: 1.25rem;
}

.about-aside li {
    margin-bottom: 0.5rem;
}

/* 404 & Legacy Utility Styles */
.featured {
    padding: 2rem 0;
}

.main-content {
    padding: 2rem 0 3rem;
}

.clear-fix::after {
    content: "";
    display: table;
    clear: both;
}

.float-left {
    float: left;
}

.float-right {
    float: right;
}

/* Footer */
.site-footer {
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.site-footer p {
    margin: 0;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .hero-section {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .hero-actions {
        justify-content: center;
    }

    .chapter-jump-card {
        margin-left: auto;
        margin-right: auto;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .author-sketch {
        float: none;
        display: block;
        margin: 0 auto 1.5rem;
        max-width: 200px;
    }

    .reader-page-info {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .content-wrapper {
        padding: 0 1rem;
    }

    .reader-bar-inner {
        gap: 0.5rem;
    }

    .reader-nav-controls {
        gap: 0.5rem;
    }

    .reader-nav-link,
    .reader-nav-disabled {
        padding: 0.3rem 0.4rem;
        font-size: 0.85rem;
    }

    .btn {
        width: 100%;
    }

    .hero-actions {
        flex-direction: column;
    }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

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