/* Shared responsive behavior for every page. */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    min-width: 0;
}

img {
    display: block;
    max-width: 100%;
}

nav {
    gap: 2rem;
}

.logo {
    flex-shrink: 0;
}

.nav-links {
    align-items: center;
}

.nav-links a {
    display: flex;
    align-items: center;
    min-height: 44px;
}

.nav-links a[aria-current="page"] {
    color: #222;
    text-decoration: underline;
    text-underline-offset: 6px;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid #222;
    outline-offset: 4px;
}

.menu-toggle {
    display: none;
}

.container,
.book-info,
.story-card {
    min-width: 0;
    overflow-wrap: anywhere;
}

.book-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.book-links .btn {
    margin: 0;
    text-align: center;
}

footer,
footer a {
    color: #666;
}

/* Collapse navigation before the desktop links run out of space. */
@media (max-width: 1024px) {
    nav {
        flex-wrap: wrap;
        gap: 0 1rem;
        padding: 0.75rem 1.25rem;
    }

    .logo {
        font-size: 1.25rem;
        letter-spacing: 1px;
    }

    .menu-toggle:not([hidden]) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.65rem;
        min-height: 44px;
        padding: 0.5rem 0.65rem;
        border: 1px solid #d8d8d8;
        border-radius: 3px;
        color: #222;
        background: #fff;
        font: inherit;
        font-size: 0.95rem;
        cursor: pointer;
    }

    .menu-icon {
        display: block;
        width: 16px;
        height: 10px;
        border-top: 1px solid currentColor;
        border-bottom: 1px solid currentColor;
    }

    .nav-links {
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-top: 0.75rem;
        padding: 0.5rem 0;
        border-top: 1px solid #e5e5e5;
        max-height: calc(100svh - 85px);
        overflow-y: auto;
    }

    /* Links remain available if JavaScript does not load. */
    nav[data-menu-ready] .nav-links {
        display: none;
    }

    nav[data-menu-ready] .menu-toggle[aria-expanded="true"] + .nav-links {
        display: flex;
    }

    .nav-links a {
        padding: 0.65rem 0.25rem;
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1.25rem;
    }

    section {
        padding: 2rem 0;
    }

    h2 {
        font-size: 1.875rem;
        line-height: 1.25;
        margin-bottom: 1.5rem;
    }

    .about-content,
    .contact-content,
    .book-info p {
        font-size: 1.0625rem;
        line-height: 1.75;
    }

    .hero-image {
        height: auto;
    }

    .hero-image img {
        height: auto;
        width: 100%;
    }

    .hero-text {
        position: static;
        padding: 1.75rem 1.25rem 2rem;
        background: #f5f5f5;
        color: #222;
    }

    .hero-text h1 {
        font-size: clamp(2rem, 8vw, 2.75rem);
        line-height: 1.15;
        text-shadow: none;
        margin-bottom: 0.75rem;
    }

    .hero-text p {
        font-size: 1.0625rem;
        text-shadow: none;
    }

    .stories-grid {
        gap: 1.75rem;
        margin-top: 0;
    }

    .story-card {
        padding-left: 1rem;
    }

    .story-card h3 {
        font-size: 1.1875rem;
        line-height: 1.4;
    }

    .story-card .description {
        font-size: 1rem;
    }

    .book-section {
        padding: 2rem 1.25rem;
    }

    .book-content {
        gap: 2rem;
    }

    .book-cover {
        max-width: 240px;
        margin: 0 auto;
        height: auto;
    }

    .book-info h2 {
        font-size: 1.875rem;
        line-height: 1.25;
    }

    .book-links {
        flex-direction: column;
        margin-top: 1.5rem;
    }

    footer {
        margin-top: 2rem;
        padding: 1.25rem;
        font-size: 0.8125rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    a {
        transition: none !important;
    }
}

@media (max-width: 360px) {
    nav {
        column-gap: 0.5rem;
        padding-inline: 1rem;
    }

    .logo {
        font-size: 1.125rem;
    }
}
