/* BookClub.uz — palette after Rishtan ceramics: cobalt, firuza, saffron on white clay.
   Status colours carry meaning: firuza = available, saffron = borrowed, cobalt = for sale. */

:root {
    --paper: #F7F8FA;
    --surface: #FFFFFF;
    --ink: #14213D;
    --muted: #5B6680;
    --line: #DDE2EB;
    --cobalt: #2346A0;
    --cobalt-soft: #E6ECFA;
    --firuza: #0B7A75;
    --firuza-soft: #E1F3F1;
    --saffron: #9A6412;
    --saffron-soft: #FBF0DC;
    --cover-bg: #2346A0;
    --cover-shadow: 0 1px 1px rgba(20, 33, 61, .08), 0 6px 14px -6px rgba(20, 33, 61, .35);
    --cover-shadow-lift: 0 2px 2px rgba(20, 33, 61, .08), 0 18px 28px -10px rgba(20, 33, 61, .45);

    --font-display: "Unbounded", system-ui, sans-serif;
    --font-body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
    --gutter: clamp(16px, 4vw, 40px);
    --max: 1200px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #0E1526;
        --surface: #16203A;
        --ink: #E8ECF4;
        --muted: #9AA5BD;
        --line: #26324F;
        --cobalt: #9DB4FF;
        --cobalt-soft: #1D2A52;
        --firuza: #5FD3C8;
        --firuza-soft: #12343A;
        --saffron: #F2C063;
        --saffron-soft: #3A2E17;
        --cover-bg: #233F8A;
        --cover-shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 6px 14px -6px rgba(0, 0, 0, .7);
        --cover-shadow-lift: 0 2px 2px rgba(0, 0, 0, .3), 0 18px 28px -10px rgba(0, 0, 0, .8);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 400 16px/1.55 var(--font-body);
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; border-radius: 4px; }

.muted { color: var(--muted); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
    position: absolute; left: 12px; top: -48px; z-index: 100;
    padding: 8px 14px; border-radius: 8px;
    background: var(--ink); color: var(--paper); text-decoration: none;
}
.skip:focus { top: 12px; }

.page {
    flex: 1;
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(24px, 5vw, 48px) var(--gutter) 72px;
}

/* ---------- Header ---------- */

.site-header {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line);
    view-transition-name: site-header;
}

.site-header__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    min-height: 64px;
}

.logo {
    font: 700 19px/1 var(--font-display);
    letter-spacing: -.01em;
    text-decoration: none;
    white-space: nowrap;
}
.logo__tld { color: var(--cobalt); }

.tabs {
    display: flex;
    gap: 4px;
    justify-self: center;
}
.tabs a {
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 500;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s, background-color .2s;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }

.search-link {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border-radius: 999px;
    color: var(--ink);
    transition: background-color .2s;
}
.search-link:hover, .search-link[aria-current="page"] { background: var(--line); }

/* On narrow screens the tabs become a swipeable row under the logo */
@media (max-width: 900px) {
    .site-header__inner {
        grid-template-columns: 1fr auto;
        row-gap: 0;
        padding-top: 10px;
    }
    .tabs {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        margin: 0 calc(var(--gutter) * -1);
        padding: 8px var(--gutter) 10px;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        mask-image: linear-gradient(90deg, #000 calc(100% - var(--gutter) * 2), transparent 100%);
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { scroll-snap-align: start; }
}

/* ---------- Page heading ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 24px;
    margin-bottom: clamp(24px, 4vw, 40px);
}

.page-title {
    font: 700 clamp(28px, 5.2vw, 52px)/1.05 var(--font-display);
    letter-spacing: -.03em;
    text-wrap: balance;
}

.page-count { color: var(--muted); font-size: 15px; }

.empty {
    max-width: 52ch;
    padding: 32px 0;
    color: var(--muted);
    font-size: 17px;
}

/* ---------- Book grid & covers ---------- */

.grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: clamp(28px, 4vw, 44px) clamp(16px, 2.6vw, 32px);
}
@media (max-width: 420px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card__link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
}

/* A cover drawn as a physical book: square spine edge, rounded fore-edge, a spine crease */
.cover {
    position: relative;
    aspect-ratio: 2 / 3;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 2px 6px 6px 2px;
    background: var(--cover-bg);
    box-shadow: var(--cover-shadow);
    transform-origin: 30% 100%;
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.cover::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(90deg,
        rgba(0, 0, 0, .28) 0, rgba(255, 255, 255, .22) 3px,
        rgba(0, 0, 0, .10) 6px, transparent 12px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.js .cover img { opacity: 0; transition: opacity .4s ease; }
.js .cover img.is-loaded { opacity: 1; }

.cover__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 14px 12px 14px 18px;
    color: #fff;
    font: 700 15px/1.2 var(--font-display);
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
    background:
        radial-gradient(circle at 80% 18%, rgba(255, 255, 255, .18) 0 18%, transparent 19%),
        radial-gradient(circle at 80% 18%, transparent 0 26%, rgba(255, 255, 255, .12) 27% 29%, transparent 30%),
        var(--cover-bg);
}

@media (hover: hover) {
    .card__link:hover .cover {
        transform: translateY(-6px) rotate(-1.2deg);
        box-shadow: var(--cover-shadow-lift);
    }
}

.card__title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card__author {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Status ---------- */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
}
.status::before {
    content: "";
    flex: none;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.status--free { color: var(--firuza); }
.status--busy { color: var(--saffron); }
.status--sale { color: var(--cobalt); }

.status--lg {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 15px;
}
.status--lg.status--free { background: var(--firuza-soft); }
.status--lg.status--busy { background: var(--saffron-soft); }
.status--lg.status--sale { background: var(--cobalt-soft); }

/* ---------- Detail ---------- */

.detail {
    display: grid;
    grid-template-columns: minmax(200px, 320px) minmax(0, 1fr);
    gap: clamp(28px, 6vw, 72px);
    align-items: start;
}
.detail__cover { position: sticky; top: 96px; }
.cover--large { margin: 0; border-radius: 3px 10px 10px 3px; }
.cover--large .cover__placeholder { font-size: 24px; padding: 24px 20px 24px 28px; }

.detail__title {
    font: 700 clamp(26px, 4.4vw, 44px)/1.1 var(--font-display);
    letter-spacing: -.025em;
    text-wrap: balance;
}
.detail__author { margin-top: 10px; color: var(--muted); font-size: 18px; }
.detail__facts { margin-top: 20px; }
.detail__text { margin-top: 24px; max-width: 64ch; font-size: 17px; line-height: 1.65; }
.detail__text p + p { margin-top: .8em; }

@media (max-width: 680px) {
    .detail { grid-template-columns: 1fr; }
    .detail__cover { position: static; width: min(220px, 60vw); margin: 0 auto; }
    .detail__body { text-align: left; }
}

/* ---------- Form ---------- */

.request {
    margin-top: 36px;
    max-width: 480px;
    padding: clamp(20px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}
.request__title { font-size: 19px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.request .muted { font-size: 15px; margin-bottom: 20px; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }

.field input,
.field textarea,
.search input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 16px; /* prevents zoom-on-focus in iOS Safari */
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus,
.field textarea:focus,
.search input:focus {
    outline: none;
    border-color: var(--cobalt);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--cobalt-soft);
}

.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: #C2352B; font-size: 14px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 22px;
    border: 0;
    border-radius: 10px;
    background: var(--cobalt);
    color: #fff;
    font: 600 16px/1 var(--font-body);
    cursor: pointer;
    transition: transform .15s var(--ease), filter .2s;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .btn { color: #0E1526; }
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; cursor: progress; }
.request .btn { width: 100%; margin-top: 4px; }

/* ---------- Search ---------- */

.search {
    display: flex;
    gap: 10px;
    max-width: 560px;
    margin-bottom: 32px;
}
.search input { flex: 1; }
.search + .page-count { margin-bottom: 24px; }

/* ---------- Notices ---------- */

.notices { margin-bottom: 28px; }
.notice {
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--firuza-soft);
    color: var(--firuza);
    font-weight: 500;
    animation: notice-in .5s var(--ease) both;
}
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- About ---------- */

.about { max-width: 640px; }
.about .page-title { margin-bottom: 24px; }
.about__lead { font-size: 20px; line-height: 1.55; margin-bottom: 24px; }
.about .socials { margin-top: 16px; }

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--line);
    padding: 32px 0;
}
.site-footer__inner,
.site-footer__copy {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter);
}
.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.site-footer__brand { font: 700 15px/1.2 var(--font-display); margin-bottom: 2px; }
.site-footer__copy { margin-top: 20px; font-size: 14px; }

.socials { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.socials a {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    font-size: 17px;
    text-decoration: none;
    transition: background-color .2s, color .2s, border-color .2s;
}
.socials a:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Page transitions ---------- */

/* Cross-document View Transitions: the cover morphs from the grid into the detail page.
   Browsers without support simply navigate as before. */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: .22s; }
::view-transition-group(*) { animation-timing-function: var(--ease); animation-duration: .38s; }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
