/* ── Author Site — Base Layout (no visual styling) ───────────────────────────
   This file handles structure, grid, spacing, and responsive behaviour only.
   All colors, fonts, shadows, and decorative styles belong in a theme file.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Reset ───────────────────────────────────────────────────────────────────*/

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; }
button { font: inherit; color: inherit; }

/* Ensure [hidden] always wins over any explicit display: flex/block rules */
[hidden] { display: none !important; }

.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }

/* ── Theme loading ───────────────────────────────────────────────────────────
   loadTheme() sets .theme-pending until the theme's styles and fonts arrive, so
   readers see the spinner rather than an unstyled page. */

body.theme-pending > :not(#site-loading):not(script) { visibility: hidden; }
body.theme-pending > #site-loading { display: flex !important; }

/* ── Layout tokens (overrideable by theme) ───────────────────────────────────*/

:root {
    --site-max-width: 1140px;
    --section-pad-y: 5.5rem;
    --section-pad-x: 1.5rem;
    --nav-height: 64px;
}

/* ── Accessibility ───────────────────────────────────────────────────────────*/

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 10000;
    padding: .6rem 1rem;
    text-decoration: none;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
    .book-card:hover, .post-card:hover, .product-card:hover,
    .gallery-image-wrap:hover .gallery-image, .world-card:hover .world-image,
    .post-image-link:hover .post-image { transform: none !important; }
}

/* ── Loading state ───────────────────────────────────────────────────────────*/

.site-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Coming-soon state ───────────────────────────────────────────────────────*/

.site-coming-soon {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.coming-soon-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--section-pad-y) var(--section-pad-x);
}

.coming-soon-label {
    font-size: .85rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
}

.coming-soon-name {
    font-size: clamp(2.25rem, 6vw, 4rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.coming-soon-message {
    font-size: 1.05rem;
    max-width: 440px;
    line-height: 1.7;
}

.coming-soon-cta {
    display: inline-block;
    margin-top: 2rem;
    padding: .75rem 1.75rem;
    text-decoration: none;
}

.coming-soon-owner {
    margin-top: 2.5rem;
    font-size: .8rem;
    opacity: .65;
}

.coming-soon-owner a { color: inherit; }

/* ── Not-found state ─────────────────────────────────────────────────────────*/

.site-not-found {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.not-found-inner { max-width: 440px; display: flex; flex-direction: column; align-items: center; }
.not-found-icon  { margin-bottom: 1.25rem; opacity: .7; }
.not-found-inner h1 { font-size: 1.75rem; margin-bottom: .75rem; }
.not-found-inner p  { margin-bottom: 1.5rem; }
.ppd-cta {
    display: inline-block;
    padding: .6rem 1.5rem;
    text-decoration: none;
}

/* ── Navigation ──────────────────────────────────────────────────────────────*/

.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
}

.nav-container {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding: 0 var(--section-pad-x);
    height: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-brand {
    font-size: 1.15rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.nav-author-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.6rem;
    margin-left: auto;
}

.nav-links a {
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
    padding: .35rem 0;
    border-bottom: 2px solid transparent;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 44px;
    height: 44px;
    padding: 13px 10px;
    background: none;
    border: none;
    cursor: pointer;
    margin-left: auto;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    transition: transform .2s, opacity .2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ── Hero section ────────────────────────────────────────────────────────────*/

.site-section--hero {
    position: relative;
    min-height: min(62vh, 620px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--section-pad-y) var(--section-pad-x);
}

.site-section--hero.hero--featured { min-height: min(86vh, 760px); }

/* Dark overlay shown when a hero background image is set via JS */
.hero-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, .45) 100%);
    pointer-events: none;
}

.hero--has-image .hero-overlay { display: block; }

/* Themes may draw a decorative layer (particles, gears, lines…) on .site-section--hero::before
   at z-index 1; content sits above it. */
.site-section--hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.hero-layout {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--site-max-width);
    display: flex;
    justify-content: center;
}

.hero-inner {
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.hero-genre   { font-size: .82rem; letter-spacing: .16em; text-transform: uppercase; }
.hero-name    { font-size: clamp(2.5rem, 6.5vw, 4.75rem); line-height: 1.05; }
.hero-tagline { font-size: clamp(1.05rem, 2.2vw, 1.35rem); max-width: 560px; line-height: 1.55; }
.hero-cta     { display: inline-block; padding: .8rem 2rem; margin-top: .75rem; text-decoration: none; }

/* With a featured book: author on the left, book on the right */
.hero--featured { text-align: left; }
.hero--featured .hero-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: center;
}
.hero--featured .hero-inner { align-items: flex-start; }

.hero-feature {
    display: grid;
    grid-template-columns: minmax(150px, 230px) minmax(0, 1fr);
    gap: 1.75rem;
    align-items: center;
}

.hero-feature-cover { display: block; aspect-ratio: 2/3; }
.hero-feature-img,
.hero-feature-cover .book-cover-placeholder { width: 100%; height: 100%; object-fit: cover; }

.hero-feature-info  { display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; }
.hero-feature-label { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.hero-feature-title { font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.15; }
.hero-feature-title a { color: inherit; text-decoration: none; }
.hero-feature-title a:hover { text-decoration: underline; text-underline-offset: 4px; }
.hero-feature-series { font-size: .9rem; }
.hero-feature-blurb { font-size: .98rem; line-height: 1.65; }
.hero-feature-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-top: .5rem; }

.hero-feature-buy {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .75rem 1.6rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
}
.hero-feature-more { font-weight: 600; text-decoration: none; }
.hero-feature-more:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ── Generic section container ───────────────────────────────────────────────*/

.site-section {
    padding: var(--section-pad-y) var(--section-pad-x);
    scroll-margin-top: var(--nav-height);
}

.section-container {
    max-width: var(--site-max-width);
    margin: 0 auto;
}

.section-heading {
    font-size: clamp(1.75rem, 3.4vw, 2.4rem);
    line-height: 1.15;
    margin-bottom: 2.75rem;
}

/* Section headings centre over their (centred) grids; About keeps its own alignment */
.section-container > .section-heading { text-align: center; }
.section-container > .section-heading::after { margin-left: auto; margin-right: auto; }

/* Card grids: fixed-width tracks, centred, so 1–3 items never hug the left edge */
.books-grid, .store-grid, .gallery-grid,
.blog-grid, .worldbuilding-grid, .reviews-grid { justify-content: center; }

.section-empty {
    opacity: .7;
    font-style: italic;
}

/* ── About section ───────────────────────────────────────────────────────────*/

.about-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 4rem;
    align-items: start;
    max-width: 980px;
    margin: 0 auto;
}

.about-photo-wrap {
    position: sticky;
    top: calc(var(--nav-height) + 2rem);
}

.about-photo,
.about-initials {
    width: 260px;
    height: 320px;
    object-fit: cover;
}

/* Shape the author picked in the dashboard (no class = the theme's own shape). Two
   classes so it beats each theme's .about-photo rule; theme frames and shadows follow. */
.about-photo.about-photo--circle,  .about-initials.about-photo--circle    { width: 260px; height: 260px; border-radius: 50%; }
.about-photo.about-photo--square,  .about-initials.about-photo--square    { width: 260px; height: 260px; border-radius: var(--t-radius-lg, 0); }
.about-photo.about-photo--rectangle, .about-initials.about-photo--rectangle { width: 260px; height: 320px; border-radius: var(--t-radius-lg, 0); }

.about-initials {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: 700;
}

.about-content .section-heading { margin-bottom: 1.5rem; }

.about-bio {
    font-size: 1.08rem;
    line-height: 1.85;
    margin-bottom: 1.75rem;
    white-space: pre-line;
    max-width: 65ch;
}

.about-socials {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .95rem;
    font-size: .85rem;
    text-decoration: none;
    border-radius: 999px;
}

/* ── Books grid ──────────────────────────────────────────────────────────────*/

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 250px));
    gap: 2.25rem 2rem;
}

.book-card {
    display: flex;
    flex-direction: column;
    position: relative;
}

.book-cover-wrap {
    position: relative;
    display: block;
    aspect-ratio: 2/3;
    overflow: hidden;
    flex-shrink: 0;
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No cover image: a typeset title card instead */
.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    text-align: center;
    font-size: 1.25rem;
    line-height: 1.25;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.book-badge {
    position: absolute;
    top: .6rem;
    right: .6rem;
    padding: .25rem .6rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
}

.book-info {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.book-title  { font-size: 1.08rem; margin-bottom: .25rem; line-height: 1.3; }
.book-title a { color: inherit; text-decoration: none; }
.book-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.book-series { font-size: .82rem; margin-bottom: .4rem; }

.book-actions {
    display: flex;
    gap: .5rem;
    margin-top: auto;
    padding-top: .75rem;
    flex-wrap: wrap;
    align-items: center;
}

.book-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .5rem .95rem;
    font-size: .82rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

/* Buy menu (several retailers) */
.book-buy { position: relative; }

.book-buy-menu {
    position: absolute;
    bottom: calc(100% + .4rem);
    left: 0;
    z-index: 20;
    min-width: 190px;
    padding: .35rem;
    display: flex;
    flex-direction: column;
}

.book-buy-option {
    display: block;
    padding: .55rem .75rem;
    font-size: .85rem;
    text-decoration: none;
    white-space: nowrap;
}
.book-buy-option--shop { display: flex; align-items: center; gap: .4rem; font-weight: 600; }

/* Book page: Buy Now under the title; its menu opens downwards */
.book-detail-actions { margin: 1.25rem 0 1.5rem; }
.book-detail-actions .book-buy { display: inline-block; }
.book-detail-actions .book-buy-menu { bottom: auto; top: calc(100% + .4rem); }

/* ── Books section — explore more ───────────────────────────────────────────*/

.books-more,
.blog-more,
.events-more,
.gallery-more,
.worldbuilding-more,
.reviews-more,
.store-more {
    text-align: center;
    margin-top: 3rem;
}

.books-more-btn,
.blog-more-btn,
.events-more-btn,
.gallery-more-btn,
.worldbuilding-more-btn,
.reviews-more-btn,
.store-more-btn {
    display: inline-block;
    padding: .75rem 2rem;
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
}

/* ── Listing / detail pages ──────────────────────────────────────────────────*/

.books-listing-page,
.book-detail-page,
.blog-listing-page,
.post-detail-page,
.events-listing-page,
.event-detail-page { min-height: calc(100vh - var(--nav-height)); }

.book-detail-back,
.post-detail-back,
.event-detail-back {
    display: inline-block;
    font-size: .88rem;
    text-decoration: none;
    margin-bottom: 2rem;
}

/* ── Book detail page ────────────────────────────────────────────────────────*/

.book-detail-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 4rem;
    align-items: start;
}

.book-detail-cover-wrap { position: relative; }

.book-detail-cover {
    width: 100%;
    display: block;
}

.book-detail-cover-placeholder {
    aspect-ratio: 2/3;
    font-size: 1.6rem;
}

.book-detail-info {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.book-detail-title    { font-size: clamp(1.9rem, 4vw, 2.9rem); line-height: 1.12; margin: 0; }
.book-detail-subtitle { font-size: 1.15rem; font-style: italic; margin: 0; }
.book-detail-series   { font-size: .95rem; margin: 0; }
.book-detail-genre    { font-size: .88rem; margin: 0; }

.book-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem 1.25rem;
    margin-top: .25rem;
}

.book-detail-meta-item { font-size: .88rem; }

.book-detail-desc {
    font-size: 1.05rem;
    line-height: 1.85;
    margin-top: 1rem;
    white-space: pre-line;
    max-width: 68ch;
}

.book-detail-store-btn {
    display: inline-block;
    padding: .7rem 1.6rem;
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
    margin-top: 1rem;
    align-self: flex-start;
}

/* ── Blog grid ───────────────────────────────────────────────────────────────*/

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
    gap: 2rem;
}

.post-card { display: flex; flex-direction: column; overflow: hidden; }

.post-image-link  { display: block; overflow: hidden; }
.post-image-wrap  { aspect-ratio: 16/9; overflow: hidden; }
.post-image       { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.post-image-link:hover .post-image { transform: scale(1.03); }
.post-body        { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.post-meta-row    { display: flex; align-items: center; gap: .65rem; margin-bottom: .5rem; flex-wrap: wrap; }
.post-date        { font-size: .8rem; display: block; }
.post-reading-time { font-size: .8rem; }
.post-title       { font-size: 1.15rem; margin-bottom: .5rem; line-height: 1.3; }
.post-title a     { color: inherit; text-decoration: none; }
.post-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.post-excerpt     { font-size: .92rem; line-height: 1.6; margin-bottom: .75rem; flex: 1; }
.post-tag         { display: inline-block; font-size: .72rem; padding: .2rem .55rem; }
.post-footer      { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding-top: .75rem; }
.post-read-more   { font-size: .88rem; font-weight: 600; text-decoration: none; }
.post-read-more:hover { text-decoration: underline; }

/* ── Blog post detail page ───────────────────────────────────────────────────*/

.post-detail-page .section-container,
.event-detail-page .section-container { max-width: 780px; }

.post-detail-image {
    width: 100%;
    max-height: 440px;
    object-fit: cover;
    display: block;
    margin-bottom: 2.25rem;
}

.post-detail-header { margin-bottom: 2.25rem; }

.post-detail-title {
    font-size: clamp(1.9rem, 4vw, 2.8rem);
    line-height: 1.15;
    margin: .6rem 0;
}

.post-detail-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: .75rem;
    flex-wrap: wrap;
}

.post-detail-body {
    font-size: 1.1rem;
    line-height: 1.85;
    max-width: 68ch;
}

.post-detail-body h2 { font-size: 1.55rem; margin: 2.25rem 0 .75rem; line-height: 1.25; }
.post-detail-body h3 { font-size: 1.25rem; margin: 1.75rem 0 .5rem; line-height: 1.3; }
.post-detail-body p  { margin-bottom: 1.25rem; }
.post-detail-body ul,
.post-detail-body ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.post-detail-body ul { list-style: disc; }
.post-detail-body ol { list-style: decimal; }
.post-detail-body li { margin-bottom: .35rem; }
.post-detail-body a  { text-decoration: underline; text-underline-offset: 3px; }
.post-detail-body img { margin: 1.5rem 0; }
.post-detail-body blockquote { margin: 1.5rem 0; padding-left: 1.25rem; border-left: 3px solid; font-style: italic; }

.post-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid;
}

/* ── Events ──────────────────────────────────────────────────────────────────*/

.events-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 860px;
    margin: 0 auto;
}

.event-card        { display: flex; overflow: hidden; }
.event-image-wrap  { flex-shrink: 0; width: 180px; overflow: hidden; }
.event-image       { width: 100%; height: 100%; object-fit: cover; }
.event-body        { padding: 1.4rem 1.5rem; display: flex; flex-direction: column; justify-content: center; flex: 1; }
.event-meta-row    { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .55rem; }
.event-title       { font-size: 1.2rem; margin-bottom: .55rem; line-height: 1.3; }
.event-title a     { text-decoration: none; }
.event-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.event-date,
.event-venue       { display: flex; align-items: flex-start; gap: .45rem; font-size: .88rem; margin-bottom: .3rem; }
.event-date .icon,
.event-venue .icon { margin-top: .15rem; }
.event-desc        { font-size: .92rem; line-height: 1.6; margin: .35rem 0 .9rem; }
.event-actions     { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.event-cta         { display: inline-block; padding: .5rem 1.2rem; text-decoration: none; }
.event-details-link { font-size: .88rem; text-decoration: none; }
.event-details-link:hover { text-decoration: underline; }

.event-type-badge  { display: inline-block; padding: .2rem .6rem; font-size: .72rem; font-weight: 600; border-radius: 3px; letter-spacing: .03em; text-transform: uppercase; }
.event-price-badge { display: inline-block; padding: .2rem .6rem; font-size: .72rem; font-weight: 600; border-radius: 3px; }

/* ── Event detail page ───────────────────────────────────────────────────────*/

.event-detail-poster {
    width: 100%;
    max-height: 440px;
    object-fit: cover;
    border-radius: var(--t-radius-lg);
    margin-bottom: 2rem;
}

.event-detail-header { margin-bottom: 2rem; }

.event-detail-badges { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }

.event-format-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .65rem;
    font-size: .78rem;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.event-detail-title {
    font-size: clamp(1.9rem, 4vw, 2.8rem);
    line-height: 1.15;
    margin-bottom: 1rem;
}

.event-detail-meta {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    font-size: .95rem;
    margin-bottom: 1.5rem;
}

.event-detail-meta span { display: flex; align-items: center; gap: .5rem; }

.event-detail-body { font-size: 1.08rem; line-height: 1.85; margin-bottom: 2rem; }
.event-detail-body h2 { font-size: 1.45rem; margin: 1.75rem 0 .75rem; }
.event-detail-body h3 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
.event-detail-body p  { margin-bottom: 1rem; }
.event-detail-body ul,
.event-detail-body ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.event-detail-body ul { list-style: disc; }
.event-detail-body ol { list-style: decimal; }
.event-detail-body li { margin-bottom: .3rem; }
.event-detail-body a  { text-decoration: underline; }

.event-detail-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--t-radius-lg);
    margin-bottom: 2rem;
}

.event-info-block { display: flex; flex-direction: column; gap: .3rem; }
.event-info-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.event-info-value { font-size: .95rem; }

.event-detail-register {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--t-radius-lg);
}

.event-register-btn {
    display: inline-block;
    padding: .75rem 2rem;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    border-radius: var(--t-radius);
    transition: background .15s;
}

.event-capacity-note { font-size: .88rem; }

.event-featured-books { margin-top: 2.5rem; }
.event-featured-books h3 { font-size: 1.2rem; margin-bottom: 1.25rem; }
.event-featured-books .books-grid { justify-content: start; }

/* ── Gallery ─────────────────────────────────────────────────────────────────*/

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 270px));
    gap: 1rem;
}

.gallery-item       { margin: 0; overflow: hidden; }
.gallery-image-wrap {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}
.gallery-image      { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery-caption    { font-size: .8rem; padding: .5rem .6rem; }

.gallery-category-badge {
    position: absolute;
    bottom: .5rem;
    left: .5rem;
    font-size: .68rem;
    padding: .2rem .5rem;
    border-radius: 3px;
    pointer-events: none;
}

/* ── Gallery lightbox ────────────────────────────────────────────────────────*/

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .9);
    padding: 1.5rem;
}

.gallery-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    opacity: .85;
}
.gallery-lightbox-close:hover { opacity: 1; }
.gallery-lightbox-close:focus-visible { outline: 2px solid #fff; }

.gallery-lightbox-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(90vw, 1000px);
    max-height: 90vh;
    gap: .75rem;
}

.gallery-lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.gallery-lightbox-info { text-align: center; }
.gallery-lightbox-title { color: #fff; font-size: 1rem; font-weight: 600; margin: 0 0 .25rem; }
.gallery-lightbox-desc  { color: rgba(255,255,255,.8); font-size: .9rem; margin: 0; }

/* ── Worldbuilding ───────────────────────────────────────────────────────────*/

.worldbuilding-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
    gap: 2rem;
}

.world-card        { display: flex; flex-direction: column; overflow: hidden; }
.world-image-wrap  { aspect-ratio: 16/9; overflow: hidden; }
.world-image       { width: 100%; height: 100%; object-fit: cover; }
.world-body        { padding: 1rem 0; flex: 1; }
.world-tag         { display: inline-block; font-size: .72rem; padding: .2rem .55rem; margin-bottom: .6rem; }
.world-title       { font-size: 1.15rem; margin-bottom: .5rem; line-height: 1.3; }
.world-desc        { font-size: .92rem; line-height: 1.6; }

/* ── Worldbuilding listing page ──────────────────────────────────────────────*/

.worldbuilding-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 2rem;
}

.world-filter-btn {
    padding: .4rem 1rem;
    font-size: .85rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.world-summary { font-size: .85rem; margin-bottom: .4rem; font-style: italic; }

/* ── Reviews ─────────────────────────────────────────────────────────────────*/

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
    gap: 1.75rem;
}

.review-card         { padding: 1.75rem; position: relative; display: flex; flex-direction: column; }
.review-card--featured::before {
    content: '★ Featured';
    position: absolute;
    top: .85rem; right: .85rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    padding: .2rem .55rem;
    border-radius: 99px;
}
.review-stars        { font-size: 1.1rem; letter-spacing: .1em; margin-bottom: .85rem; }
.review-text         { font-size: 1rem; line-height: 1.7; font-style: italic; margin-bottom: 1.25rem; flex: 1; }
.review-footer       { display: flex; flex-direction: column; gap: .4rem; }
.review-name         { font-size: .9rem; font-weight: 600; font-style: normal; }
.review-meta         { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.review-source-badge { font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; }
.review-date         { font-size: .78rem; }

.reviews-source-filter { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-bottom: 2rem; }
.reviews-filter-btn    { padding: .45rem 1.05rem; border-radius: 99px; border: none; cursor: pointer; font-size: .85rem; font-weight: 500; transition: background .15s, color .15s; }

/* ── Store ───────────────────────────────────────────────────────────────────*/

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 260px));
    gap: 2rem;
}

.product-card       { display: flex; flex-direction: column; overflow: hidden; }
.product-image-wrap { aspect-ratio: 1; overflow: hidden; }
.product-image      { width: 100%; height: 100%; object-fit: cover; }
.product-body       { padding: 1rem 0; flex: 1; display: flex; flex-direction: column; }
.product-title      { font-size: 1.05rem; margin-bottom: .35rem; line-height: 1.3; }
.product-desc       { font-size: .88rem; line-height: 1.6; flex: 1; margin-bottom: .75rem; }
.product-price      { font-size: 1.1rem; font-weight: 700; margin-bottom: .6rem; }
.product-cta        { display: block; width: 100%; text-align: center; padding: .6rem; text-decoration: none; margin-top: auto; border: none; cursor: pointer; font: inherit; }
.product-checkout-error { margin-bottom: 1rem; font-weight: 600; }
.store-book-filter { margin: -.5rem 0 2rem; text-align: center; font-family: var(--t-ui-font); font-size: .95rem; color: var(--t-text-muted); }
.store-book-filter strong { color: var(--t-text); }
.product-format-note { font-family: var(--t-ui-font); font-size: .8rem; color: var(--t-text-muted); margin: 0 0 .5rem; }

/* ── Cart (author/cart.js) ─────────────────────────────────────────────────────
   A floating button and a side panel. Colours come from the theme's tokens. */
.cart-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cart-toggle {
    position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 900;
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .75rem 1rem; border: none; border-radius: 999px; cursor: pointer;
    background: var(--t-accent); color: var(--t-on-accent);
    font-family: var(--t-ui-font); font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.cart-toggle:focus-visible { outline: 3px solid var(--t-focus, currentColor); outline-offset: 3px; }
.cart-drawer {
    margin: 0 0 0 auto; padding: 0; border: none; max-width: none; max-height: none;
    width: min(420px, 100vw); height: 100%;
    background: var(--t-surface, #fff); color: var(--t-text, #222);
    font-family: var(--t-ui-font);
}
.cart-drawer::backdrop { background: rgba(0,0,0,.45); }
.cart-panel { display: flex; flex-direction: column; height: 100%; padding: 1.25rem; }
.cart-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: .75rem; border-bottom: 1px solid var(--t-border, #ddd); }
.cart-title { font-size: 1.25rem; margin: 0; }
.cart-close { border: none; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; padding: .25rem .5rem; }
.cart-message { margin: .75rem 0 0; padding: .6rem .75rem; border-radius: var(--t-radius, 6px); background: var(--t-bg, #f5f5f5); font-size: .9rem; }
.cart-items { flex: 1; overflow-y: auto; margin: 0; padding: .5rem 0; list-style: none; }
.cart-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: .85rem; padding: .85rem 0; border-bottom: 1px solid var(--t-border, #ddd); }
.cart-item--unavailable .cart-item-image, .cart-item--unavailable .cart-item-name { opacity: .5; }
.cart-item-image { width: 64px; height: 64px; object-fit: cover; border-radius: var(--t-radius, 6px); background: var(--t-bg, #eee); display: block; }
.cart-item-name { font-weight: 600; margin: 0; line-height: 1.3; }
.cart-item-meta { margin: .15rem 0 0; font-size: .85rem; color: var(--t-text-muted); }
.cart-item-error { margin: .35rem 0 0; font-size: .82rem; font-weight: 600; color: #b42318; }
.cart-item-actions { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.cart-qty-btn { width: 2rem; height: 2rem; border: 1px solid var(--t-border, #ccc); border-radius: var(--t-radius, 6px); background: none; cursor: pointer; font-size: 1rem; }
.cart-qty-btn:disabled { opacity: .4; cursor: not-allowed; }
.cart-qty { min-width: 1.5rem; text-align: center; font-weight: 600; }
.cart-remove { margin-left: auto; border: none; background: none; cursor: pointer; font-size: .85rem; text-decoration: underline; color: var(--t-text-muted); }
.cart-empty { flex: 1; padding: 2rem 0; text-align: center; color: var(--t-text-muted); }
.cart-footer { padding-top: 1rem; border-top: 1px solid var(--t-border, #ddd); }
.cart-subtotal { display: flex; justify-content: space-between; font-size: 1.05rem; margin: 0 0 .35rem; }
.cart-fine-print { font-size: .8rem; color: var(--t-text-muted); margin: 0 0 1rem; }
.cart-checkout:disabled { opacity: .6; cursor: not-allowed; }
.cart-secure { margin: .6rem 0 0; text-align: center; font-size: .75rem; color: var(--t-text-muted); }
@media (max-width: 540px) {
    .cart-toggle { right: 1rem; bottom: 1rem; }
    .cart-panel { padding: 1rem; }
}

/* ── Shop policies page (store/policies.html) ─────────────────────────────────*/
.policies-page { min-height: calc(100vh - var(--nav-height)); }
.policies-container { max-width: 760px; }
.policies-section { margin-top: 2.25rem; }
.policies-section-title { font-size: 1.3rem; margin: 0 0 .6rem; }
.policies-text { line-height: 1.8; white-space: pre-line; }
.policies-text--default { color: var(--t-text-muted); }

/* ── Newsletter band ─────────────────────────────────────────────────────────*/

.site-section--newsletter { padding-top: 3.5rem; padding-bottom: 3.5rem; }

.newsletter-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem 3rem;
    flex-wrap: wrap;
}

.newsletter-title { font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.2; margin-bottom: .4rem; }
.newsletter-desc  { font-size: 1rem; line-height: 1.6; max-width: 52ch; }
.newsletter-cta {
    display: inline-block;
    padding: .85rem 2.25rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

/* ── Contact ─────────────────────────────────────────────────────────────────*/

.site-section--contact .section-container { max-width: 720px; }

.contact-block-desc {
    font-size: 1.02rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.contact-form { display: flex; flex-direction: column; gap: 1rem; }
.contact-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.contact-field { display: flex; flex-direction: column; gap: .4rem; }
.contact-label { font-size: .85rem; font-weight: 600; }

.contact-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* ── Footer ──────────────────────────────────────────────────────────────────*/

.site-footer { padding: 3.5rem var(--section-pad-x) 2.5rem; text-align: center; }
.footer-container {
    max-width: var(--site-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
}
.footer-name  { font-size: 1.35rem; }

.footer-socials { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.social-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    text-decoration: none;
}

.footer-newsletter {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .92rem;
    font-weight: 600;
    text-decoration: none;
}
.footer-newsletter:hover { text-decoration: underline; }

.footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .35rem 1.25rem;
    font-size: .8rem;
    margin-top: .5rem;
}
.footer-ppd { text-decoration: none; }
.footer-ppd:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────────────────────────*/

@media (max-width: 1024px) {
    .nav-links { gap: 1.15rem; }
    .nav-links a { font-size: .85rem; }

    .hero--featured .hero-layout { grid-template-columns: 1fr; text-align: center; }
    .hero--featured .hero-inner { align-items: center; margin: 0 auto; }
    .hero-feature { max-width: 620px; margin: 0 auto; text-align: left; }
}

/* Many nav items: collapse into the menu earlier than the layout breakpoint */
@media (max-width: 900px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: .5rem 0;
        max-height: calc(100vh - var(--nav-height));
        overflow-y: auto;
    }

    .nav-links.nav-open { display: flex; }
    .nav-links a { display: block; padding: .9rem var(--section-pad-x); font-size: 1rem; border-bottom: none; }
    .nav-toggle { display: flex; }
}

@media (max-width: 768px) {
    :root { --section-pad-y: 3.75rem; --section-pad-x: 1.25rem; }

    .about-layout { grid-template-columns: 1fr; gap: 2rem; }
    .about-photo-wrap { position: static; width: fit-content; }
    .about-photo, .about-initials { width: 180px; height: 220px; }
    .about-initials { font-size: 3rem; }

    .books-grid, .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 1rem; }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .blog-grid, .reviews-grid, .worldbuilding-grid { grid-template-columns: 1fr; }

    .book-actions { flex-direction: column; align-items: stretch; }
    .book-actions .book-btn, .book-buy, .book-buy .book-btn { width: 100%; justify-content: center; }
    .book-buy-menu { left: 0; right: 0; min-width: 0; }

    .event-card { flex-direction: column; }
    .event-image-wrap { width: 100%; aspect-ratio: 16/9; }

    .book-detail-layout { grid-template-columns: 1fr; gap: 2rem; }
    .book-detail-cover-wrap { max-width: 260px; }

    .contact-row { grid-template-columns: 1fr; }
    .newsletter-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 540px) {
    .site-section--hero.hero--featured { min-height: 0; }
    .hero-feature { grid-template-columns: 120px minmax(0, 1fr); gap: 1.1rem; align-items: start; }
    .hero-feature-blurb { display: none; }
    .hero-feature-title { font-size: 1.3rem; }
    .hero-feature-buy { padding: .65rem 1.2rem; }
    .book-cover-placeholder { font-size: 1rem; padding: .75rem; }
}

/* ── Item images (renderImageGallery in shared.js) ─────────────────────────────
   The extra images on a book, event, product or worldbuilding page. */
.item-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; margin: 1.5rem 0; }
.item-gallery-item { margin: 0; }
.item-gallery-thumb { display: block; width: 100%; padding: 0; border: 1px solid var(--t-border); border-radius: var(--t-radius); overflow: hidden; background: var(--t-surface); cursor: zoom-in; }
.item-gallery-thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .2s; }
.item-gallery-thumb:hover img { transform: scale(1.04); }
.item-gallery-thumb:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 2px; }
.item-gallery-caption { margin-top: .35rem; font-family: var(--t-ui-font); font-size: .8rem; color: var(--t-text-muted); line-height: 1.4; }
@media (prefers-reduced-motion: reduce) { .item-gallery-thumb img { transition: none; } }

/* ── Worldbuilding element page (worldbuilding/element.html) ──────────────────*/
.world-title a, .world-image-wrap { color: inherit; text-decoration: none; }
.world-title a:hover { text-decoration: underline; }
.world-image-wrap { display: block; }
.world-more { display: inline-block; margin-top: .5rem; font-family: var(--t-ui-font); font-size: .85rem; text-decoration: none; }
.world-detail-page { min-height: calc(100vh - var(--nav-height)); }
.world-detail-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 3rem; align-items: start; }
.world-detail-layout--no-image { grid-template-columns: minmax(0, 1fr); max-width: 780px; }
.world-detail-figure { margin: 0; }
.world-detail-main { display: block; width: 100%; padding: 0; border: none; border-radius: var(--t-radius-lg); overflow: hidden; background: none; cursor: zoom-in; box-shadow: var(--t-shadow); }
.world-detail-main img { display: block; width: 100%; height: auto; }
.world-detail-main:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 3px; }
.world-detail-title { font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.12; margin: 0 0 .5rem; }
.world-detail-series { font-size: .95rem; color: var(--t-text-muted); margin: 0 0 .75rem; }
.world-detail-summary { font-size: 1.1rem; font-style: italic; color: var(--t-text-muted); margin: 0 0 1rem; }
.world-detail-desc { font-size: 1.05rem; line-height: 1.85; white-space: pre-line; max-width: 68ch; }
.world-detail-facts { display: grid; gap: 1rem; margin: 1.75rem 0 0; }
.world-detail-fact dt { font-family: var(--t-ui-font); font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--t-text-muted); }
.world-detail-fact dd { margin: .2rem 0 0; line-height: 1.7; white-space: pre-line; }
.world-detail-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.5rem; }
.world-detail-more-heading { font-size: 1.3rem; margin: 3rem 0 0; }
@media (max-width: 768px) {
    .world-detail-layout { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
}

/* ── Product page (store/product.html) and linked shop cards ──────────────────*/
.product-image-wrap { display: block; position: relative; }
.product-title a { color: inherit; text-decoration: none; }
.product-title a:hover { text-decoration: underline; }
.product-more-images { position: absolute; right: .5rem; bottom: .5rem; padding: .15rem .5rem; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; font-family: var(--t-ui-font); font-size: .72rem; }
.product-detail-page { min-height: calc(100vh - var(--nav-height)); }
.product-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: start; }
.product-detail-layout--no-image { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
.product-detail-figure { margin: 0; }
.product-detail-main { display: block; width: 100%; padding: 0; border: none; border-radius: var(--t-radius-lg); overflow: hidden; background: var(--t-surface); cursor: zoom-in; box-shadow: var(--t-shadow); }
.product-detail-main img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.product-detail-main:focus-visible, .product-detail-thumb:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 2px; }
.product-detail-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: .5rem; margin-top: .75rem; }
.product-detail-thumb { padding: 0; border: 2px solid transparent; border-radius: var(--t-radius); overflow: hidden; background: var(--t-surface); cursor: pointer; }
.product-detail-thumb[aria-pressed="true"] { border-color: var(--t-accent); }
.product-detail-thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.product-detail-info { display: flex; flex-direction: column; gap: .5rem; }
.product-detail-title { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.15; margin: 0; }
.product-detail-price { font-size: 1.5rem; font-weight: 700; margin: 0; }
.product-detail-stock { font-family: var(--t-ui-font); font-size: .88rem; color: var(--t-text-muted); margin: 0; }
.product-detail-desc { font-size: 1.02rem; line-height: 1.8; white-space: pre-line; margin-top: .75rem; }
.product-detail-actions { margin-top: 1.25rem; max-width: 320px; }
.product-detail-book { margin-top: 1rem; font-family: var(--t-ui-font); font-size: .9rem; }
.product-detail-page .store-note { margin-top: 3rem; font-size: .8rem; color: var(--t-text-muted); }
@media (max-width: 768px) {
    .product-detail-layout { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
    .product-detail-actions { max-width: none; }
}
.product-detail-info .product-type-badge--inline { align-self: flex-start; margin: 0; }
.event-detail-photos-heading { font-size: 1.3rem; margin: 2.5rem 0 0; }
