/* Bahi Books — mobile-first shelf layout
   Cream paper, wine accent, heavy serif titles. */

:root {
  --cream: #FDF7EE;
  --cream-2: #F4E9DA;
  --card: #FFFFFF;
  --ink: #241A18;
  --wine: #7C2340;
  --wine-dark: #631A33;
  --muted: #8B8079;
  --line: #F0E5D6;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --pad: 1.15rem;
  --max: 1180px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 4.5rem;
}

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

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--wine);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--wine);
  color: #fff;
  padding: .7rem 1rem;
  text-decoration: none;
  font-size: .9rem;
}
.skip:focus { top: 1rem; }

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.bar {
  display: grid;
  grid-template-columns: 2.6rem 1fr 5.4rem;
  align-items: center;
  gap: .25rem;
  max-width: var(--max);
  margin-inline: auto;
  padding: .6rem var(--pad);
  min-height: 4rem;
}

.icon-btn {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink);
  border-radius: 50%;
}
.icon-btn:hover { background: var(--cream); }
.icon-btn svg { width: 1.45rem; height: 1.45rem; }

.menu-btn { justify-self: start; }

.bar-actions {
  display: flex;
  align-items: center;
  gap: .1rem;
  justify-self: end;
}

.wordmark {
  text-align: center;
  text-decoration: none;
  line-height: 1;
}

.wordmark-name {
  display: block;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.03em;
}
.wordmark-name span { color: var(--wine); }

.wordmark-tag {
  display: block;
  margin-top: .22rem;
  font-size: .55rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.bag-count {
  position: absolute;
  top: .35rem;
  right: .3rem;
  min-width: 1rem;
  height: 1rem;
  padding-inline: .22rem;
  border-radius: 999px;
  background: var(--wine);
  color: #fff;
  font-size: .6rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}

/* Search */

.search-panel {
  display: none;
  gap: .5rem;
  max-width: var(--max);
  margin-inline: auto;
  padding: 0 var(--pad) .8rem;
}
.search-panel.is-open { display: flex; }

.search-panel input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--cream);
  border-radius: 999px;
  padding: .62rem 1rem;
  font-size: .9rem;
}
.search-panel input::placeholder { color: var(--muted); }
.search-panel input:focus-visible { outline-offset: 0; }

.search-clear {
  border: 0;
  background: transparent;
  color: var(--wine);
  font-size: .82rem;
  font-weight: 600;
  padding-inline: .35rem;
}

/* Nav sheet */

.nav-sheet {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--card);
  padding: .35rem var(--pad) .9rem;
  box-shadow: 0 12px 24px rgba(60, 30, 20, .08);
}
.nav-sheet.is-open { display: block; }
.nav-sheet a {
  display: block;
  padding: .8rem 0;
  text-decoration: none;
  font-size: .95rem;
  border-bottom: 1px solid var(--line);
}
.nav-sheet a:last-child { border-bottom: 0; }

.search-status {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem var(--pad) 0;
  font-size: .85rem;
  color: var(--muted);
}

/* ---------- Sections ---------- */

main {
  max-width: var(--max);
  margin-inline: auto;
}

.intro { padding: 1.65rem var(--pad) .35rem; }

.intro h1 {
  font-size: clamp(1.55rem, 6.6vw, 2.15rem);
  line-height: 1.12;
  max-width: 20ch;
}

.intro p {
  margin-top: .65rem;
  max-width: 34rem;
  font-size: .9rem;
  line-height: 1.55;
  color: #6C5F58;
}

.shelf { padding: 1.5rem var(--pad) .5rem; }

.shelf + .shelf { padding-top: 2rem; }

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.shelf-head h1,
.shelf-head h2 {
  font-size: clamp(1.4rem, 6vw, 1.95rem);
  line-height: 1.1;
}

.view-all {
  flex: none;
  font-size: .82rem;
  font-weight: 600;
  color: var(--wine);
  text-decoration: none;
  padding-bottom: .1rem;
}
.view-all:hover { text-decoration: underline; }

/* ---------- Best seller cards ---------- */

.seller-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: .7rem;
}

@media (min-width: 480px) {
  .seller-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seller-cover { width: 5.2rem; height: 7.4rem; }
  .seller-title { font-size: .95rem; }
}

.seller-card {
  display: flex;
  gap: .6rem;
  background: var(--card);
  border-radius: 1.05rem;
  padding: .6rem;
  box-shadow: 0 6px 18px rgba(60, 30, 20, .07);
  min-width: 0;
}

.seller-cover {
  flex: none;
  width: 6rem;
  height: 8.4rem;
  border-radius: .55rem;
  background: var(--cream-2);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: .2rem;
}

.seller-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.seller-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.seller-title {
  font-size: 1rem;
  line-height: 1.22;
  letter-spacing: -.005em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.seller-author {
  margin-top: .25rem;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.3;
}

.seller-foot {
  margin-top: auto;
  padding-top: .5rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .35rem;
}

.price { display: grid; }

.price-was {
  font-size: .68rem;
  color: var(--muted);
  text-decoration: line-through;
  line-height: 1.2;
}

.price-now {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--wine);
  line-height: 1.2;
  white-space: nowrap;
}

.fab {
  flex: none;
  width: 2.15rem;
  height: 2.15rem;
  border: 0;
  border-radius: 50%;
  background: var(--wine);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(124, 35, 64, .3);
  transition: transform .15s ease, background-color .15s ease;
}
.fab svg { width: 1.05rem; height: 1.05rem; }
.fab:hover { background: var(--wine-dark); transform: scale(1.05); }
.fab:active { transform: scale(.96); }

/* ---------- Cover tiles ---------- */

.tile-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem .7rem;
}

.tile { min-width: 0; }

.tile-media {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--cream-2);
}

.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: .7rem;
}

.wish,
.tile-cart {
  position: absolute;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background-color .15s ease, color .15s ease;
}

.wish {
  top: .5rem;
  right: .5rem;
  width: 2rem;
  height: 2rem;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(60, 30, 20, .16);
}
.wish svg { width: 1.05rem; height: 1.05rem; }
.wish:hover { color: var(--wine); }
.wish[aria-pressed="true"] { color: var(--wine); }
.wish[aria-pressed="true"] svg path { fill: currentColor; }

.tile-cart {
  bottom: .5rem;
  right: .5rem;
  width: 2.3rem;
  height: 2.3rem;
  background: var(--wine);
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 35, 64, .34);
}
.tile-cart svg { width: 1.1rem; height: 1.1rem; }
.tile-cart:hover { background: var(--wine-dark); }

.tile-title {
  margin-top: .55rem;
  font-size: .93rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-price {
  margin-top: .25rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--wine);
}

.no-results {
  border: 1px dashed #E3D3BF;
  border-radius: 1rem;
  background: #FFFCF6;
  padding: 1.75rem 1.25rem;
  text-align: center;
}
.no-results p { color: var(--muted); font-size: .9rem; margin-bottom: .9rem; }

.clear-btn {
  border: 1px solid var(--wine);
  background: transparent;
  color: var(--wine);
  font-size: .84rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .5rem 1.1rem;
}

/* ---------- Visit ---------- */

.visit { padding: 2rem var(--pad) 1rem; }

.visit-card {
  background: var(--card);
  border-radius: 1.25rem;
  padding: 1.35rem 1.15rem;
  box-shadow: 0 6px 18px rgba(60, 30, 20, .06);
}

.visit-card h2 { font-size: 1.3rem; }

.visit-lede {
  margin-top: .5rem;
  font-size: .87rem;
  color: var(--muted);
}

.visit-facts {
  margin: 1rem 0 0;
  display: grid;
  gap: .65rem;
}
.visit-facts > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: .75rem;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
}
.visit-facts dt {
  font-size: .7rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: .12rem;
}
.visit-facts dd { margin: 0; font-size: .86rem; line-height: 1.45; }
.visit-facts a { color: var(--wine); text-decoration: none; }
.visit-facts a:hover { text-decoration: underline; }

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

.site-footer {
  max-width: var(--max);
  margin: 1.5rem auto 0;
  padding: 1.5rem var(--pad) 2rem;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer-name {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .3rem;
}

/* ---------- Tab bar (mobile) ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  display: grid;
  justify-items: center;
  gap: .18rem;
  padding: .55rem 0 .65rem;
  font-size: .66rem;
  font-weight: 500;
}
.tab svg { width: 1.3rem; height: 1.3rem; }
.tab.is-active { color: var(--wine); font-weight: 700; }
.tab:hover { color: var(--wine); }

.tab-count {
  position: absolute;
  top: .3rem;
  left: calc(50% + .35rem);
  min-width: .95rem;
  height: .95rem;
  padding-inline: .2rem;
  border-radius: 999px;
  background: var(--wine);
  color: #fff;
  font-size: .58rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------- Cart ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 26, 24, .48);
  opacity: 0;
  transition: opacity .2s ease;
  z-index: 60;
}
.overlay.is-visible { opacity: 1; }

.cart {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(23rem, 100%);
  background: var(--card);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  box-shadow: -10px 0 40px rgba(36, 26, 24, .18);
}
.cart.is-open { transform: translateX(0); }

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.cart-head h2 { font-size: 1.2rem; }

.cart-close {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
}
.cart-close svg { width: .85rem; height: .85rem; }

.cart-body { flex: 1; overflow-y: auto; padding: 1.1rem; }

.cart-empty { font-size: .88rem; color: var(--muted); }

.cart-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }

.cart-item {
  display: grid;
  grid-template-columns: 2.9rem minmax(0, 1fr) auto;
  gap: .8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.cart-item img {
  width: 2.9rem;
  height: 3.9rem;
  object-fit: contain;
  background: var(--cream-2);
  border-radius: .4rem;
}
.cart-item-title { font-family: var(--display); font-weight: 600; font-size: .95rem; line-height: 1.25; }
.cart-item-author { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.cart-item-price {
  font-size: .78rem;
  color: var(--wine);
  font-weight: 600;
  margin-top: .25rem;
}

.cart-remove {
  border: 0;
  background: transparent;
  font-size: .72rem;
  color: var(--muted);
  text-decoration: underline;
  padding: 0;
}
.cart-remove:hover { color: var(--ink); }

.cart-foot {
  padding: 1rem 1.1rem 1.2rem;
  border-top: 1px solid var(--line);
  background: var(--cream);
}

.cart-row {
  display: flex;
  justify-content: space-between;
  font-size: .95rem;
  font-weight: 600;
}
.cart-ship { font-size: .76rem; color: var(--muted); margin-top: .3rem; }

.checkout {
  width: 100%;
  margin-top: .9rem;
  min-height: 2.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--wine);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
}
.checkout:hover { background: var(--wine-dark); }
.checkout:disabled { background: #D8C8BD; cursor: not-allowed; }

.cart-small {
  margin-top: .6rem;
  text-align: center;
  font-size: .7rem;
  color: var(--muted);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.2rem;
  transform: translate(-50%, .75rem);
  background: var(--ink);
  color: var(--cream);
  padding: .6rem 1rem;
  border-radius: 999px;
  font-size: .82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 80;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Larger screens ---------- */

@media (min-width: 640px) {
  .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem 1rem; }
  .shelf-head h1, .shelf-head h2 { font-size: 1.85rem; }
}

@media (min-width: 768px) {
  .seller-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
}

@media (min-width: 900px) {
  body { padding-bottom: 0; }

  .bar {
    grid-template-columns: auto 1fr auto;
    min-height: 4.6rem;
    padding-inline: 2rem;
  }

  .menu-btn { display: none; }

  .wordmark { grid-column: 1; text-align: left; justify-self: start; }

  .wordmark-name { font-size: 1.7rem; }

  .nav-sheet {
    display: flex !important;
    position: static;
    grid-column: 2;
    justify-content: center;
    gap: 1.6rem;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    max-width: none;
  }
  .nav-sheet a {
    padding: .3rem 0;
    border-bottom: 1px solid transparent;
    font-size: .87rem;
    color: var(--muted);
  }
  .nav-sheet a:hover { color: var(--wine); border-bottom-color: var(--wine); }

  .bar-actions { grid-column: 3; gap: .35rem; justify-self: end; }

  .search-panel {
    display: flex;
    padding: 0 2rem .9rem;
  }
  .search-btn { display: none; }
  .search-panel input { max-width: 26rem; border-radius: 999px; }

  .intro { padding: 2.5rem 2rem .5rem; }
  .intro h1 { font-size: 2.35rem; max-width: 24ch; }
  .intro p { font-size: .98rem; max-width: 42rem; }

  .shelf { padding: 2.25rem 2rem 1rem; }
  .shelf + .shelf { padding-top: 2.75rem; }

  .seller-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
  .seller-card { padding: .8rem; gap: .75rem; border-radius: 1.15rem; }
  .seller-cover { width: 6rem; height: 8.4rem; }
  .seller-title { font-size: 1.02rem; }
  .seller-author { font-size: .8rem; }
  .price-now { font-size: 1.1rem; }
  .fab { width: 2.4rem; height: 2.4rem; }

  .tile-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.6rem 1.15rem; }
  .tile-title { font-size: 1rem; }

  .visit { padding: 2.75rem 2rem 1.5rem; }
  .visit-card { padding: 1.9rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 2rem; align-items: start; }
  .visit-card h2 { font-size: 1.5rem; }
  .visit-facts { margin-top: 0; }

  .site-footer { padding: 1.75rem 2rem 2.5rem; }

  .tabbar { display: none; }
  .toast { bottom: 1.75rem; }
}

@media (min-width: 1100px) {
  .seller-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
