/* =====================================================================
   Digital Marketplace — stylesheet
   Direction: deep ink + warm gold foil, literary serif display (Fraunces)
   over Inter. Restrained glass. Book-style 3:4 product covers.
   ===================================================================== */

:root {
  --ink:        #0b0d12;
  --ink-2:      #11141c;
  --panel:      #14171f;
  --surface:    rgba(255,255,255,.04);
  --surface-2:  rgba(255,255,255,.06);
  --border:     rgba(255,255,255,.09);
  --text:       #ecebe4;
  --muted:      #9aa0ad;
  --gold:       #e6b450;
  --gold-2:     #f2cd7e;
  --violet:     #8b86c9;
  --green:      #6fcf97;
  --danger:     #e5707a;
  --shadow:     0 18px 50px rgba(0,0,0,.45);
  --radius:     16px;
  --radius-sm:  10px;
  --maxw:       1180px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  --ink:        #f6f4ee;
  --ink-2:      #efece3;
  --panel:      #ffffff;
  --surface:    rgba(20,20,25,.03);
  --surface-2:  rgba(20,20,25,.05);
  --border:     rgba(20,20,25,.10);
  --text:       #1b1c20;
  --muted:      #6a6f7a;
  --gold:       #b78420;
  --gold-2:     #9a6d12;
  --shadow:     0 16px 40px rgba(40,36,28,.14);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;   /* stop iOS auto-zooming text */
  text-size-adjust: 100%;
}
/* Kill the grey tap flash on mobile for every interactive element. */
*, a, button, input, select, textarea, .btn, .icon-btn, .book-card, label {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
button, .btn { touch-action: manipulation; }   /* removes 300ms tap delay */
body {
  margin: 0;
  font-family: var(--sans);
  background:
     radial-gradient(900px 500px at 85% -10%, rgba(230,180,80,.10), transparent 60%),
     radial-gradient(700px 500px at -5% 10%, rgba(139,134,201,.08), transparent 55%),
     var(--ink);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

h1,h2,h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; line-height: 1.12; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.eyebrow { font-family: var(--sans); text-transform: uppercase; letter-spacing: .22em;
           font-size: .72rem; color: var(--gold); font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; cursor: pointer;
  font-family: var(--sans); font-weight: 600; font-size: .95rem; line-height: 1.15;
  padding: .72rem 1.3rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  min-height: 44px;                 /* comfortable tap target on phones */
  text-align: center;
  -webkit-user-select: none; user-select: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease; }
.btn:active { transform: translateY(1px); }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1f05;
  box-shadow: 0 8px 22px rgba(230,180,80,.30); }
.btn-gold:hover { box-shadow: 0 12px 30px rgba(230,180,80,.42); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: rgba(229,112,122,.14); color: var(--danger); border-color: rgba(229,112,122,.3); }

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--ink) 78%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; gap: 1.2rem; height: 70px; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--serif);
  font-size: 1.3rem; font-weight: 600; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); box-shadow: 0 0 12px var(--gold); }
.brand img { height: 34px; width: auto; }
.nav .spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: 1.1rem; }
.nav-links a { color: var(--muted); font-size: .92rem; font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.search-box { display: flex; align-items: center; gap: .5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: .35rem .9rem; }
.search-box input { background: none; border: none; outline: none; color: var(--text); width: 180px; font-size: .9rem; }

/* ---------- Hero ---------- */
.hero { padding: 4.5rem 0 2.5rem; position: relative; }
.hero .lead { max-width: 620px; }
.hero p.sub { font-size: 1.12rem; color: var(--muted); max-width: 540px; margin: 1rem 0 1.8rem; }
.hero .gold-text { color: var(--gold-2);
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- Product grid: book cards ---------- */
.section-head { display: flex; align-items: end; justify-content: space-between; margin: 2.6rem 0 1.3rem; }
.grid { display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.book-card { display: flex; flex-direction: column; }
.book-cover { position: relative; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, #1d212c, #11141c);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease; }
/* book spine highlight */
.book-cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
  background: linear-gradient(to right, rgba(0,0,0,.35), rgba(255,255,255,.06));
  z-index: 2; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .noimg { width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--serif); color: var(--muted); font-size: .9rem; padding: 1rem; text-align: center; }
.book-card:hover .book-cover { transform: translateY(-6px) rotate(-.5deg); box-shadow: 0 26px 60px rgba(0,0,0,.55); }
.book-cover .price-tag { position: absolute; right: 8px; bottom: 8px; z-index: 3;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1f05;
  font-weight: 700; font-size: .82rem; padding: .25rem .6rem; border-radius: 8px; }
.book-cover .strike { position: absolute; left: 12px; bottom: 10px; z-index: 3; color: #fff;
  font-size: .72rem; text-decoration: line-through; opacity: .7; }
.book-meta { padding: .7rem .1rem 0; }
.book-meta .title { font-family: var(--serif); font-size: 1.02rem; font-weight: 500;
  margin: 0 0 .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta .desc { font-size: .82rem; color: var(--muted); display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stars { color: var(--gold); font-size: .82rem; letter-spacing: .04em; }
.stars .count { color: var(--muted); margin-left: .3rem; }

/* ---------- Product detail ---------- */
.product-detail { display: grid; grid-template-columns: 360px 1fr; gap: 2.4rem; margin: 2.2rem 0; }
.product-detail .cover-lg { aspect-ratio: 3/4; border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border); position: sticky; top: 90px; }
.product-detail .cover-lg img { width: 100%; height: 100%; object-fit: cover; }
.buy-card { padding: 1.4rem; margin-top: 1.2rem; }
.price-row { display: flex; align-items: baseline; gap: .7rem; margin-bottom: 1rem; }
.price-row .now { font-family: var(--serif); font-size: 2rem; color: var(--gold-2); }
.price-row .was { color: var(--muted); text-decoration: line-through; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: .8rem; margin: 1.2rem 0; }
.gallery img { border-radius: 10px; border: 1px solid var(--border); aspect-ratio: 16/10; object-fit: cover; }
.feature-list { list-style: none; padding: 0; margin: 1rem 0; }
.feature-list li { padding: .35rem 0 .35rem 1.6rem; position: relative; color: var(--muted); }
.feature-list li::before { content: "✦"; color: var(--gold); position: absolute; left: 0; }

/* ---------- Forms ---------- */
.auth-wrap { max-width: 430px; margin: 3.5rem auto; padding: 2.2rem; }
.field { margin-bottom: 1.05rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: .8rem .9rem; background: var(--ink-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 16px; font-family: var(--sans); outline: none; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(230,180,80,.18); }
textarea.input { min-height: 120px; resize: vertical; }

/* ---------- Alerts ---------- */
.alert { padding: .85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.2rem; font-size: .9rem; }
.alert-error { background: rgba(229,112,122,.12); border: 1px solid rgba(229,112,122,.3); color: var(--danger); }
.alert-ok { background: rgba(111,207,151,.12); border: 1px solid rgba(111,207,151,.3); color: var(--green); }

/* ---------- Dashboard / tables ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 1.2rem; margin: 1.6rem 0; }
.stat { padding: 1.3rem; }
.stat .k { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.stat .v { font-family: var(--serif); font-size: 2rem; margin-top: .3rem; color: var(--gold-2); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
th, td { text-align: left; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
tr:last-child td { border-bottom: none; }
.badge { font-size: .72rem; padding: .2rem .55rem; border-radius: 999px; font-weight: 600; }
.badge.paid { background: rgba(111,207,151,.15); color: var(--green); }
.badge.pending { background: rgba(230,180,80,.15); color: var(--gold-2); }
.badge.failed { background: rgba(229,112,122,.15); color: var(--danger); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 2.4rem 0; color: var(--muted); font-size: .88rem; }
.site-footer .row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }

/* ---------- Admin shell ---------- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-side { background: var(--ink-2); border-right: 1px solid var(--border); padding: 1.4rem 1rem; }
.admin-side .brand { margin-bottom: 1.6rem; padding: 0 .4rem; }
.admin-side nav a { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem;
  border-radius: 10px; color: var(--muted); font-size: .92rem; font-weight: 500; margin-bottom: .25rem; }
.admin-side nav a:hover { background: var(--surface); color: var(--text); }
.admin-side nav a.active { background: linear-gradient(135deg, rgba(230,180,80,.18), rgba(230,180,80,.06));
  color: var(--gold-2); border: 1px solid rgba(230,180,80,.2); }
.admin-main { padding: 1.8rem 2rem; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.6rem; }

/* ---------- Utilities ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.flex { display: flex; gap: .8rem; align-items: center; }
.mt-1 { margin-top: .6rem; } .mt-2 { margin-top: 1.2rem; } .mt-3 { margin-top: 2rem; }
.text-c { text-align: center; }
.pill { display:inline-block; background: var(--surface); border: 1px solid var(--border);
  padding: .25rem .7rem; border-radius: 999px; font-size: .78rem; color: var(--muted); }

/* ---------- Responsive ---------- */

/* Tablets / small laptops */
@media (max-width: 1024px) {
  .product-detail { grid-template-columns: 300px 1fr; gap: 1.8rem; }
  .admin-shell { grid-template-columns: 200px 1fr; }
  .admin-main { padding: 1.6rem 1.4rem; }
}

/* Tablet portrait & large phones */
@media (max-width: 860px) {
  .container { padding: 0 16px; }
  .product-detail { grid-template-columns: 1fr; gap: 1.4rem; }
  .product-detail .cover-lg { position: relative; top: 0; max-width: 300px; margin: 0 auto; }
  .buy-card { max-width: 360px; margin-left: auto; margin-right: auto; }

  /* Admin: collapsible off-canvas sidebar */
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: fixed; left: -280px; top: 0; bottom: 0; width: 250px; z-index: 100;
    transition: left .25s ease; box-shadow: 0 0 0 100vmax transparent; }
  .admin-side.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .admin-main { padding: 1.2rem 1rem; }
  #menuBtn { display: grid !important; }   /* show hamburger regardless of inline style */
  .search-box input { width: 130px; }
  .hero { padding: 3rem 0 2rem; }
}

/* Phones */
@media (max-width: 640px) {
  .nav { height: auto; flex-wrap: wrap; gap: .6rem; padding-top: .7rem; padding-bottom: .7rem; }
  .nav .spacer { display: none; }
  .brand { font-size: 1.15rem; flex: 1; }
  .search-box { order: 3; flex: 1 1 100%; display: flex; }
  .search-box input { width: 100%; flex: 1; font-size: 16px; }
  .nav-links { gap: .5rem; flex-wrap: wrap; }
  .nav-links a, .nav-links .btn { font-size: .9rem; }
  .nav-links .btn { padding: .55rem .9rem; min-height: 40px; }

  .section-head { flex-direction: column; align-items: flex-start; gap: .5rem; margin: 1.8rem 0 1rem; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: .9rem; }
  .book-meta .title { font-size: .92rem; }

  .auth-wrap { margin: 1.8rem auto; padding: 1.5rem 1.2rem; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: .8rem; }
  .stat { padding: 1rem; }
  .stat .v { font-size: 1.5rem; }

  .site-footer { padding: 2rem 0; margin-top: 2.5rem; }
  .site-footer .row { flex-direction: column; gap: .8rem; }

  /* Buttons feel better full-width when they're the main action on a narrow screen */
  .hero .btn, .auth-wrap .btn { width: 100%; }

  /* Tables stay scrollable; keep action buttons from collapsing too small */
  td .btn, th .btn { min-height: 38px; }
  td form { display: inline-block; margin: .15rem .1rem; }
}

/* Small phones */
@media (max-width: 400px) {
  h1 { font-size: 1.7rem; }
  .grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .btn { font-size: .9rem; padding: .65rem 1rem; }
  .nav-links .btn { flex: 1; }
}

/* Coarse-pointer (touch) refinements regardless of width */
@media (hover: none) and (pointer: coarse) {
  .book-card:hover .book-cover { transform: none; box-shadow: var(--shadow); }
  .btn:hover { box-shadow: none; }
}

/* ---------- Motion: respect reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Fade-in on load */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .5s ease both; }

/* ---------- Legal / content pages ---------- */
.legal { max-width: 820px; margin: 2.4rem auto 3rem; }
.legal h1 { margin-bottom: .3rem; }
.legal .updated { color: var(--muted); font-size: .85rem; margin-bottom: 1.8rem; }
.legal h2 { font-size: 1.25rem; margin: 2rem 0 .6rem; }
.legal h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
.legal p, .legal li { color: var(--text); opacity: .92; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin: .35rem 0; }
.legal a { color: var(--gold-2); }
.legal .glass { padding: 1.2rem 1.4rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: .9rem 1.2rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }
