/* Mobile-first: base styles target phones; min-width queries add layout for larger screens. */

:root {
  --bg: #ffffff;
  --surface: #f6f5f2;
  --ink: #1a1a1a;
  --ink-soft: #5f5f5f;
  --line: #e4e2dd;
  --accent: #1f4d3f;
  --accent-ink: #ffffff;
  --radius: 6px;
  --max: 1140px;
  --gutter: 16px;
  --font: "Libre Franklin", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --surface: #1e1e1e;
    --ink: #f2f2f0;
    --ink-soft: #a8a8a4;
    --line: #2e2e2c;
    --accent: #7fc4a8;
    --accent-ink: #10221b;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 0.95rem; }

.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

/* Header: logo row, nav row underneath on phones */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-direction: column; padding-top: 0.75rem; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.02em; padding: 0.25rem 0; }
.nav { display: flex; gap: 1.25rem; overflow-x: auto; }
.nav a {
  display: flex; align-items: center;
  min-height: 44px;
  text-decoration: none; color: var(--ink-soft); font-size: 0.95rem; white-space: nowrap;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

/* Buttons: 44px touch target */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  text-align: center;
}
.btn:hover { filter: brightness(1.12); }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* Intro & page heads */
.intro, .page-head { padding-top: 2rem; padding-bottom: 0.5rem; }
.intro p, .page-head p { color: var(--ink-soft); max-width: 52ch; margin: 0 0 1rem; font-size: 1.05rem; }

section { padding: 1.5rem 0 2.5rem; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem; margin-bottom: 1.25rem;
}
.section-head h2 { margin: 0; }
.section-head a { color: var(--ink-soft); font-size: 0.95rem; }

/* Book grid: 2 columns on phones */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 0.875rem;
}

.book-card { display: flex; flex-direction: column; gap: 0.25rem; }
.book-card .cover {
  aspect-ratio: 8.5 / 11;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  display: grid; place-items: center;
  color: var(--ink-soft); font-size: 0.85rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-decoration: none;
}
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card h3 { margin: 0; }
.book-card h3 a { text-decoration: none; }
.book-card h3 a:hover { text-decoration: underline; }
.book-card .meta { color: var(--ink-soft); font-size: 0.8rem; margin: 0; }
.book-card .price { font-weight: 600; margin: 0 0 0.5rem; }
.book-card .btn { margin-top: auto; width: 100%; font-size: 0.9rem; padding: 0.6rem 0.5rem; }

/* Book detail: stacked on phones */
.crumbs { font-size: 0.875rem; color: var(--ink-soft); padding-top: 1rem; margin: 0; }
.book-detail { display: grid; gap: 1.5rem; padding: 1rem 0 2.5rem; }
.book-detail .cover {
  aspect-ratio: 8.5 / 11;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--ink-soft);
}
.book-detail .price { font-size: 1.3rem; font-weight: 600; margin: 0.25rem 0 1rem; }
.book-detail .btn { width: 100%; }
.specs { list-style: none; padding: 0; margin: 1.5rem 0; border-top: 1px solid var(--line); }
.specs li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--line); font-size: 0.95rem;
}
.specs li span:first-child { color: var(--ink-soft); }
.specs li span:last-child { text-align: right; }

/* Notice strip */
.strip {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1rem;
}
.strip p { margin: 0; }

.prose { max-width: 66ch; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--ink-soft); font-size: 0.875rem; }
.site-footer .wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.site-footer a { text-decoration: none; display: inline-block; padding: 0.4rem 0; }
.site-footer a:hover { color: var(--ink); }

/* Large phones / small tablets */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1rem; }

  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 1.25rem; }
  .book-card .meta { font-size: 0.875rem; }
  .book-card .btn { width: auto; align-self: start; padding: 0.6rem 1rem; font-size: 0.95rem; }

  .strip { flex-direction: row; justify-content: space-between; align-items: center; padding: 1.5rem; }
  .book-detail .btn { width: auto; }

  /* 3 columns here, so drop the 4th release to avoid an orphan row */
  .releases .book-card:nth-child(4) { display: none; }
}

/* Tablets and up */
@media (min-width: 900px) {
  :root { --gutter: 32px; }
  h1 { font-size: 2.5rem; }
  h2 { font-size: 1.35rem; }

  .site-header .wrap {
    flex-direction: row; align-items: center; justify-content: space-between;
    min-height: 64px; padding-top: 0;
  }
  .nav { gap: 1.5rem; overflow: visible; }

  .intro, .page-head { padding-top: 3rem; }

  .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2.25rem 1.5rem; }
  .releases .book-card:nth-child(4) { display: flex; }

  .book-detail { grid-template-columns: minmax(0, 380px) 1fr; gap: 3rem; padding: 2rem 0 3.5rem; align-items: start; }
  .book-detail .cover { max-width: none; margin: 0; }

  .site-footer .wrap { flex-direction: row; justify-content: space-between; align-items: center; }
}
