@import url("tokens.css");

/* ==========================================================
   Reset & base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "ss01","cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ==========================================================
   Type
   ========================================================== */
.display, .h1, .h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; line-height: 1.02; color: var(--ink); }
.display { font-size: clamp(56px, 8vw, 112px); }
.h1      { font-size: clamp(40px, 5vw, 64px); }
.h2      { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.08; }
.h3      { font-family: var(--font-display); font-weight: 400; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.15; }
.italic-accent { font-style: italic; color: var(--accent); }
.eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}
.lede { font-family: var(--font-serif); font-size: clamp(17px, 1.4vw, 19px); line-height: 1.55; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.mono  { font-family: var(--font-mono); }

/* ==========================================================
   Layout
   ========================================================== */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 28px; }
.wrap-wide { max-width: 1440px; margin: 0 auto; padding: 0 28px; }
.row { display: flex; align-items: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.section { padding: var(--s-11) 0; }
.section-sm { padding: var(--s-9) 0; }
.divider-soft { border-top: 1px solid var(--line); }

/* ==========================================================
   Header
   ========================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.site-header .inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: 28px;
  max-width: 1440px; margin: 0 auto; padding: 0 28px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 22px;
  letter-spacing: -0.01em; color: var(--ink);
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFE7A0 0%, var(--accent) 55%, var(--accent-deep) 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.nav { display: flex; align-items: center; gap: 22px; }
.nav a {
  font-size: 14px; color: var(--ink-2); position: relative;
  padding: 6px 0;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); }
.nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; height: 44px; padding: 0 18px;
  border-radius: var(--r-pill);
  font-weight: 500; font-size: 14px; letter-spacing: 0.01em;
  transition: transform var(--dur-fast) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--ink); color: var(--bg);
}
.btn-primary:hover { background: var(--ink-2); }
.btn-accent {
  background: var(--accent); color: var(--accent-ink);
}
.btn-accent:hover { background: var(--accent-deep); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-3); }
.btn-soft {
  background: var(--accent-soft); color: var(--accent-deep);
}
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 30%); color: var(--accent-ink); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 15px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.btn-icon:hover { background: var(--surface); color: var(--ink); }

/* Theme toggle — icon button in header + labeled row in mobile drawer */
.theme-toggle svg { transition: transform var(--dur) var(--ease); }
.theme-toggle:hover svg { transform: rotate(-18deg); }
.theme-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  font-size: 13px; color: var(--ink-3);
  padding: 4px 0;
}
.theme-row svg { color: var(--ink-2); }
.theme-row-state { font-size: 12px; color: var(--ink-4); }
.theme-row-state.on { color: var(--accent); }

/* Tag/pill */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip-accent { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }
.chip-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: inline-block;
}

/* ==========================================================
   Inputs
   ========================================================== */
.input, .select {
  height: 40px; padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px; color: var(--ink);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--ink-3); background: var(--surface-2); }
.search {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--ink-3); }
.search input { background: transparent; border: 0; flex: 1; height: 100%; min-width: 0; }
.search input::placeholder { color: var(--ink-4); }
.search svg { color: var(--ink-3); flex-shrink: 0; }

/* ==========================================================
   Cards
   ========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* ==========================================================
   Book covers (CSS/SVG covers — see js/covers.jsx)
   ========================================================== */
.cover {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-cover);
  background: #DDD;
  transform: translateZ(0);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cover svg { width: 100%; height: 100%; display: block; }
.cover .cover-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 12px;
  background: linear-gradient(to right, rgba(0,0,0,.18), transparent);
  pointer-events: none;
}
.cover .cover-gloss {
  position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 28%, rgba(255,255,255,0) 70%, rgba(0,0,0,.05) 100%);
  pointer-events: none;
}
.cover-lift:hover { transform: translateY(-4px) rotate(-0.3deg); }

/* Book card (grid item) */
.book-card {
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer; text-align: left;
}
.book-card .cover { transition: transform var(--dur) var(--ease); }
.book-card:hover .cover { transform: translateY(-4px); box-shadow: 0 40px 70px -25px rgba(27,22,16,.5), 0 14px 24px -10px rgba(27,22,16,.3); }
.book-card .title-line { font-family: var(--font-serif); font-size: 15px; color: var(--ink); line-height: 1.25; font-weight: 500; }
.book-card .author-line { font-size: 13px; color: var(--ink-3); }
.book-card .meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.book-card .price { font-family: var(--font-serif); font-size: 14px; color: var(--ink-2); }
.book-card .format-icons { display: flex; gap: 6px; color: var(--ink-3); }

/* ==========================================================
   Stars
   ========================================================== */
.stars { display: inline-flex; gap: 2px; color: var(--accent); }
.stars svg { width: 14px; height: 14px; }

/* ==========================================================
   Toast
   ========================================================== */
.toast-host {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: var(--r-pill);
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toast-in .3s var(--ease-out);
  display: inline-flex; align-items: center; gap: 10px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Footer
   ========================================================== */
.site-footer {
  background: var(--ink); color: var(--bg-2);
  padding: 80px 0 40px;
  margin-top: 120px;
}
.site-footer .footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 40px;
  max-width: 1440px; margin: 0 auto; padding: 0 28px;
}
.site-footer h4 {
  font-family: var(--font-sans); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: color-mix(in srgb, var(--bg) 60%, transparent);
  font-weight: 600; margin: 0 0 16px;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.site-footer a { color: color-mix(in srgb, var(--bg) 85%, transparent); font-size: 14px; }
.site-footer a:hover { color: var(--bg); }
.site-footer .brand { color: var(--bg); }
.site-footer .brand-mark { background: radial-gradient(circle at 35% 35%, #FFE7A0 0%, #E48A4F 55%, #8A3617 100%); }
.site-footer .bottom {
  max-width: 1440px; margin: 64px auto 0; padding: 24px 28px 0;
  border-top: 1px solid color-mix(in srgb, var(--bg) 14%, transparent);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: color-mix(in srgb, var(--bg) 55%, transparent);
}

/* ==========================================================
   Utilities
   ========================================================== */
.grow { flex: 1; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

@media (max-width: 900px) {
  .site-footer .footer-grid { grid-template-columns: 1fr 1fr; }
  .nav-secondary { display: none; }
}
