@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --navy: #12233f;
    --blue: #234f87;
    --gold: #d7b46a;
    --ink: #172238;
    --muted: #69758a;
    --paper: #f5f7fb;
    --line: #e4e9f1;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, Roboto, Arial, sans-serif;
}
button { font: inherit; }
.site-header {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 5vw, 72px);
    color: #fff;
    background: var(--navy);
    border-bottom: 3px solid var(--gold);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 46px; height: 46px;
    overflow: hidden; border: 0; border-radius: 50%;
    background: transparent; flex: 0 0 46px;
}
.brand-mark img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    border-radius: 50%; background: transparent;
}
.brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 4px; color: #c4cfdf; font-size: 11px; }
.header-note { color: #d6dfec; font-size: 13px; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.intro { padding: 58px 0 34px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .17em; }
h1 { margin: 0; color: var(--navy); font-size: clamp(29px, 4vw, 44px); line-height: 1.14; letter-spacing: -.035em; }
.intro-copy { margin: 15px 0 0; color: var(--muted); font-size: 15px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 14px 0 20px; }
.section-heading h2 { margin: 0; font-size: 22px; color: var(--navy); }
.muted { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; padding-bottom: 64px; }
.book-card {
    display: flex; flex-direction: column; min-width: 0; padding: 12px;
    border: 1px solid var(--line); border-radius: 16px; background: #fff;
    box-shadow: 0 7px 24px rgba(18,35,63,.045); transition: transform .2s ease, box-shadow .2s ease;
}
.book-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(18,35,63,.12); }
.cover-wrap {
    position: relative; display: grid; place-items: center; overflow: hidden;
    height: 285px; border-radius: 10px; background: linear-gradient(145deg, #e7edf6, #d5dfed);
}
.cover-wrap img { width: 100%; height: 100%; object-fit: contain; }
.cover-fallback {
    display: none; width: 100%; height: 100%; padding: 24px; align-items: center;
    justify-content: center; text-align: center; color: #fff;
    background: linear-gradient(145deg, #17345d, #38618f);
}
.cover-fallback .fallback-inner { border: 1px solid rgba(255,255,255,.5); padding: 22px 12px; width: 100%; }
.cover-fallback .fallback-symbol { display: block; color: var(--gold); font-size: 34px; margin-bottom: 16px; }
.cover-fallback strong { display: block; font-size: 17px; line-height: 1.4; }
.book-info { padding: 17px 5px 4px; }
.book-info h3 { margin: 0; font-size: 16px; line-height: 1.45; color: var(--navy); }
.book-info p { min-height: 18px; margin: 8px 0 15px; color: var(--muted); font-size: 12px; }
.read-button {
    display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%;
    min-height: 43px; padding: 10px 14px; border: 0; border-radius: 9px;
    background: var(--navy); color: #fff; font-weight: 600; cursor: pointer;
    transition: background .2s ease;
}
.read-button:hover { background: var(--blue); }
.read-button:focus-visible, button:focus-visible { outline: 3px solid #e6c36f; outline-offset: 3px; }
.site-footer { padding: 23px 20px; text-align: center; color: #778196; border-top: 1px solid var(--line); font-size: 12px; }

/* Flipbook reader */
.reader-overlay {
    position: fixed; inset: 0; z-index: 1000; display: none; flex-direction: column;
    background: #111b2c; color: #fff;
}
.reader-overlay.is-open { display: flex; }
.reader-topbar {
    flex: 0 0 62px; display: flex; align-items: center; gap: 15px;
    padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.12); background: #101a2a;
}
.icon-button, .toolbar-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid rgba(255,255,255,.2); border-radius: 9px; color: #fff;
    background: rgba(255,255,255,.06); cursor: pointer;
}
.icon-button { width: 40px; height: 40px; font-size: 25px; }
.toolbar-button { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.toolbar-button[aria-pressed="false"] { opacity: .7; }
.reader-book-title { overflow: hidden; flex: 1; color: #f2f5fa; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.reader-actions { display: flex; gap: 8px; }
.reader-stage {
    position: relative; flex: 1; min-height: 0; display: flex; align-items: center;
    justify-content: center; padding: 12px 58px 16px; overflow: hidden;
}
#flipbook { margin: auto; }
#flipbook .page { overflow: hidden; background: #fff; }
#flipbook .page img { display: block; width: 100%; height: 100%; object-fit: contain; }
#flipbook .page.page-empty { background: #fff; }
.page-arrow {
    position: absolute; z-index: 5; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 42px; height: 58px;
    border: 1px solid rgba(255,255,255,.18); border-radius: 12px;
    background: rgba(255,255,255,.09); color: #fff; font-size: 38px; line-height: 1; cursor: pointer;
}
.page-arrow:hover { background: rgba(255,255,255,.18); }
#prev-page { left: 10px; }
#next-page { right: 10px; }
.reader-loading {
    position: absolute; z-index: 4; display: none; padding: 10px 16px;
    border-radius: 10px; color: #fff; background: rgba(0,0,0,.65); font-size: 13px;
}
.reader-loading.is-visible { display: block; }
.reader-bottombar {
    flex: 0 0 52px; display: flex; align-items: center; gap: 18px; padding: 0 24px;
    border-top: 1px solid rgba(255,255,255,.12); color: #e2e8f1; font-size: 12px;
}
#page-counter { min-width: 60px; font-variant-numeric: tabular-nums; }
.reader-progress { height: 4px; flex: 1; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.16); }
#progress-fill { display: block; width: 0; height: 100%; background: var(--gold); transition: width .2s ease; }
.reader-hint { color: #9eacc1; }

@media (max-width: 700px) {
    .site-header { height: 68px; padding: 0 16px; }
    .header-note { display: none; }
    .brand-mark { width: 38px; height: 38px; }
    .page-shell { width: min(100% - 28px, 520px); }
    .intro { padding: 38px 0 25px; }
    .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
    .cover-wrap { height: clamp(170px, 55vw, 260px); }
    .book-card { padding: 8px; border-radius: 12px; }
    .book-info { padding: 12px 3px 3px; }
    .book-info h3 { font-size: 13px; }
    .book-info p { font-size: 11px; margin-bottom: 12px; }
    .read-button { font-size: 12px; min-height: 39px; }
    .reader-topbar { flex-basis: 56px; gap: 9px; padding: 0 10px; }
    .reader-book-title { font-size: 12px; }
    .toolbar-button { padding: 7px 9px; }
    .sound-label, .fullscreen-label { display: none; }
    .reader-stage { padding: 8px 28px 10px; }
    .page-arrow { width: 30px; height: 48px; font-size: 30px; border-radius: 8px; }
    #prev-page { left: 2px; }
    #next-page { right: 2px; }
    .reader-bottombar { flex-basis: 44px; padding: 0 12px; gap: 10px; }
    .reader-hint { display: none; }
}
@media (max-width: 380px) {
    .book-grid { grid-template-columns: 1fr; }
    .cover-wrap { height: 300px; }
}


/* Zoom controls */
.zoom-level { min-width: 42px; text-align: center; color: #dbe5f4; font-size: 11px; font-variant-numeric: tabular-nums; }
.zoom-button { width: 34px; padding: 0; font-size: 20px; }
.zoom-reset { padding: 7px 8px; font-size: 10px; }
.reader-stage { overflow: auto; touch-action: pan-x pan-y; }
#flipbook { transform-origin: center center; transition: transform .12s ease; }
.reader-stage.is-zoomed { align-items: flex-start; justify-content: flex-start; }
.reader-stage.is-zoomed #flipbook { margin: 22px auto; }
.page-error { padding: 12px; text-align: center; color: #6b7280; }
@media (max-width: 700px) {
    .zoom-reset { display: none; }
    .zoom-level { min-width: 34px; font-size: 10px; }
    .zoom-button { width: 30px; min-height: 32px; }
}


/* Responsive layout: desktop, browser zoom and mobile */
html {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

.site-header {
    width: 100%;
    min-width: 0;
}

.page-shell {
    width: min(1180px, calc(100% - 40px));
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
}

.intro,
.section-heading,
.book-grid,
.book-card {
    min-width: 0;
    max-width: 100%;
}

.intro h1 {
    max-width: 100%;
    font-size: clamp(22px, 3.2vw, 44px);
    line-height: 1.2;
    letter-spacing: -0.035em;
    overflow-wrap: anywhere;
}

.intro-copy {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.book-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
}

img {
    max-width: 100%;
}

@media (max-width: 700px) {
    .page-shell {
        width: calc(100% - 28px);
    }

    .intro h1 {
        font-size: clamp(23px, 5.6vw, 34px);
    }
}

@media (max-width: 480px) {
    .site-header {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand {
        min-width: 0;
        gap: 9px;
    }

    .brand strong {
        font-size: 13px;
    }

    .brand small {
        font-size: 10px;
    }

    .page-shell {
        width: calc(100% - 24px);
    }

    .intro {
        padding-top: 30px;
    }

    .intro h1 {
        font-size: clamp(22px, 6vw, 30px);
    }
}


/* Kitob o‘qilishlari statistikasi */
.book-views {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 12px;
}
.book-views .views-number {
    color: var(--navy);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}


/* Kitob kartalaridagi tugmalar bir xil pastki chiziqda */
.book-card {
    height: 100%;
}
.book-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}
.book-info h3 {
    min-height: 2.9em;
}
.book-info > p {
    flex-shrink: 0;
}
.book-info .read-button {
    margin-top: auto;
}

/* Flipbook ichida aniq betga o‘tish */
.reader-bottombar {
    flex-wrap: wrap;
    min-height: 58px;
    height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
}
.page-jump-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    color: #e2e8f1;
}
.page-jump-form label {
    color: #c8d2e1;
    font-size: 12px;
}
.page-jump-form input {
    width: 64px;
    min-width: 0;
    height: 32px;
    padding: 4px 7px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 7px;
    outline: none;
    background: rgba(255,255,255,.08);
    color: #fff;
    font: inherit;
}
.page-jump-form input:focus {
    border-color: var(--gold);
    outline: 2px solid rgba(226,190,105,.22);
}
.page-jump-form input::placeholder {
    color: #aab6c8;
}
.page-jump-form button {
    height: 32px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 7px;
    background: #e2be69;
    color: #142541;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.page-jump-form button:hover {
    filter: brightness(1.06);
}
@media (max-width: 700px) {
    .book-info h3 {
        min-height: 0;
    }
    .reader-bottombar {
        flex-basis: auto;
        gap: 8px;
        justify-content: space-between;
        padding: 7px 10px;
    }
    .reader-progress {
        min-width: 36px;
        order: 3;
        flex-basis: 100%;
    }
    .page-jump-form {
        gap: 4px;
    }
    .page-jump-form label {
        font-size: 11px;
    }
    .page-jump-form input {
        width: 54px;
        height: 30px;
        font-size: 12px;
    }
    .page-jump-form button {
        height: 30px;
        padding: 0 8px;
    }
    .reader-hint {
        display: none;
    }
}
