
/* Murasaki Everywhere — Chapter Reader
   Shared presentation for all chapter pages.
*/

@font-face {
    font-family: "Tojo Captioner";
    src: url("../fonts/TheTojoCaptioner-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Edo SZ";
    src: url("../fonts/edosz.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;

    --bg: #0b0b0d;
    --panel: #17171b;
    --text: #e9e7e4;
    --muted: #aaa6a2;
    --accent: #b51f2b;
    --border: rgb(255 255 255 / 14%);

    --murasaki: #7d4071;
    --sato: #80c8ff;
    --takayama: #B29E67;
    --goons: #8E0000;

    --content-width: 880px;
    --page-gutter: clamp(1rem, 4vw, 2.5rem);
    --nav-height: 4.5rem;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    padding-bottom: calc(
        var(--nav-height) + env(safe-area-inset-bottom, 0px) + 2rem
    );

    background:
        radial-gradient(
            ellipse at 50% 0%,
            rgb(91 16 25 / 19%),
            transparent 38rem
        ),
        var(--bg);

    color: var(--text);
    font-family: "Tojo Captioner", Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

a {
    color: #f2a1a7;
    text-underline-offset: 0.2em;
}

a:hover {
    color: #fff;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid #ffb3b8;
    outline-offset: 4px;
}

/* Site header */

.reader-header,
.chapter-reader {
    width: min(
        100%,
        calc(var(--content-width) + 2 * var(--page-gutter))
    );
    margin-inline: auto;
    padding-inline: var(--page-gutter);
}

.reader-header {
    padding-top: 1.25rem;
}

.reader-site-title {
    display: inline-block;
    color: var(--text);
    font-family: "Edo SZ", Georgia, serif;
    font-size: clamp(1.25rem, 3vw, 1.8rem);
    line-height: 1.2;
    text-decoration: none;
}

.reader-site-subtitle {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reader-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.reader-breadcrumbs a {
    color: inherit;
}

/* Chapter title */

.chapter-heading {
    margin: clamp(2.5rem, 7vw, 5rem) 0 2.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.chapter-arc-label {
    margin: 0 0 0.75rem;
    color: #ed303d;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.chapter-heading h1 {
    margin: 0;
    color: #fff;
    font-family: "Edo SZ", Georgia, serif;
    font-size: clamp(2rem, 6vw, 3.8rem);
    font-weight: 400;
    line-height: 1.14;
    text-shadow: 0 3px 0 rgb(0 0 0 / 55%);
    text-wrap: balance;
}

.chapter-dateline {
    margin: 1rem 0 0;
    color: var(--muted);
    font-style: italic;
    letter-spacing: 0.04em;
}

.chapter-prose {
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
}

.chapter-prose > p {
    margin: 0 0 1.1rem;
}

/* Narration and dialogue */

.narration {
    color: #d7d3ce;
}

.dialogue {
    display: grid;
    grid-template-columns: minmax(8.5rem, 11rem) minmax(0, 1fr);
    gap: 0.25rem 1rem;

    margin: 1.2rem 0;
    padding: 0.9rem 1rem;

    border-left: 3px solid var(--border);
    border-radius: 0 0.4rem 0.4rem 0;
    background: rgb(255 255 255 / 3.5%);
}

.speaker-name {
    color: #fff;
    font-weight: 700;
    line-height: 1.55;
}

.dialogue-text {
    min-width: 0;
    color: var(--text);
    white-space: pre-wrap;
}

/* Character-specific speaker colors */

.dialogue[data-speaker="murasaki"] {
    border-left-color: var(--murasaki);
}

.dialogue[data-speaker="murasaki"] .speaker-name {
    color: var(--murasaki);
}

.dialogue[data-speaker="sato"] {
    border-left-color: var(--sato);
}

.dialogue[data-speaker="sato"] .speaker-name {
    color: var(--sato);
}

.dialogue[data-speaker="takayama"] {
    border-left-color: var(--takayama);
}

.dialogue[data-speaker="takayama"] .speaker-name {
    color: var(--takayama);
}

.dialogue[data-speaker^="takayama-goon"] {
    border-left-color: var(--goons);
}

.dialogue[data-speaker^="takayama-goon"] .speaker-name {
    color: var(--goons);
}

/* Stage directions */

.stage-direction {
    margin: 1.15rem 0;
    color: #a9a5a1;
    font-size: 0.97rem;
    font-style: italic;
}

.stage-direction::before {
    content: "〈 ";
    color: #69656a;
}

.stage-direction::after {
    content: " 〉";
    color: #69656a;
}

/* Scene headings and author notes */

.scene-heading {
    display: grid;
    gap: 0.35rem;
    margin: 3rem 0 1.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);

    color: #fff;
    font-family: "Edo SZ", Georgia, serif;
    font-size: clamp(1.25rem, 3vw, 1.7rem);
    font-weight: 400;
    line-height: 1.3;
    text-align: center;
}

.scene-time {
    letter-spacing: 0.07em;
}

.scene-subtitle {
    color: var(--muted);
    font-family: "Tojo Captioner", Arial, sans-serif;
    font-size: 0.76rem;
    letter-spacing: 0.12em;
}

.author-note {
    margin: 1.5rem 0;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: rgb(255 255 255 / 4%);
    color: var(--muted);
    font-size: 0.92rem;
}

.author-note p {
    margin: 0;
}

.author-note strong {
    color: var(--text);
}

/* Optional images and inline audio */

.story-image {
    margin: 2rem auto;
    text-align: center;
}

.story-image img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 75vh;
    margin-inline: auto;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    box-shadow: 0 12px 35px rgb(0 0 0 / 35%);
    object-fit: contain;
}

.story-image figcaption {
    margin-top: 0.65rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

.story-audio {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 1rem 0 1.5rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
}

.story-audio audio {
    width: 100%;
    min-width: 0;
}

.story-audio-label {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Intentional dramatic pause after Murasaki's eye injury */

.story-break {
    min-height: clamp(8rem, 24vh, 16rem);
    margin: 1.5rem 0;
}

/* Chapter closing line */

.chapter-ending {
    margin: 4rem 0 2rem;
    color: #fff;
    font-family: "Edo SZ", Georgia, serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    line-height: 1.25;
    text-align: center;
    text-shadow: 0 0 1.5rem rgb(181 31 43 / 45%);
}


/* =========================================================
   BOSS INTRO — Yakuza Kiwami-inspired composition
   The entire animation is confined to the 16:9 image frame.
   ========================================================= */

.boss-intro {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    isolation: isolate;
    background: #000;
}

/* 1920×1080 fight/background image */

.boss-intro-image {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* START FIGHT button */

.boss-intro-trigger {
    position: absolute;
    left: 50%;
    bottom: 4%;
    z-index: 5;
    transform: translateX(-50%);

    /* Compact, square styling */
    padding: 8px 18px;
    min-width: 130px;

    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #fff;
    border-radius: 0;

    /* Site typography */
    font-family: "Tojo Captioner", sans-serif;
    font-size: 14px;
    font-weight: normal;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;

    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

/* Hover state */
.boss-intro-trigger:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

/* Keyboard accessibility */
.boss-intro-trigger:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
}

/* Disabled state while the intro plays */
.boss-intro-trigger:disabled {
    cursor: default;
    opacity: 0;
}

/* Transparent overlay: never darken the page or background image. */

.boss-intro-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    background: transparent;
    pointer-events: none;
}

.boss-intro-overlay[hidden] {
    display: none;
}

/* ---------------------------------------------------------
   Faction crest
   --------------------------------------------------------- */

.boss-intro-sigil {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;

    display: block;
    width: 29%;
    height: auto;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;

    opacity: 0;
    transform: translate(-50%, -50%) scale(3.5) rotate(-24deg);
    transform-origin: center;
}

.boss-intro-overlay.is-playing .boss-intro-sigil {
    animation: boss-sigil-entry 0.9s ease-out both;
}

@keyframes boss-sigil-entry {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(3.5) rotate(-24deg);
    }

    35% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.75) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.75) rotate(0deg);
    }

    95% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.75) rotate(0deg);
    }
}

/* ---------------------------------------------------------
   Combined boss rank and name PNG
   --------------------------------------------------------- */

.boss-intro-caption-image {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;

    display: block;
    width: 85%;
    height: auto;
    max-width: 95%;
    max-height: 90%;
    object-fit: contain;

    opacity: 0;
    transform: translate(-50%, -50%) scale(5);
    transform-origin: center center;
    filter: none;
}

.boss-intro-overlay.is-playing .boss-intro-caption-image {
    animation: boss-caption-scale-down 0.35s linear 0.1s both;
}

@keyframes boss-caption-scale-down {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(3);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ---------------------------------------------------------
   Responsive sizing
   --------------------------------------------------------- */

@media (max-width: 620px) {
    .boss-intro-caption-image {
        width: 85%;
        max-width: 95%;
        max-height: 85%;
    }

    .boss-intro-trigger {
        bottom: 3%;
        font-size: 0.75rem;
    }
}


/* Fixed translucent Previous / Next bar */

.chapter-navigation {
    position: fixed;
    z-index: 20;
    inset: auto 0 0;

    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;

    min-height: var(--nav-height);
    padding:
        0.7rem max(var(--page-gutter), env(safe-area-inset-left, 0px))
        calc(0.7rem + env(safe-area-inset-bottom, 0px))
        max(var(--page-gutter), env(safe-area-inset-right, 0px));

    border-top: 1px solid rgb(255 255 255 / 14%);
    background: rgb(13 13 16 / 88%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chapter-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    width: fit-content;
    max-width: 100%;
    padding: 0.35rem 0.55rem;
    color: #f2a1a7;
    font-weight: 700;
    text-decoration: none;
}

.chapter-nav-previous {
    justify-self: start;
}

.chapter-nav-next {
    justify-self: end;
}

.chapter-nav-current {
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
}

.chapter-nav-link[aria-disabled="true"] {
    color: #68656a;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mobile layout */

@media (max-width: 620px) {
    body {
        font-size: 1rem;
        line-height: 1.7;
    }

    .reader-header {
        padding-top: 1rem;
    }

    .chapter-heading {
        margin-top: 2.5rem;
    }

    .dialogue {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.25rem;
        margin: 1rem 0;
        padding: 0.75rem 0.85rem;
    }

    .speaker-name {
        font-size: 0.95rem;
    }

    .stage-direction {
        font-size: 0.92rem;
    }

    .chapter-navigation {
        grid-template-columns: 1fr 1fr;
        min-height: 4.1rem;
    }

    .chapter-nav-current {
        display: none;
    }

    .chapter-nav-link {
        padding-inline: 0;
    }

    .boss-intro-overlay {
        padding: 0.75rem;
    }

}

/* Accessibility: honor the visitor's reduced-motion preference. */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
