/* Story Mode is intentionally scoped to fiction posts in the October staging theme. */

.story-mode {
    width: min(920px, calc(100vw - 40px));
    margin: 0 50% 34px;
    transform: translateX(-50%);
}

.story-mode-details {
    border: 1px solid rgba(243, 198, 122, 0.28);
    background: rgba(6, 20, 33, 0.94);
}

.story-mode-details > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 66px;
    padding: 13px 18px;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
}

.story-mode-details > summary::-webkit-details-marker {
    display: none;
}

.story-mode-details > summary > span:first-child {
    display: grid;
    gap: 2px;
}

.story-mode-details > summary strong {
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.story-mode-details > summary small {
    color: var(--muted);
    font-size: 0.72rem;
}

.story-mode-details > summary > span:last-child {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(243, 198, 122, 0.4);
    color: var(--text);
    font-family:var(--font-serif);
    font-size: 1rem;
}

.story-mode-details[open] > summary {
    border-bottom: 1px solid rgba(243, 198, 122, 0.22);
    background: rgba(243, 198, 122, 0.05);
}

.story-mode-panel {
    padding: clamp(20px, 4vw, 34px);
}

.story-mode-panel > header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 18px;
    margin-bottom: 26px;
}

.story-mode-panel .eyebrow {
    margin-bottom: 7px;
}

.story-mode-panel h2 {
    margin: 0;
    color: var(--text);
    font-family:var(--font-serif);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 500;
    line-height: 1;
}

.story-mode-reset {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid rgba(243, 198, 122, 0.36);
    color: var(--accent);
    background: transparent;
    cursor: pointer;
    font:inherit;
    font-size: 0.67rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.story-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 22px;
}

.story-mode-grid fieldset {
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

.story-mode-grid legend {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.story-mode-options {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 5px;
}

.story-mode-options button {
    min-width: 0;
    min-height: 40px;
    padding: 6px 8px;
    overflow-wrap: anywhere;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #bac6d7;
    background: rgba(255, 255, 255, 0.035);
    cursor: pointer;
    font:inherit;
    font-size: 0.69rem;
    font-weight: 500;
}

.story-mode-options button[aria-pressed="true"] {
    border-color: var(--accent);
    color: #071b34;
    background: var(--accent);
}

.story-mode-panel > footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: start;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(243, 198, 122, 0.16);
}

.story-mode-panel > footer p {
    margin: 0;
    color: #9faec2;
    font-size: 0.72rem;
}

.story-mode-status {
    min-width: 150px;
    color: #78d3a5 !important;
    text-align: right;
}

.story-mode :is(summary, button):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.article[data-story-font="small"] .gh-content {
    --story-font-size: 1rem;
}

.article[data-story-font="standard"] .gh-content {
    --story-font-size: 1.1875rem;
}

.article[data-story-font="large"] .gh-content {
    --story-font-size: clamp(1.375rem, 2vw, 1.5rem);
}

.article[data-story-spacing="compact"] .gh-content {
    --story-line-height: 1.5;
}

.article[data-story-spacing="comfortable"] .gh-content {
    --story-line-height: 1.7;
}

.article[data-story-spacing="spacious"] .gh-content {
    --story-line-height: 1.92;
}

.article[data-story-width="narrow"] .gh-content {
    --story-reading-width: 620px;
}

.article[data-story-width="standard"] .gh-content {
    --story-reading-width: 760px;
}

.article[data-story-width="wide"] .gh-content {
    --story-reading-width: 900px;
}

.article[data-story-mode-ready] .gh-content {
    width: min(var(--story-reading-width, 760px), calc(100vw - 40px));
    max-width: none;
    margin-inline: 50%;
    color: var(--story-text, var(--text));
    font-size: var(--story-font-size, 1.1875rem);
    line-height: var(--story-line-height, 1.7);
    transform: translateX(-50%);
}

.article[data-story-mode-ready] .gh-content :is(p, li, figcaption) {
    color: inherit;
}

.article[data-story-theme="paper"] .gh-content,
.article[data-story-theme="contrast"] .gh-content {
    padding: clamp(22px, 4vw, 42px);
    border: 1px solid var(--story-border);
    background: var(--story-canvas);
}

.article[data-story-theme="paper"] .gh-content {
    --story-canvas: #f2e5cc;
    --story-text: #251b12;
    --story-border: #c8aa79;
}

.article[data-story-theme="paper"] .gh-content :is(h2, h3, a) {
    color: #704612;
}

.article[data-story-theme="paper"] .gh-content blockquote {
    color: #584532;
    border-left-color: #9a651e;
}

.article[data-story-theme="contrast"] .gh-content {
    --story-canvas: #000;
    --story-text: #fff;
    --story-border: #fff;
}

.article[data-story-theme="contrast"] .gh-content :is(h2, h3, a) {
    color: #ffdc91;
}

.article[data-story-theme="contrast"] .gh-content blockquote {
    color: #fff;
    border-left-color: #ffdc91;
}

.story-mode-progress {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 45;
    display: grid;
    grid-template-columns: minmax(90px, 180px) auto;
    align-items: center;
    gap: 10px;
    min-width: 190px;
    padding: 10px 12px;
    border: 1px solid rgba(243, 198, 122, 0.5);
    color: var(--accent);
    background: rgba(4, 16, 29, 0.94);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(14px);
}

.story-mode-progress[hidden] {
    display: none !important;
}

.story-mode-progress > span {
    display: block;
    height: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.14);
}

.story-mode-progress i {
    display: block;
    width: var(--story-progress, 0%);
    height: 100%;
    background: var(--accent);
}

.story-mode-progress strong {
    min-width: 32px;
    font-size: 0.7rem;
    text-align: right;
}

html.story-mode-reduced-motion {
    scroll-behavior: auto !important;
}

html.story-mode-reduced-motion *,
html.story-mode-reduced-motion *::before,
html.story-mode-reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
}

@media (max-width: 760px) {
    .story-mode {
        width: calc(100vw - 28px);
        margin-bottom: 26px;
    }

    .story-mode-panel {
        padding: 20px 16px;
    }

    .story-mode-panel > header,
    .story-mode-panel > footer,
    .story-mode-grid {
        grid-template-columns: 1fr;
    }

    .story-mode-reset {
        justify-self: start;
    }

    .story-mode-status {
        min-width: 0;
        text-align: left;
    }

    .story-mode-options button {
        font-size: 0.64rem;
    }

    .article[data-story-mode-ready] .gh-content {
        width: min(var(--story-reading-width, 760px), calc(100vw - 28px));
    }

    .article[data-story-theme="paper"] .gh-content,
    .article[data-story-theme="contrast"] .gh-content {
        padding: 22px 18px;
    }

    .story-mode-progress {
        right: 14px;
        bottom: max(14px, env(safe-area-inset-bottom));
        left: 14px;
        grid-template-columns: minmax(0, 1fr) auto;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-mode *,
    .story-mode-progress * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
