/* Layout: slim top bar with a kasavu-style double gold rule, one centred column.
   Home is a shelf of cover photos; a book page lets the visitor flip the cover to its back.
   Malayalam text: no added letter-spacing, generous line-height. */
:root {
  color-scheme: light dark;
  --bg: #f1f4f0;
  --surface: #fafcf9;
  --fg: #16241d;
  --muted: #586a60;
  --line: #d3dcd5;
  --accent: #1c6a49;
  --accent-fg: #ffffff;
  --gold: #b58a2c;
  --danger: #a63636;
  --ok: #1c6a49;
  --c0: #2c4a7c;
  --c1: #9b3f4a;
  --c2: #8a5f10;
  --c3: #3a6b4a;
  --c4: #5a4390;
  --c5: #2a6a80;
  --cover-fg: #f8f7f1;
  --font-display: 'Noto Serif Malayalam', 'Anek Malayalam', Georgia, serif;
  --font-body: 'Anek Malayalam', 'Noto Sans Malayalam', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1612;
    --surface: #15201a;
    --fg: #e4eee8;
    --muted: #9bb0a4;
    --line: #2a3b32;
    --accent: #5fc291;
    --accent-fg: #07200f;
    --gold: #d9ae55;
    --danger: #ee8686;
    --ok: #5fc291;
    --c0: #38599a;
    --c1: #a84c57;
    --c2: #94660f;
    --c3: #3f7a53;
    --c4: #6a52a8;
    --c5: #2f7a91;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 1.05rem; line-height: 1.7; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 62rem; margin-inline: auto; padding-inline: 16px; padding-block: 20px 56px; }
.loading, .empty { padding: 32px 0; color: var(--muted); }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding-bottom: 12px; border-bottom: 4px double var(--gold); }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.5; color: var(--fg); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { background: none; border: 0; cursor: pointer; padding: 4px 10px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; text-decoration: none; }
.tab[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

.btn { display: inline-block; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); padding: 6px 14px; border-radius: 6px; font-weight: 600; line-height: 1.5; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 2px 10px; font-size: .85rem; }
.btn.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn[disabled] { opacity: .6; cursor: default; }

.intro { padding-block: 24px 4px; }
h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 5.5vw, 2.5rem); line-height: 1.4; text-wrap: balance; }
.lede { margin: 6px 0 0; color: var(--muted); }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-block: 20px; }
.search { flex: 1 1 14rem; min-width: 0; }
.field { width: 100%; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); line-height: 1.5; }
textarea.field { resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 1px 14px; font-size: .92rem; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 26px 16px; margin: 0; padding: 0; list-style: none; }
.book { display: flex; flex-direction: column; min-width: 0; color: inherit; text-decoration: none; }
.photo { aspect-ratio: 2 / 3; overflow: hidden; border-radius: 2px 6px 6px 2px; background: var(--surface); box-shadow: inset 6px 0 0 rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.25); }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cap { display: flex; flex-direction: column; margin-top: 8px; }
.cap strong { font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.cap span { font-size: .85rem; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.cover { display: flex; flex-direction: column; justify-content: space-between; gap: 18px; aspect-ratio: 2 / 3; margin: 0; padding: 16px 10px 12px 18px; border-radius: 2px 6px 6px 2px; color: var(--cover-fg); box-shadow: inset 7px 0 0 rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.25); }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: var(--c5); }
.cv-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1.45; overflow-wrap: anywhere; }
.cv-author { font-size: .8rem; line-height: 1.5; opacity: .9; overflow-wrap: anywhere; }
.meta { display: flex; flex-direction: column; margin-top: 8px; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.price { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.cond, .genre { font-size: .85rem; color: var(--muted); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .book .photo, .book .cover { transition: transform .15s; }
  .book:hover .photo, .book:hover .cover { transform: translateY(-3px); }
}

.detail { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 28px 40px; padding-top: 24px; align-items: start; }
@media (max-width: 48rem) { .detail { grid-template-columns: minmax(0, 1fr); } }
.viewer { display: flex; flex-direction: column; gap: 14px; max-width: 22rem; }
.stage { position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; padding: 0; border: 0; background: none; perspective: 1400px; cursor: pointer; }
div.stage { cursor: default; }
.flip-inner { position: absolute; inset: 0; transition: transform .6s; transform-style: preserve-3d; }
.flip-inner.is-back { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; overflow: hidden; border-radius: 2px 6px 6px 2px; background: var(--surface); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.28); }
.face .cover { height: 100%; aspect-ratio: auto; box-shadow: inset 7px 0 0 rgba(0,0,0,.2); }
.face img { display: block; width: 100%; height: 100%; object-fit: contain; }
.back-face { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { cursor: pointer; border: 0; background: transparent; padding: 2px 16px; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.hint { font-size: .85rem; color: var(--muted); }
.info h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.author { margin: 4px 0 0; font-size: 1.1rem; color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 18px 0; }
.facts .price { font-size: 1.5rem; }
.desc p { margin: 10px 0; white-space: pre-line; max-width: 38rem; }
.contact { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.contact p { margin: 0 0 10px; }
.mail { font-family: var(--font-mono); font-size: .95rem; overflow-wrap: anywhere; }

.prose { max-width: 38rem; padding-block: 24px 0; }
.prose h2 { margin: 28px 0 6px; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.5; }
.prose p { margin: 10px 0; white-space: pre-line; }
.prose ol { margin: 10px 0; padding-left: 1.4rem; }
.prose li { margin: 6px 0; }
.grades { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 12px 0; }
.grades dt { font-weight: 600; }
.grades dd { margin: 0; color: var(--muted); }
@media (max-width: 30rem) { .grades { grid-template-columns: 1fr; gap: 0; } .grades dd { margin-bottom: 10px; } }

/* Admin */
.admin-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding-bottom: 12px; border-bottom: 4px double var(--gold); }
.admin-top h1 { font-size: 1.5rem; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.note { margin: 14px 0 0; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); }
.note.ok { border-color: var(--ok); }
.note.bad { border-color: var(--danger); color: var(--danger); }
.panel { margin-block: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.panel h2 { margin: 0 0 12px; font-family: var(--font-body); font-weight: 600; font-size: 1.1rem; }
.panel.login { max-width: 24rem; margin-inline: auto; margin-top: 48px; }
.panel.login h1 { font-size: 1.5rem; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: .88rem; color: var(--muted); }
label.f .field { background: var(--bg); color: var(--fg); }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.error { margin: 0; color: var(--danger); font-size: .92rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 16px; }
.pf { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pf-label { font-size: .88rem; color: var(--muted); }
.pv-box { display: flex; align-items: center; justify-content: center; width: 8rem; aspect-ratio: 2 / 3; border: 1px dashed var(--line); border-radius: 4px; background: var(--bg); overflow: hidden; }
.pv-box img { width: 100%; height: 100%; object-fit: cover; }
.pf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pf input[type="file"] { max-width: 100%; font-size: .85rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; }
.items { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.item .thumb { width: 3.5rem; aspect-ratio: 2 / 3; flex: none; border-radius: 2px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.item .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.item .info { flex: 1 1 12rem; min-width: 0; }
.item .info strong { display: block; overflow-wrap: anywhere; line-height: 1.5; }
.item .info span { font-size: .88rem; color: var(--muted); }
.item .btns { display: flex; flex-wrap: wrap; gap: 6px; }
.qr { display: block; width: 12rem; max-width: 100%; height: auto; margin: 8px 0; image-rendering: pixelated; border: 1px solid var(--line); background: #fff; }
.codes { margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-family: var(--font-mono); font-size: 1rem; line-height: 1.8; user-select: all; overflow-x: auto; }
.panel .mail { margin: 4px 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* sold-out books */
.book.sold .photo img, .book.sold .cover { opacity: .5; filter: grayscale(.6); }
.photo { position: relative; }
.badge { position: absolute; left: 6px; top: 8px; background: #7a1f1f; color: #fff; font-size: .8rem; padding: 2px 8px; border-radius: 3px; }
.soldtxt { color: #7a1f1f; }
.check { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }

/* gallery */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 16px; margin: 16px 0 0; padding: 0; list-style: none; }
.gal li { margin: 0; }
.gal-btn { display: block; width: 100%; padding: 0; border: 0; background: var(--surface); border-radius: 6px; overflow: hidden; cursor: zoom-in; aspect-ratio: 1; }
.gal-btn img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gal-cap { margin: 6px 0 0; font-size: .92rem; color: var(--muted); overflow-wrap: anywhere; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.lightbox p { color: #fff; margin: 0; text-align: center; }
main > h1:first-child { margin-top: 28px; }
.price.soldtxt { font-family: inherit; font-weight: 600; }

/* Featured row and the New Arrival tag */
.highlight { margin-top: 24px; }
.highlight h2 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.3rem, 4.5vw, 1.8rem); line-height: 1.4; }
.cover { position: relative; }
.badge.new { left: auto; right: 4px; top: 8px; font-size: .7rem; padding: 2px 6px; background: #8a5a1b; letter-spacing: .03em; transform: rotate(4deg); box-shadow: 0 1px 2px rgba(0,0,0,.35); }

/* Instagram / Facebook buttons */
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 40px; padding-top: 16px; border-top: 4px double var(--gold); color: var(--muted); }
.social { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); font-weight: 600; text-decoration: none; }
.social:hover { background: var(--accent); color: var(--accent-fg); }
.cover .badge.new { top: auto; bottom: 10px; }
.reach { display: flex; flex-wrap: wrap; gap: 10px 12px; }

/* Coming soon page (no books yet) */
.soon { padding-block: 24px 0; text-align: center; }
.soon-logo { position: relative; width: min(30rem, 88%); margin: 0 auto; }
.soon-logo img { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.soon-over { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-34%); padding-inline: 10%; color: #fff4d8; text-shadow: 0 2px 3px #000, 0 0 12px rgba(0,0,0,.95), 0 0 28px rgba(0,0,0,.8); }
.soon-over h1 { color: inherit; font-size: clamp(1.9rem, 9vw, 3.6rem); line-height: 1.1; }
.soon-over p { margin: 6px 0 0; font-weight: 700; font-size: clamp(.95rem, 4vw, 1.6rem); line-height: 1.25; }
.soon-over.maint h1 { font-size: clamp(1.3rem, 6vw, 2.3rem); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

.about-grid { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: 40px; align-items: start; padding-block: 24px 0; }
.about-logo { width: 100%; height: auto; border-radius: 50%; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.about-grid .prose { padding-block: 0; }
@media (max-width: 700px) {
  .about-grid { grid-template-columns: 1fr; gap: 20px; }
  .about-logo { max-width: 240px; margin-inline: auto; }
}
/* Coming soon: dimmed logo, wide heading across it */
.soon-logo.dim img { filter: brightness(.5) drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.soon-over.wide { padding-inline: 4%; }
.soon-over.wide h1 { white-space: nowrap; letter-spacing: .08em; text-transform: uppercase; font-size: clamp(1.5rem, 7.2vw, 3rem); }
.preview-banner { margin: 0 0 12px; padding: 8px 12px; border: 1px dashed var(--accent); border-radius: 6px; background: var(--surface); font-size: .95rem; text-align: center; }
