/* ── Story Line as a book ── */
.features-section {
    position: relative;
    z-index: 3;
    padding: 80px 20px 50px;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 120, 150, 0.18), transparent 55%),
        linear-gradient(to bottom, transparent 0%, rgba(1, 4, 9, 0.9) 18%, #010811 100%);
    text-align: center;
}

.story-kicker {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: #7eb8c9;
    margin: 0 0 12px;
}

.features-section > h2 {
    font-family: "Cinzel", serif;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    margin: 0 0 10px;
    font-weight: 700;
    color: #f0f7fa;
    text-shadow: 0 2px 20px rgba(0, 180, 216, 0.35);
}

.story-lead {
    font-family: "Literata", Georgia, serif;
    font-size: 1.05rem;
    color: #a8c5d0;
    max-width: 36rem;
    margin: 0 auto 36px;
    line-height: 1.55;
}

.story-book-wrap {
    --book-w: min(920px, 94vw);
    --book-closed-w: min(400px, 78vw);
    --book-h: min(540px, 72vh);
    --flip-ms: 900ms;
    --open-ms: 1100ms;
    --flip-ease: cubic-bezier(0.645, 0.045, 0.355, 1);
    --open-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    width: var(--book-w);
    margin: 0 auto;
    transition: width var(--open-ms) var(--open-ease);
    perspective: 2600px;
}

.story-book-wrap.is-closed {
    width: var(--book-closed-w);
}

.story-book {
    position: relative;
    width: 100%;
    height: var(--book-h);
    transform-style: preserve-3d;
}

.story-book-spine {
    position: absolute;
    left: 50%;
    top: 3%;
    bottom: 3%;
    width: 14px;
    margin-left: -7px;
    background: linear-gradient(90deg, #071018, #1a3344 45%, #071018);
    border-radius: 2px;
    box-shadow: 0 0 28px rgba(0, 0, 0, 0.7);
    z-index: 6;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.35s ease, left var(--open-ms) var(--open-ease);
}

.story-book-wrap.is-closed .story-book-spine {
    left: 10px;
    margin-left: 0;
    width: 12px;
    opacity: 0.95;
}

.story-book-shelf {
    position: absolute;
    inset: 0;
    border-radius: 4px 12px 12px 4px;
    background:
        linear-gradient(145deg, #152838 0%, #0b1520 42%, #061018 100%);
    box-shadow:
        0 28px 60px rgba(0, 0, 0, 0.55),
        inset 0 0 0 1px rgba(120, 190, 210, 0.12),
        inset 8px 0 20px rgba(0, 0, 0, 0.35);
    z-index: 0;
}

.story-book-wrap.is-closed .story-book-shelf {
    border-radius: 4px 10px 10px 4px;
    background:
        linear-gradient(160deg, #1a3348 0%, #0c1a28 45%, #050d14 100%);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.65),
        8px 0 0 #0a1520,
        10px 0 0 #152536,
        12px 0 0 #0a1520,
        14px 4px 24px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px rgba(120, 190, 210, 0.16);
}

/* Closed hardcover — click to open */
.story-cover {
    position: absolute;
    inset: 0;
    z-index: 12;
    border: 0;
    padding: 0;
    cursor: pointer;
    border-radius: 4px 10px 10px 4px;
    transform-origin: left center;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform var(--open-ms) var(--open-ease);
    background: transparent;
    color: #e8f4f8;
    text-align: center;
}

.story-cover:focus-visible {
    outline: 2px solid #00b4d8;
    outline-offset: 4px;
}

.story-cover-inner {
    padding: 28px 24px;
    max-width: 86%;
    pointer-events: none;
}

.story-cover-kicker {
    font-family: "Cinzel", serif;
    font-size: 0.68rem;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: #7eb8c9;
    margin: 0 0 14px;
}

.story-cover-title {
    font-family: "Cinzel", serif;
    font-size: clamp(1.45rem, 4vw, 1.9rem);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin: 0 0 8px;
    color: #f2fafc;
    text-shadow: 0 0 24px rgba(0, 180, 216, 0.35);
}

.story-cover-sub {
    font-family: "Literata", Georgia, serif;
    font-size: 0.95rem;
    color: #9fc0ce;
    margin: 0 0 22px;
    line-height: 1.5;
}

.story-cover-cta {
    display: inline-block;
    font-family: "Cinzel", serif;
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #caf0f8;
    border: 1px solid rgba(0, 180, 216, 0.45);
    padding: 10px 16px;
    animation: coverPulse 2.4s ease-in-out infinite;
}

@keyframes coverPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 180, 216, 0); }
    50% { box-shadow: 0 0 18px rgba(0, 180, 216, 0.35); }
}

.story-cover-face-back {
    position: absolute;
    inset: 0;
    border-radius: 10px 4px 4px 10px;
    background: linear-gradient(155deg, #0d1c28 0%, #071018 100%);
    transform: rotateY(180deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: inset 0 0 0 1px rgba(120, 190, 210, 0.1);
}

.story-cover-front {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 4px 10px 10px 4px;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(0, 180, 216, 0.16), transparent 50%),
        linear-gradient(155deg, #163044 0%, #0a1824 48%, #040b12 100%);
    box-shadow:
        inset 0 0 0 1px rgba(144, 224, 239, 0.22),
        inset 0 0 60px rgba(0, 0, 0, 0.35),
        0 20px 50px rgba(0, 0, 0, 0.45);
    transition: box-shadow 0.35s ease;
}

.story-cover:hover .story-cover-front {
    box-shadow:
        inset 0 0 0 1px rgba(144, 224, 239, 0.4),
        inset 0 0 60px rgba(0, 0, 0, 0.3),
        0 24px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(0, 180, 216, 0.15);
}

.story-book-wrap.is-opening .story-cover,
.story-book-wrap.is-open .story-cover {
    transform: rotateY(-180deg);
    pointer-events: none;
    cursor: default;
}

.story-book-wrap.is-open .story-cover {
    opacity: 0;
    visibility: hidden;
}

.story-book-wrap.is-closed:not(.is-opening) .flipbook,
.story-book-wrap.is-closed:not(.is-opening) .story-page-hit {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.story-book-wrap.is-opening .flipbook {
    opacity: 1;
    visibility: visible;
    animation: pagesReveal var(--open-ms) var(--open-ease) both;
}

@keyframes pagesReveal {
    0% { opacity: 0.25; filter: brightness(0.65); }
    60% { opacity: 1; filter: brightness(0.92); }
    100% { opacity: 1; filter: none; }
}

.story-book-controls,
.story-hint {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.story-book-wrap.is-closed:not(.is-open) .story-book-controls {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.story-book-wrap.is-open .story-book-controls,
.story-book-wrap.is-open .story-hint {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.story-book-wrap.is-closed .story-hint {
    opacity: 1;
    transform: none;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .story-book-wrap,
    .story-cover,
    .flip-leaf {
        transition-duration: 1ms !important;
    }
}

.flipbook {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 14px 16px 18px;
    box-sizing: border-box;
    perspective: 2400px;
    transform-style: preserve-3d;
}

.flip-base,
.flip-face {
    overflow: hidden;
    color: #142029;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 28%),
        linear-gradient(90deg, #d2dee8 0%, #e6eef4 52%, #d5e1eb 100%);
    box-shadow: inset 0 0 40px rgba(20, 40, 55, 0.08);
}

.flip-base {
    position: absolute;
    top: 14px;
    bottom: 18px;
    width: calc(50% - 16px);
    z-index: 1;
}

.flip-base--left {
    left: 16px;
    border-radius: 3px 0 0 3px;
    background:
        linear-gradient(90deg, rgba(10, 20, 30, 0.08), transparent 20%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 28%),
        linear-gradient(90deg, #c8d7e2 0%, #e2ebf1 55%, #d5e2ec 100%);
    box-shadow: inset -12px 0 22px rgba(10, 25, 35, 0.07);
}

.flip-base--right {
    right: 16px;
    border-radius: 0 3px 3px 0;
    background:
        linear-gradient(270deg, rgba(10, 20, 30, 0.07), transparent 18%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 28%),
        linear-gradient(90deg, #dce7ef 0%, #e8f0f6 50%, #cedbe6 100%);
    box-shadow: inset 12px 0 22px rgba(10, 25, 35, 0.06);
}

.flip-leaf {
    position: absolute;
    top: 14px;
    bottom: 18px;
    left: 50%;
    width: calc(50% - 16px);
    z-index: 4;
    transform-origin: left center;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform var(--flip-ms) var(--flip-ease);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.flip-leaf.is-ready {
    opacity: 1;
    visibility: visible;
}

.flip-leaf.is-forward {
    transform: rotateY(-180deg);
}

.flip-leaf.is-back-start {
    transform: rotateY(-180deg);
    transition: none;
}

.flip-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 0 3px 3px 0;
}

.flip-face--front {
    z-index: 2;
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.28),
        inset 12px 0 22px rgba(10, 25, 35, 0.06);
}

.flip-face--back {
    transform: rotateY(180deg);
    border-radius: 3px 0 0 3px;
    background:
        linear-gradient(90deg, rgba(10, 20, 30, 0.08), transparent 20%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 28%),
        linear-gradient(90deg, #c8d7e2 0%, #e2ebf1 55%, #d5e2ec 100%);
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.28),
        inset -12px 0 22px rgba(10, 25, 35, 0.07);
}

/* Dynamic shade across the turning leaf */
.flip-leaf::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.28) 0%,
        rgba(0, 0, 0, 0.05) 42%,
        rgba(255, 255, 255, 0.08) 58%,
        rgba(0, 0, 0, 0.22) 100%
    );
    opacity: 0;
    transition: opacity 0.2s ease;
    backface-visibility: hidden;
}

.flip-leaf.is-ready::before {
    opacity: 0.55;
    animation: flipShadePulse var(--flip-ms) var(--flip-ease);
}

@keyframes flipShadePulse {
    0% { opacity: 0.15; }
    45% { opacity: 0.75; }
    100% { opacity: 0.2; }
}

.flip-inner {
    position: relative;
    height: 100%;
    padding: clamp(22px, 3.5vw, 40px) clamp(18px, 3vw, 34px);
    box-sizing: border-box;
    text-align: left;
}

.flip-inner--center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.story-page-num {
    position: absolute;
    bottom: 14px;
    font-family: "Cinzel", serif;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    color: #5a7382;
}

.flip-base--left .story-page-num,
.flip-face--back .story-page-num { left: 22px; }

.flip-base--right .story-page-num,
.flip-face--front .story-page-num { right: 22px; }

.story-chapter {
    font-family: "Cinzel", serif;
    font-size: 0.72rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: #0e6f86;
    margin: 0 0 10px;
}

.flip-inner h3 {
    font-family: "Cinzel", serif;
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
    font-weight: 700;
    color: #0b1c28;
    margin: 0 0 14px;
    line-height: 1.25;
    letter-spacing: 0.04em;
}

.flip-inner p {
    font-family: "Literata", Georgia, serif;
    font-size: clamp(0.92rem, 1.5vw, 1.02rem);
    line-height: 1.72;
    color: #243542;
    margin: 0;
}

.flip-inner--dark {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(0, 180, 216, 0.14), transparent 55%),
        linear-gradient(160deg, #102030 0%, #071018 55%, #040a10 100%);
    color: #e8f4f8;
    box-shadow: inset 0 0 0 1px rgba(120, 200, 220, 0.15);
}

.flip-base .flip-inner--dark,
.flip-face .flip-inner--dark {
    position: absolute;
    inset: 0;
}

.flip-inner--dark h3 {
    color: #f2fafc;
    font-size: clamp(1.35rem, 2.6vw, 1.8rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.flip-inner--dark p {
    color: #9fc0ce;
    max-width: 16rem;
}

.story-cover-mark {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 18px;
    box-shadow: 0 0 0 2px rgba(0, 180, 216, 0.45), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.story-ornament {
    width: 72px;
    height: 1px;
    margin: 16px auto;
    background: linear-gradient(90deg, transparent, #3aa8c0, transparent);
}

.story-book.is-flipping .story-page-hit {
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .flip-leaf {
        transition-duration: 1ms !important;
    }
}

.story-book-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 22px auto 0;
}

.story-nav-btn {
    font-family: "Cinzel", serif;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #caf0f8;
    background: rgba(8, 24, 36, 0.75);
    border: 1px solid rgba(0, 180, 216, 0.35);
    padding: 10px 18px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.story-nav-btn:hover:not(:disabled) {
    color: #fff;
    border-color: rgba(0, 180, 216, 0.75);
    background: rgba(0, 100, 130, 0.35);
    transform: translateY(-1px);
}

.story-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.story-page-indicator {
    font-family: "Literata", Georgia, serif;
    font-size: 0.95rem;
    color: #8eb0be;
    min-width: 5.5rem;
}

.story-hint {
    margin: 14px 0 0;
    font-size: 0.82rem;
    color: #6f8f9c;
    letter-spacing: 0.04em;
}

.story-page-hit {
    position: absolute;
    top: 14px;
    bottom: 18px;
    width: 18%;
    z-index: 3;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.story-page-hit--prev { left: 16px; }

/* Clickable next page (right half of the open book) */
.story-page-hit--next {
    right: 16px;
    left: 50%;
    width: auto;
}

.footer-credits {
    margin-top: 48px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 28px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #8899a6;
    text-shadow: 0 2px 4px #000;
}

.footer-credits span {
    color: #00b4d8;
    text-shadow: 0 0 10px rgba(0, 180, 216, 0.6);
}

@media (max-width: 900px) {
    .features-section {
        padding: 110px 16px 60px !important;
    }

    .story-book-wrap {
        --book-h: min(620px, 78vh);
    }

    .story-book-spine {
        display: none;
    }

    .flip-base--left {
        display: none;
    }

    .flip-base--right,
    .flip-leaf {
        left: 12px;
        right: 12px;
        width: auto;
        border-radius: 4px;
    }

    .flip-leaf {
        transform-origin: left center;
    }

    .flip-face,
    .flip-face--back {
        border-radius: 4px;
    }

    .story-hint {
        display: none;
    }

    /* Single-page mobile: whole page is the “next” tap target */
    .story-page-hit--next {
        left: 12px;
        right: 12px;
        width: auto;
    }
}
