/* ==========================================================
   SAGE: GHOSTS OF MILLHAVEN — Theme Stylesheet
   Palette: muted blue-grey / slate, moody, contemporary noir
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=EB+Garamond:wght@400;500&display=swap');

:root {
    --sage-bg-dark: #1b232e;
    --sage-bg-panel: rgba(27, 35, 46, 0.82);
    --sage-slate: #3c4a5c;
    --sage-slate-light: #6b7b8f;
    --sage-silver: #cdd6df;
    --sage-silver-bright: #eef2f6;
    --sage-accent-glow: #a9c4d8;
    --sage-text: #e8edf2;
    --sage-text-muted: #9fadbb;
    --sage-font-heading: 'Cormorant Garamond', Georgia, serif;
    --sage-font-body: 'EB Garamond', Georgia, serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--sage-bg-dark);
    background-image: url('/webseries/sage/assets/images/sage-background.png');
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    background-repeat: no-repeat;
    font-family: var(--sage-font-body);
    color: var(--sage-text);
}

/* Admin pages (queue, review, edit-chapter) use this class instead of the
   watercolor art -- that background was designed for the reading experience,
   not for dense editing screens where captions and labels need to stay
   legible against a flat, predictable surface. */
body.sage-admin-page {
    background-image: none;
    background-color: var(--sage-bg-dark);
}

a {
    color: var(--sage-accent-glow);
    text-decoration: none;
}
a:hover {
    color: var(--sage-silver-bright);
}

/* ---------- Header ---------- */
.sage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
}
.sage-back-link {
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6), 0 0 12px rgba(0,0,0,0.35);
}

/* Anything sitting directly on the raw background image (not inside a
   dark panel) needs a shadow, since the artwork's brightness varies
   a lot across the image and plain grey text can vanish in lighter spots.
   Strengthened + extended to cover the hero CTA buttons, which were
   missing from this rule entirely. */
.sage-hero,
.sage-footer,
.sage-chapter-nav a,
.sage-cta-row .sage-btn {
    text-shadow: 0 1px 4px rgba(0,0,0,0.75), 0 0 16px rgba(0,0,0,0.5);
}

/* Footer and chapter nav sit on the least predictable part of the
   background (varies from open sky to the lit city skyline), so they
   need brighter text plus a scrim behind them, not just a shadow. */
.sage-footer,
.sage-chapter-nav a {
    color: var(--sage-silver-bright);
}

.sage-footer {
    background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0));
    padding-top: 60px;
    margin-top: -30px;
}

/* Overlay layer for animated cels (falling leaves, snow, fireflies,
   fog, holiday overlays). Sits fixed over the whole viewport, behind
   actual content, above the base background. Transparent PNGs only --
   the base background still shows through wherever the overlay has no
   art. Multiple overlay divs can stack (e.g. a seasonal motion overlay
   plus a holiday overlay on top of it) since each is independently
   positioned and z-indexed the same. */
.sage-bg-overlay {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 0;
    opacity: 0.85;
}

/* Make sure real page content stacks above the overlay layer(s). */
.sage-header,
.sage-hero,
.sage-chapter-list-section,
.sage-chapter-content,
.sage-chapter-nav,
.sage-footer {
    position: relative;
    z-index: 1;
}

/* Overlay motion styles. These are single static compositions, not
   seamless repeating textures, so this is gentle looping drift/sway/
   twinkle rather than true infinite falling snow -- convincing ambient
   motion without needing new tileable art. */
.sage-bg-overlay--fall {
    animation: sage-overlay-fall 14s ease-in-out infinite;
}
.sage-bg-overlay--drift {
    animation: sage-overlay-drift 22s ease-in-out infinite;
}
.sage-bg-overlay--twinkle {
    animation: sage-overlay-twinkle 3.5s ease-in-out infinite;
}

@keyframes sage-overlay-fall {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(18px); }
    100% { transform: translateY(0); }
}
@keyframes sage-overlay-drift {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(12px, -8px); }
    100% { transform: translate(0, 0); }
}
@keyframes sage-overlay-twinkle {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 0.95; }
}

/* Respect users who've asked their system to reduce motion */
@media (prefers-reduced-motion: reduce) {
    .sage-bg-overlay--fall,
    .sage-bg-overlay--drift,
    .sage-bg-overlay--twinkle {
        animation: none;
    }
}

/* ---------- Hero / Hub Page ---------- */
.sage-hero {
    text-align: center;
    padding: 60px 20px 40px;
}
.sage-wordmark {
    max-width: 700px;
    width: 90%;
    height: auto;
}
.sage-tagline {
    font-family: var(--sage-font-heading);
    font-style: italic;
    font-size: 1.3rem;
    color: var(--sage-silver-bright);
    margin-top: 10px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6), 0 0 12px rgba(0,0,0,0.35);
}
.sage-cta-row {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}
.sage-btn {
    display: inline-block;
    padding: 14px 30px;
    border-radius: 3px;
    font-family: var(--sage-font-heading);
    font-size: 1.05rem;
    letter-spacing: 0.03em;
    border: 1px solid var(--sage-slate-light);
    transition: all 0.2s ease;
}
.sage-btn-primary {
    background-color: var(--sage-slate);
    color: var(--sage-silver-bright);
}
.sage-btn-primary:hover {
    background-color: var(--sage-slate-light);
}
.sage-btn-secondary {
    background-color: rgba(0,0,0,0.25);
    color: var(--sage-silver);
    border-color: var(--sage-silver-bright);
}
.sage-btn-secondary:hover {
    background-color: rgba(255,255,255,0.06);
}

/* ---------- Chapter List ---------- */
.sage-chapter-list-section {
    max-width: 800px;
    margin: 40px auto 80px;
    padding: 0 20px;
}
.sage-chapter-list-toggle {
    width: 100%;
    background: var(--sage-bg-panel);
    border: 1px solid var(--sage-slate);
    color: var(--sage-silver-bright);
    font-family: var(--sage-font-heading);
    font-size: 1.1rem;
    padding: 14px 20px;
    text-align: left;
    cursor: pointer;
    border-radius: 3px;
}
.sage-chevron {
    float: right;
    transition: transform 0.2s ease;
}
.sage-chapter-list-toggle.open .sage-chevron {
    transform: rotate(180deg);
}
.sage-chapter-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.sage-chapter-list.open {
    max-height: 3000px;
}
.sage-chapter-item {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 18px 20px;
    background: var(--sage-bg-panel);
}
.sage-chapter-item a {
    display: block;
    color: var(--sage-text);
}
.sage-chapter-num {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sage-accent-glow);
    display: block;
    margin-bottom: 4px;
}
.sage-chapter-title {
    font-family: var(--sage-font-heading);
    font-size: 1.3rem;
    display: block;
}
.sage-chapter-era {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--sage-text-muted);
}
.sage-chapter-synopsis {
    font-size: 0.95rem;
    color: var(--sage-text-muted);
    margin-top: 6px;
}
.sage-chapter-empty {
    text-align: center;
    color: var(--sage-text-muted);
    font-style: italic;
}

/* ---------- Chapter Reading Page ---------- */
.sage-mode-toggle {
    display: flex;
    gap: 4px;
    background: var(--sage-bg-panel);
    border-radius: 20px;
    padding: 4px;
}
.sage-mode-btn {
    background: transparent;
    border: none;
    color: var(--sage-text-muted);
    padding: 8px 18px;
    border-radius: 16px;
    font-family: var(--sage-font-heading);
    cursor: pointer;
}
.sage-mode-btn.active {
    background: var(--sage-slate);
    color: var(--sage-silver-bright);
}

.sage-chapter-content {
    max-width: 720px;
    margin: 20px auto 60px;
    padding: 40px 30px;
    background: var(--sage-bg-panel);
    border-radius: 4px;
}
.sage-episode-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
    color: var(--sage-accent-glow);
    margin-bottom: 4px;
}
.sage-era-caption {
    font-style: italic;
    color: var(--sage-text-muted);
    margin-bottom: 10px;
}
.sage-chapter-title-heading {
    font-family: var(--sage-font-heading);
    font-size: 2.4rem;
    margin: 0 0 30px;
    color: var(--sage-silver-bright);
}
.sage-scroll-view p {
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 1.2em;
}

/* ---------- Book-flip mode ---------- */
.sage-book-view {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sage-flipbook {
    margin: 0 auto;
}
.sage-page {
    background: #f4f0e8;
    color: #2a2a2a;
    position: relative;
    overflow: hidden;
}
.sage-cover-page {
    background: var(--sage-bg-dark);
    padding: 0;
    position: relative;
    overflow: hidden;
}
.sage-cover-inner {
    position: absolute;
    inset: 0;
}
.sage-cover-wordmark {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sage-cover-episode {
    position: absolute;
    bottom: 22%;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--sage-silver-bright);
    font-family: var(--sage-font-heading);
    text-shadow: 0 1px 6px rgba(0,0,0,0.85), 0 0 20px rgba(0,0,0,0.5);
}
.sage-cover-episode-num {
    display: block;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.9;
}
.sage-cover-episode-title {
    display: block;
    font-size: 1.6rem;
    font-style: italic;
    margin-top: 6px;
}
.sage-page-inner {
    padding: 30px 26px;
    font-size: 1rem;
    line-height: 1.7;
    height: 100%;
    box-sizing: border-box;
    position: relative;
}
.sage-page-number {
    position: absolute;
    bottom: 10px;
    right: 16px;
    font-size: 0.8rem;
    color: #888;
}
.sage-flipbook-controls {
    margin-top: 16px;
    display: flex;
    gap: 16px;
}
.sage-flipbook-controls button {
    background: var(--sage-slate);
    color: var(--sage-silver-bright);
    border: none;
    padding: 10px 20px;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--sage-font-heading);
}

/* ---------- Teaser box ---------- */
.sage-teaser-box {
    margin-top: 50px;
    padding: 24px;
    border-top: 1px solid var(--sage-slate);
    border-bottom: 1px solid var(--sage-slate);
}
.sage-teaser-label {
    font-family: var(--sage-font-heading);
    font-style: italic;
    color: var(--sage-accent-glow);
    margin-bottom: 8px;
}
.sage-teaser-text {
    color: var(--sage-text-muted);
}

/* ---------- Chapter nav ---------- */
.sage-chapter-nav {
    max-width: 720px;
    margin: 0 auto 60px;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    font-family: var(--sage-font-heading);
}

/* ---------- Footer ---------- */
.sage-footer {
    text-align: center;
    padding: 30px;
    color: var(--sage-text-muted);
    font-size: 0.85rem;
}
.sage-footer-isbn {
    font-size: 0.75rem;
    opacity: 0.7;
    display: inline-block;
    margin-top: 6px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .sage-header { padding: 16px 20px; flex-direction: column; gap: 12px; }
    .sage-chapter-content { padding: 26px 18px; }
    .sage-chapter-title-heading { font-size: 1.8rem; }
}
