/* =========================================================
   TOWNTUNE V2 - BOOK LANDING + FULLSCREEN VIEWER
   ========================================================= */

.book-page-main {
    padding-top: 24px;
}

.book-hero {
    display: grid;
    grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr);
    align-items: center;
    gap: clamp(34px, 6vw, 78px);
    min-height: 540px;
    padding: clamp(32px, 5vw, 62px);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 32px;
    background:
        radial-gradient(circle at 14% 18%, rgba(114, 222, 211, .15), transparent 27%),
        radial-gradient(circle at 92% 10%, rgba(126, 104, 255, .20), transparent 31%),
        linear-gradient(135deg, #122640, #171b49 62%, #263351);
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.book-hero-cover {
    position: relative;
    width: min(100%, 390px);
    justify-self: center;
}

.book-hero-cover img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border: 7px solid rgba(255,255,255,.93);
    border-radius: 24px;
    box-shadow: 0 28px 58px rgba(0,0,0,.32);
    transform: rotate(-2deg);
}

.book-cover-badge {
    position: absolute;
    right: -12px;
    bottom: 24px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: rgba(9, 25, 47, .88);
    color: #fff;
    font-size: 13px;
    font-weight: 950;
    box-shadow: 0 12px 28px rgba(0,0,0,.23);
    backdrop-filter: blur(10px);
}

.book-hero-copy {
    max-width: 720px;
}

.book-hero-copy h1 {
    margin: 12px 0 14px;
    color: #fff;
    font-size: clamp(52px, 7vw, 88px);
    line-height: .94;
    letter-spacing: -4px;
}

.book-hero-lead {
    max-width: 650px;
    margin: 0;
    color: #c8d6e8;
    font-size: clamp(17px, 1.7vw, 21px);
    line-height: 1.58;
    font-weight: 650;
}

.book-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.book-facts span {
    display: inline-flex;
    align-items: center;
    min-height: 35px;
    padding: 8px 11px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 999px;
    background: rgba(255,255,255,.055);
    color: #dfe9f5;
    font-size: 12px;
    font-weight: 850;
}

.book-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 11px;
    margin-top: 26px;
}

.book-primary-button,
.book-secondary-button {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 19px;
    border: 0;
    border-radius: 15px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 950;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.book-primary-button {
    background: linear-gradient(135deg, #6de0d4, #68a7ff);
    color: #07172c;
    box-shadow: 0 15px 30px rgba(59, 183, 198, .20);
}

.book-secondary-button {
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.075);
    color: #fff;
}

.book-primary-button:hover,
.book-secondary-button:hover {
    transform: translateY(-2px);
}

.book-hero-note {
    max-width: 620px;
    margin: 17px 0 0;
    color: #8ea0b7;
    font-size: 12px;
    line-height: 1.55;
}


/* PREVIEWS */

.book-preview-section {
    margin-top: 58px;
}

.section-text-button,
.section-text-link {
    border: 0;
    background: transparent;
    color: #7de4d8;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

.book-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.book-preview-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 22px;
    background: rgba(255,255,255,.055);
    box-shadow: 0 14px 30px rgba(0,0,0,.15);
    cursor: pointer;
    transition: transform .2s ease, border-color .2s ease;
}

.book-preview-card:hover {
    transform: translateY(-5px);
    border-color: rgba(125,228,216,.30);
}

.book-preview-card img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 5;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
}

.book-preview-card span {
    display: block;
    padding: 11px 2px 1px;
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    text-align: left;
}

.book-info-section {
    margin-top: 62px;
}

.more-books-section {
    margin-top: 56px;
    margin-bottom: 30px;
}

.mini-book-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}

.mini-book-card {
    min-width: 0;
    padding: 9px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 18px;
    background: rgba(255,255,255,.05);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}

.mini-book-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,.16);
}

.mini-book-card img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 12px;
    background: #fff;
}

.mini-book-card strong {
    display: block;
    padding: 10px 4px 4px;
    color: #fff;
    font-size: 13px;
}


/* =========================================================
   FULLSCREEN BOOK VIEWER
   ========================================================= */

html.book-viewer-open,
html.book-viewer-open body {
    overflow: hidden !important;
}

.book-viewer {
    position: fixed;
    z-index: 6000;
    inset: 0;
    height: 100dvh;
    display: none;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 10%, rgba(41, 92, 127, .22), transparent 30%),
        #061524;
}

.book-viewer.open {
    display: grid;
}

.book-viewer-topbar {
    position: relative;
    z-index: 4;
    min-height: calc(58px + env(safe-area-inset-top));
    padding:
        env(safe-area-inset-top)
        max(10px, env(safe-area-inset-right))
        0
        max(10px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    background: rgba(7, 23, 44, .94);
    backdrop-filter: blur(14px);
}

.book-viewer-exit {
    width: 70px;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 14px;
    background: rgba(255,255,255,.07);
    color: #fff;
    font-family: inherit;
    font-weight: 950;
    cursor: pointer;
}

.book-viewer-title {
    min-width: 0;
    overflow: hidden;
    color: #fff;
    font-size: clamp(17px, 2.5dvh, 22px);
    font-weight: 950;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-viewer-page-controls {
    justify-self: end;
    display: grid;
    grid-template-columns: 40px minmax(70px, auto) 40px;
    align-items: center;
    gap: 6px;
}

.book-viewer-page-arrow {
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 14px;
    background: rgba(255,255,255,.07);
    color: #fff;
    font-family: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.book-viewer-page-arrow:disabled {
    opacity: .28;
    cursor: default;
}

.book-viewer-count {
    min-width: 70px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    color: #d9e5f4;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.book-viewer-stage-shell {
    position: relative;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding:
        clamp(8px, 1.8dvh, 16px)
        clamp(72px, 8vw, 116px)
        clamp(8px, 1.8dvh, 16px);
}

.book-viewer-page {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    place-items: center;
}

.book-viewer-page img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 22px 55px rgba(0,0,0,.40);
}

.book-viewer-nav {
    position: absolute;
    z-index: 3;
    top: 50%;
    width: 48px;
    height: 58px;
    transform: translateY(-50%);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 17px;
    background: rgba(8, 25, 46, .84);
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.book-viewer-nav:disabled {
    opacity: .28;
    cursor: default;
}

.book-viewer-prev {
    left: 14px;
}

.book-viewer-next {
    right: 14px;
}

.book-viewer-dock {
    position: absolute;
    z-index: 5;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    gap: 8px;
    width: 94px;
}

.book-viewer-action {
    min-height: 70px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    padding: 8px 6px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 16px;
    background: rgba(8, 25, 46, .89);
    color: #fff !important;
    font-size: 11px;
    font-weight: 900;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 10px 26px rgba(0,0,0,.22);
    backdrop-filter: blur(12px);
}

.book-viewer-action-colour {
    background: linear-gradient(135deg, #6f57d9, #c14fa3);
}

.book-viewer-action-icon {
    font-size: 22px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 820px) {
    .book-page-main {
        padding-top: 14px;
    }

    .book-hero {
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 28px;
        padding: 28px 22px;
        border-radius: 24px;
    }

    .book-hero-cover {
        width: min(72vw, 330px);
    }

    .book-hero-copy {
        text-align: center;
    }

    .book-hero-copy h1 {
        font-size: clamp(50px, 13vw, 72px);
        letter-spacing: -3px;
    }

    .book-hero-lead {
        margin-inline: auto;
    }

    .book-facts,
    .book-hero-actions {
        justify-content: center;
    }

    .book-hero-note {
        margin-inline: auto;
    }

    .mini-book-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .book-viewer-stage-shell {
        padding: 8px 48px 86px;
    }

    .book-viewer-dock {
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        top: auto;
        bottom: max(8px, env(safe-area-inset-bottom));
        width: auto;
        transform: none;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .book-viewer-action {
        min-height: 62px;
        border-radius: 14px;
    }

    .book-viewer-nav {
        width: 38px;
        height: 52px;
        border-radius: 14px;
        font-size: 29px;
    }

    .book-viewer-prev {
        left: 6px;
    }

    .book-viewer-next {
        right: 6px;
    }
}

@media (max-width: 600px) {
    .book-preview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .book-preview-card {
        padding: 6px;
        border-radius: 14px;
    }

    .book-preview-card img {
        border-radius: 9px;
    }

    .book-preview-card span {
        padding-top: 7px;
        font-size: 10px;
    }

    .book-viewer-topbar {
        min-height: calc(52px + env(safe-area-inset-top));
        grid-template-columns: 64px minmax(0, 1fr) auto;
        padding-left: max(6px, env(safe-area-inset-left));
        padding-right: max(6px, env(safe-area-inset-right));
    }

    .book-viewer-exit {
        width: 60px;
        min-height: 38px;
        border-radius: 13px;
        font-size: 12px;
    }

    .book-viewer-title {
        font-size: 16px;
    }

    .book-viewer-count {
        min-width: 54px;
        padding-inline: 7px;
        font-size: 10px;
    }

    .book-viewer-page-controls {
        grid-template-columns: 34px minmax(54px, auto) 34px;
        gap: 4px;
    }

    .book-viewer-page-arrow {
        min-width: 34px;
        min-height: 34px;
        border-radius: 12px;
        font-size: 21px;
    }

    .book-viewer-stage-shell {
        padding-top: 5px;
        padding-bottom: 78px;
    }

    .book-viewer-action {
        min-height: 56px;
        padding: 6px 3px;
        font-size: 9px;
    }

    .book-viewer-action-icon {
        font-size: 19px;
    }
}


/* =========================================================
   DESKTOP BOOK VIEWER FIT FIX
   Keep the entire colouring page visible inside the viewport.
   Mobile already uses the bottom action dock and keeps its own rules.
   ========================================================= */

@media (min-width: 821px) {
    .book-viewer-stage-shell {
        min-height: 0;
        overflow: hidden;
        padding:
            12px
            126px
            12px
            70px;
    }

    .book-viewer-page {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .book-viewer-page img {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: calc(100dvh - 86px) !important;
        object-fit: contain !important;
        flex: 0 1 auto;
    }
}
