@font-face {
    font-family: "Cormorant Garamond";
    src: url("../fonts/cormorant-garamond-latin-wght-normal.woff2") format("woff2-variations");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("../fonts/cormorant-garamond-latin-wght-italic.woff2") format("woff2-variations");
    font-weight: 300 700;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "Jost";
    src: url("../fonts/jost-latin-wght-normal.woff2") format("woff2-variations");
    font-weight: 300 600;
    font-style: normal;
    font-display: swap;
}

:root {
    --ivory: #f5f3ef;
    --ivory-deep: #ece9e3;
    --ink: #29252c;
    --ink-soft: #5d5864;
    --lilac: #8d88a6;
    --lilac-deep: #6e688c;
    --blush: #cfc9dd;
    --line: rgba(41, 37, 44, 0.14);
    --header-h: 64px;
    --toolbar-h: 58px;
    --strip-h: 96px;
    --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --sans: "Jost", "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--sans);
    font-weight: 400;
    color: var(--ink);
    background: var(--ivory);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* ---------- header ---------- */

.header {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-h);
    padding: 0 clamp(14px, 3vw, 32px);
    border-bottom: 1px solid var(--line);
    background: var(--ivory);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.brand-name {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(19px, 2.4vw, 25px);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
}

.brand-sub {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--lilac-deep);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--ivory);
}

.btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}

.btn-icon {
    width: 38px;
    padding: 0;
    justify-content: center;
}

.btn-label {
    display: none;
}

@media (min-width: 720px) {
    .btn-label {
        display: inline;
    }
}

/* ---------- stage / book ---------- */

.stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 2.2vw, 34px) clamp(8px, 3vw, 44px);
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(141, 136, 166, 0.10), transparent 60%),
        var(--ivory-deep);
}

.book {
    width: 100%;
    height: 100%;
    /* the lib writes min-width/min-height inline; let the stage shrink freely
       instead so pages always fit the viewport */
    min-width: 0 !important;
    min-height: 0 !important;
}

.hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(41, 37, 44, 0.82);
    color: var(--ivory);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s;
    white-space: nowrap;
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hint.show {
    opacity: 1;
}

.stage:has(.strip.open) .hint {
    bottom: calc(var(--strip-h) + 12px);
}

/* ---------- toolbar ---------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: var(--toolbar-h);
    padding: 0 clamp(12px, 3vw, 28px);
    border-top: 1px solid var(--line);
    background: var(--ivory);
    flex: 0 0 auto;
}

.pager {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pager-label {
    min-width: 110px;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.toolbar-side {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* ---------- thumbnail filmstrip (floating over the stage bottom) ---------- */

.strip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    height: var(--strip-h);
    border-top: 1px solid var(--line);
    background: rgba(245, 243, 239, 0.94);
    backdrop-filter: blur(6px);
    transform: translateY(105%);
    transition: transform 0.28s ease;
}

.strip.open {
    transform: translateY(0);
}

.strip-track {
    display: flex;
    gap: 8px;
    height: 100%;
    padding: 10px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.strip-thumb {
    flex: 0 0 auto;
    height: 100%;
    aspect-ratio: 1654 / 1166;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    opacity: 0.55;
    transition: opacity 0.2s, border-color 0.2s, transform 0.2s;
}

.strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.strip-thumb:hover {
    opacity: 0.9;
}

.strip-thumb.current {
    opacity: 1;
    border-color: var(--lilac-deep);
    box-shadow: 0 0 0 1px var(--lilac-deep);
}

/* ---------- zoom overlay ---------- */

.zoom {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    flex-direction: column;
    background: rgba(24, 22, 26, 0.96);
}

.zoom.open {
    display: flex;
}

.zoom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    color: var(--ivory);
    flex: 0 0 auto;
}

.zoom-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-label {
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--blush);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.zoom-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0 18px 24px;
}

.zoom-view img {
    width: min(1654px, 96vw);
    height: auto;
    border-radius: 3px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.zoom .btn {
    border-color: rgba(245, 243, 239, 0.3);
    color: var(--ivory);
}

.zoom .btn:hover {
    background: var(--ivory);
    border-color: var(--ivory);
    color: var(--ink);
}

/* ---------- loading / error ---------- */

.loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--ivory-deep);
    transition: opacity 0.4s;
    z-index: 5;
}

.loader.done {
    opacity: 0;
    pointer-events: none;
}

.loader-mark {
    font-family: var(--serif);
    font-size: 30px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--lilac-deep);
}

.loader-bar {
    width: 150px;
    height: 1px;
    background: var(--line);
    overflow: hidden;
}

.loader-bar::after {
    content: "";
    display: block;
    width: 40%;
    height: 100%;
    background: var(--lilac-deep);
    animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.loader-error {
    max-width: 420px;
    padding: 0 24px;
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink-soft);
    display: none;
}

.loader.error .loader-error {
    display: block;
}

.loader.error .loader-bar {
    display: none;
}

/* ---------- rotate prompt (portrait phones) ---------- */

.rotate-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--ivory);
}

@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) {
    .rotate-overlay:not(.dismissed) {
        display: flex;
    }
}

.rotate-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px;
    text-align: center;
}

.rotate-icon {
    width: 72px;
    height: 72px;
    color: var(--lilac-deep);
    margin-bottom: 8px;
}

.rotate-phone {
    transform-origin: 32px 32px;
    animation: phone-turn 2.4s ease-in-out infinite;
}

@keyframes phone-turn {
    0%, 25% { transform: rotate(0deg); }
    55%, 85% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

.rotate-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.rotate-sub {
    margin: 0 0 10px;
    font-size: 12px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.rotate-dismiss {
    margin-top: 8px;
    padding: 8px;
    border: 0;
    background: none;
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--lilac-deep);
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
}

/* ---------- small screens ---------- */

@media (max-width: 560px) {
    :root {
        --header-h: 56px;
        --toolbar-h: 52px;
    }

    .brand-sub {
        display: none;
    }

    .pager-label {
        min-width: 84px;
        font-size: 11px;
        letter-spacing: 0.12em;
    }
}

/* short landscape screens (phones) — give the book as much room as possible */

@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --header-h: 44px;
        --toolbar-h: 42px;
        --strip-h: 78px;
    }

    .brand-sub {
        display: none;
    }

    .btn {
        height: 32px;
        font-size: 11px;
    }

    .btn-icon {
        width: 32px;
    }
}

@media print {
    body {
        overflow: visible;
    }
}
