/* =====================================================================
   Rahnuma eBooks — visual identity
   Concept: the site IS the guide (rahnuma = "one who shows the way").
   Categories render as a shelf of book spines, not a link list.
   Breadcrumbs render as a guide trail, not a > chain.
   Palette: reading-room, not template-default (no cream+terracotta).
   ===================================================================== */

:root {
    /* -- Color: reading room -- */
    --ink:          #1C2521;   /* primary text, near-black forest */
    --ink-muted:    #5B6B62;   /* secondary text */
    --paper:        #F5EFDD;   /* page background, warm parchment */
    --paper-raised: #FCFAF1;   /* card surfaces, lifted off the page */
    --forest:       #24463C;   /* brand / header / primary actions */
    --forest-dark:  #17322A;
    --brass:        #B8873A;   /* accent: active states, highlights */
    --brass-light:  #E8D5A8;
    --burgundy:     #7A2E2E;   /* secondary accent: badges, alerts */
    --line:         #DED2AE;   /* hairline dividers on parchment */
    --line-soft:    #E8DFC4;
    --shadow: 0 2px 12px rgba(28, 37, 33, 0.08);
    --shadow-lift: 0 14px 32px rgba(28, 37, 33, 0.16);
    --radius: 4px;

    /* -- Type -- */
    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    /* -- A rotating palette of "spine" colors for shelf navigation --
       assigned per-category (server-side hash) so a shelf of many
       categories reads with the same visual variety as a real bookshelf */
    --spine-1: #24463C;
    --spine-2: #7A2E2E;
    --spine-3: #B8873A;
    --spine-4: #3B4E63;
    --spine-5: #5C4A72;
    --spine-6: #8A5A2E;
    --spine-7: #2E5E55;
    --spine-8: #6B3F3F;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
}
a { color: inherit; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

::selection { background: var(--brass-light); color: var(--ink); }

/* Focus visibility -- keyboard nav should never disappear on this palette */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------
   Utility bar + header
   --------------------------------------------------------------------- */
.top-bar { background: var(--forest-dark); color: #E9E4D2; padding: 7px 0; font-size: 12px; letter-spacing: .02em; }
.top-bar .container { display: flex; gap: 20px; }
.top-bar a { color: #E9E4D2; text-decoration: none; opacity: .85; display: inline-flex; align-items: center; gap: 5px; }
.top-bar a:hover { opacity: 1; color: var(--brass-light); }

.header { background: var(--paper-raised); padding: 18px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand .mark { font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; color: var(--forest); letter-spacing: -.01em; }
.brand .sub { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); }
.nav-links { display: flex; gap: 4px; }
.nav-links a { color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 500; padding: 8px 14px; border-radius: var(--radius); transition: .15s; }
.nav-links a:hover { background: var(--paper); color: var(--forest); }

.search-bar { background: var(--forest); padding: 14px 0; }
.search-form { display: flex; gap: 0; max-width: 620px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.search-form input[type=text] { flex: 1; border: none; padding: 11px 18px; font-size: 14px; font-family: var(--font-body); background: var(--paper-raised); color: var(--ink); }
.search-form input[type=text]::placeholder { color: var(--ink-muted); }
.search-form button { border: none; background: var(--brass); color: var(--forest-dark); padding: 11px 22px; font-weight: 700; cursor: pointer; font-size: 13.5px; transition: .15s; }
.search-form button:hover { background: var(--brass-light); }

/* ---------------------------------------------------------------------
   Guide trail (breadcrumb) -- the wayfinding signature, dots on a thread
   --------------------------------------------------------------------- */
.trail { display: flex; align-items: center; flex-wrap: wrap; gap: 0; padding: 20px 0 4px; font-family: var(--font-mono); font-size: 12px; }
.trail-stop { display: flex; align-items: center; }
.trail-stop a, .trail-stop span.current { text-decoration: none; color: var(--ink-muted); padding: 4px 2px; }
.trail-stop a:hover { color: var(--forest); }
.trail-stop span.current { color: var(--ink); font-weight: 600; }
.trail-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brass); margin: 0 10px; flex-shrink: 0; }
.trail-dot.origin { background: var(--forest); }

/* ---------------------------------------------------------------------
   Hero (homepage)
   --------------------------------------------------------------------- */
.hero { padding: 56px 0 44px; }
.hero-eyebrow { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--brass); margin-bottom: 14px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 600; line-height: 1.08; color: var(--forest); max-width: 15ch; letter-spacing: -.01em; }
.hero p.lede { margin-top: 18px; font-size: 1.05rem; color: var(--ink-muted); max-width: 52ch; line-height: 1.65; }
.hero p.lede strong { color: var(--ink); font-weight: 600; }
.hero .hero-search { margin-top: 28px; max-width: 560px; }
.hero .hero-search .search-form { box-shadow: var(--shadow-lift); }

/* ---------------------------------------------------------------------
   Shelf grid (homepage category tiles) -- spine-colored left edge,
   varied like scanning an actual shelf rather than uniform cards
   --------------------------------------------------------------------- */
.shelf-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-muted); margin: 44px 0 16px; display: flex; align-items: center; gap: 12px; }
.shelf-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.shelf-tile { background: var(--paper-raised); border-radius: var(--radius); padding: 22px 20px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); border-left: 4px solid var(--spine-color, var(--forest)); transition: transform .18s ease, box-shadow .18s ease; }
.shelf-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.shelf-tile .icon { font-size: 1.6rem; color: var(--spine-color, var(--forest)); margin-bottom: 12px; }
.shelf-tile h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; margin-bottom: 5px; }
.shelf-tile .desc { font-size: .82rem; color: var(--ink-muted); line-height: 1.5; margin-bottom: 12px; min-height: 34px; }
.shelf-tile .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); }
.shelf-tile .count strong { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------------
   Two-column browse layout
   --------------------------------------------------------------------- */
.browse-layout { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; padding: 8px 0 60px; }

/* "On this shelf" -- sibling/child categories rendered as book spines */
.spine-panel { background: var(--paper-raised); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; position: sticky; top: 96px; }
.spine-panel h5 { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.spine-panel + .spine-panel { margin-top: 18px; }
.spine-list { list-style: none; display: flex; flex-direction: column; gap: 3px; }
.spine {
    display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
    padding: 8px 10px; border-radius: 3px; font-size: 13px; position: relative;
    border-left: 5px solid var(--spine-color, var(--forest));
    background: transparent; transition: background .12s;
}
.spine:hover { background: var(--paper); }
.spine.active { background: var(--forest); color: #fff; font-weight: 600; }
.spine.active .spine-count { color: var(--brass-light); }
.spine-name { flex: 1; }
.spine-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); }

/* ---------------------------------------------------------------------
   Category header + bio
   --------------------------------------------------------------------- */
.cat-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 6px; }
.cat-header .icon { font-size: 1.5rem; color: var(--spine-color, var(--forest)); margin-top: 4px; }
.cat-header h2 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--forest); }
.cat-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); margin-bottom: 20px; }

.author-bio { background: var(--paper-raised); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 24px; box-shadow: var(--shadow); border-top: 3px solid var(--brass); font-size: 14px; line-height: 1.75; color: var(--ink); }
.author-bio h1 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 8px; color: var(--forest); }
.author-bio h2, .author-bio h3 { font-family: var(--font-display); font-size: 1.02rem; margin: 14px 0 6px; color: var(--forest); }

/* ---------------------------------------------------------------------
   Filter / sort bar
   --------------------------------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; padding: 12px 14px; background: var(--paper-raised); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-bar .group { display: flex; align-items: center; gap: 6px; }
.filter-bar label { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-muted); }
.filter-bar select { border: 1px solid var(--line); background: var(--paper); padding: 6px 10px; border-radius: 3px; font-size: 12.5px; font-family: var(--font-body); color: var(--ink); }
.filter-bar .spacer { flex: 1; }
.filter-bar .result-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }

/* ---------------------------------------------------------------------
   Book cards
   --------------------------------------------------------------------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.book-card { background: var(--paper-raised); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .16s ease, box-shadow .16s ease; display: flex; flex-direction: column; position: relative; }
.book-card:hover { transform: translateY(-4px) rotate(-.3deg); box-shadow: var(--shadow-lift); }
.book-card .cover-wrap { aspect-ratio: 3/4; background: var(--paper); overflow: hidden; position: relative; }
.book-card .cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.book-card .new-ribbon { position: absolute; top: 0; right: 10px; background: var(--burgundy); color: #fff; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; padding: 3px 8px 5px; border-radius: 0 0 3px 3px; }
.book-card .lock-badge { position: absolute; top: 8px; left: 8px; background: rgba(28,37,33,.82); color: var(--brass-light); font-size: 11px; padding: 4px 6px; border-radius: 3px; }
.book-card .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-card .title { font-family: var(--font-display); font-size: .92rem; font-weight: 600; line-height: 1.3; color: var(--ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .title:hover { color: var(--forest); }
.book-card .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.book-card .chip { font-family: var(--font-mono); font-size: 9.5px; padding: 2px 6px; border-radius: 3px; font-weight: 600; letter-spacing: .02em; }
.book-card .size { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); }

/* Compact row variant (search results, admin-style listings) */
.book-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--paper-raised); margin-bottom: 6px; border-radius: var(--radius); box-shadow: var(--shadow); transition: .15s; }
.book-row:hover { box-shadow: var(--shadow-lift); }
.book-row .cover-thumb { width: 34px; height: 46px; object-fit: cover; border-radius: 2px; background: var(--paper); flex-shrink: 0; }
.book-row .title { flex: 1; font-size: 13.5px; text-decoration: none; color: var(--ink); font-weight: 500; }
.book-row .title:hover { color: var(--forest); }
.book-row .size { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); white-space: nowrap; }

/* ---------------------------------------------------------------------
   Pagination -- page-turn styling
   --------------------------------------------------------------------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 30px; font-family: var(--font-mono); font-size: 12.5px; }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 6px; text-decoration: none; color: var(--ink); border-radius: 3px; }
.pager a:hover { background: var(--paper-raised); box-shadow: var(--shadow); }
.pager .current { background: var(--forest); color: #fff; font-weight: 700; }
.pager .ellipsis { color: var(--ink-muted); }

/* ---------------------------------------------------------------------
   Book detail page
   --------------------------------------------------------------------- */
.book-detail { background: var(--paper-raised); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; display: flex; gap: 30px; flex-wrap: wrap; border-top: 4px solid var(--spine-color, var(--forest)); }
.book-detail .cover { width: 190px; flex-shrink: 0; }
.book-detail .cover img { width: 100%; border-radius: 3px; box-shadow: var(--shadow-lift); }
.book-detail .info { flex: 1; min-width: 280px; }
.book-detail h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; margin-bottom: 12px; color: var(--forest); line-height: 1.25; }
.book-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.book-summary { background: var(--paper); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; font-size: 14px; line-height: 1.75; border-left: 3px solid var(--brass); }
.book-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary { background: var(--forest); color: #fff; padding: 11px 24px; border-radius: 3px; text-decoration: none; font-weight: 600; font-size: 13.5px; transition: .15s; }
.btn-primary:hover { background: var(--forest-dark); }
.btn-secondary { background: transparent; color: var(--forest); padding: 11px 24px; border-radius: 3px; text-decoration: none; font-weight: 600; font-size: 13.5px; border: 1.5px solid var(--forest); transition: .15s; }
.btn-secondary:hover { background: var(--forest); color: #fff; }

.chip { font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 3px; letter-spacing: .02em; }

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.footer { background: var(--forest-dark); color: #C9C2A6; padding: 34px 0; text-align: center; font-size: 12px; margin-top: 50px; }
.footer a { color: #fff; }
.footer .mark { font-family: var(--font-display); font-size: 1.1rem; color: #fff; margin-bottom: 6px; display: block; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 860px) {
    .browse-layout { grid-template-columns: 1fr; }
    .spine-panel { position: static; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 560px) {
    .hero h1 { max-width: none; }
    .top-bar .container { gap: 12px; overflow-x: auto; }
}
