/* ═══════════════════════════════════════════════════════
   Éditions Ousia — NYT-inspired contemporary design
   Clean typography, generous whitespace, smooth transitions
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Custom Properties ──────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette — warm neutral with ink accents */
  --ink:            #121212;
  --ink-80:         #333333;
  --ink-60:         #555555;
  --ink-40:         #888888;
  --ink-20:         #bbbbbb;
  --ink-10:         #e0e0e0;
  --ink-05:         #f0efed;
  --paper:          #faf9f7;
  --surface:        #ffffff;
  --accent:         #567;
  --accent-hover:   #345;
  --rule:           #c8c5bf;
  --rule-light:     #e8e6e2;

  /* Typography — editorial stack */
  --f-display:      'Playfair Display', Georgia, 'Times New Roman', serif;
  --f-serif:        Georgia, 'Noto Serif', 'Times New Roman', serif;
  --f-sans:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --f-mono:         'JetBrains Mono', 'SF Mono', monospace;

  /* Spacing scale */
  --s-xs:   0.25rem;
  --s-sm:   0.5rem;
  --s-md:   1rem;
  --s-lg:   1.5rem;
  --s-xl:   2.5rem;
  --s-2xl:  4rem;
  --s-3xl:  6rem;

  /* Layout */
  --max-w:        1200px;
  --max-w-text:   680px;
  --gutter:       clamp(1rem, 4vw, 2.5rem);
  --grid-gap:     1.5rem;

  /* Motion */
  --ease:         cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur:          0.3s;
}

/* ── Base ────────────────────────────────────────────── */
html {
  font-size: clamp(16px, 1vw + 14px, 18px);
  scroll-behavior: smooth;
}

body {
  font-family: var(--f-serif);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(86, 103, 119, 0.15); }

a {
  color: var(--ink);
  text-decoration: none;
  text-underline-offset: 0.15em;
  transition: color var(--dur) var(--ease);
}

a:hover { color: var(--accent); }

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

/* ── Typography ──────────────────────────────────────── */
h1, h2, h3 { line-height: 1.2; font-weight: 400; }

h1 {
  font-family: var(--f-display);
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.02em;
  margin-bottom: var(--s-lg);
}

h2 {
  font-family: var(--f-display);
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  letter-spacing: -0.01em;
  margin-bottom: var(--s-md);
}

h3 {
  font-family: var(--f-serif);
  font-size: 1rem;
  font-weight: 600;
}

p { margin-bottom: 1em; }

/* ── Layout ──────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.container--narrow {
  max-width: var(--max-w-text);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main.container {
  padding-top: var(--s-2xl);
  padding-bottom: var(--s-3xl);
}

/* ── Header ──────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 247, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule-light);
  transition: box-shadow var(--dur) var(--ease);
}

.site-header--scrolled {
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.site-logo {
  font-family: var(--f-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.site-logo:hover { color: var(--ink); text-decoration: none; }

.site-nav ul {
  list-style: none;
  display: flex;
  gap: var(--s-lg);
}

.site-nav a {
  font-family: var(--f-sans);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-40);
  padding: 0.25rem 0;
  position: relative;
  transition: color var(--dur) var(--ease);
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--ink);
  transition: width var(--dur) var(--ease);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--ink);
  text-decoration: none;
}

.site-nav a:hover::after,
.site-nav a.active::after {
  width: 100%;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--ink);
}

.nav-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: var(--s-3xl) var(--gutter) var(--s-2xl);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-2xl);
}

.hero h1 {
  font-family: var(--f-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--s-sm);
}

.hero-tagline {
  font-family: var(--f-sans);
  font-size: 0.95rem;
  color: var(--ink-40);
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ── Section ──────────────────────────────────────────── */
.section {
  margin-bottom: var(--s-2xl);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: var(--s-sm);
  margin-bottom: var(--s-lg);
}

.section-header h2 {
  margin-bottom: 0;
  font-weight: 700;
}

.section-more {
  font-family: var(--f-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-40);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.section-more:hover {
  color: var(--ink);
}

/* ── Book Grid ───────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--grid-gap);
  margin-bottom: var(--s-lg);
}

.book-card a {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  padding: 0;
  height: 100%;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.book-card a:hover {
  text-decoration: none;
  transform: translateY(-3px);
}

.book-card.out-of-print a { opacity: 0.55; }
.book-card.out-of-print a:hover { opacity: 0.75; }

.book-cover {
  width: 100%;
  aspect-ratio: 5/7;
  object-fit: cover;
  margin-bottom: var(--s-md);
  background: var(--ink-05);
  border: 1px solid var(--rule-light);
  transition: box-shadow var(--dur) var(--ease);
}

.book-card a:hover .book-cover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.book-cover.placeholder {
  background: linear-gradient(160deg, var(--ink-05) 0%, #e5e2dc 100%);
}

.book-title {
  font-family: var(--f-serif);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.book-subtitle {
  font-family: var(--f-serif);
  font-size: 0.85rem;
  color: var(--ink-60);
  font-style: italic;
  line-height: 1.4;
  margin-bottom: 0.2rem;
}

.book-authors {
  font-family: var(--f-sans);
  font-size: 0.78rem;
  color: var(--ink-40);
  margin-bottom: 0.2rem;
}

.book-year {
  font-family: var(--f-sans);
  font-size: 0.72rem;
  color: var(--ink-20);
  letter-spacing: 0.02em;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: var(--f-sans);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2em 0.6em;
  border-radius: 2px;
  margin-top: var(--s-xs);
}

.badge-outofprint {
  background: var(--ink-10);
  color: var(--ink-60);
}

/* ── Book Detail ─────────────────────────────────────── */
.book-detail { max-width: 960px; }

.book-detail-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--s-2xl);
  margin-bottom: var(--s-2xl);
}

.book-detail-cover img,
.book-detail-cover .placeholder.large {
  width: 100%;
  aspect-ratio: 5/7;
  object-fit: cover;
  background: linear-gradient(160deg, var(--ink-05) 0%, #e5e2dc 100%);
  border: 1px solid var(--rule-light);
}

.book-detail-info h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  margin-bottom: var(--s-sm);
}

.book-detail-info .book-subtitle {
  font-size: 1.15rem;
  margin-bottom: var(--s-lg);
}

.book-meta {
  margin: var(--s-lg) 0;
  border-top: 1px solid var(--rule-light);
  border-bottom: 1px solid var(--rule-light);
  padding: var(--s-md) 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 2rem;
  align-items: baseline;
}

.book-meta dt {
  font-family: var(--f-sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-40);
}

.book-meta dd {
  margin: 0;
  font-size: 0.95rem;
}

.book-meta dd a {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}

.book-meta dd a:hover {
  text-decoration-color: var(--ink);
}

.book-description {
  max-width: var(--max-w-text);
  border-top: 2px solid var(--ink);
  padding-top: var(--s-lg);
}

.book-description h2 {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: var(--s-md);
}

/* ── Prose / KirbyText content ────────────────────── */
.book-description p,
.author-bio p,
.default-text p {
  margin-bottom: 1em;
  line-height: 1.75;
}

.book-description p:last-child,
.author-bio p:last-child,
.default-text p:last-child {
  margin-bottom: 0;
}

.book-description ul,
.book-description ol,
.author-bio ul,
.author-bio ol,
.default-text ul,
.default-text ol {
  margin: 1em 0;
  padding-left: 1.5em;
  line-height: 1.75;
}

.book-description li,
.author-bio li,
.default-text li {
  margin-bottom: 0.4em;
}

.book-description ul { list-style-type: disc; }
.book-description ol { list-style-type: decimal; }

.book-description blockquote,
.author-bio blockquote,
.default-text blockquote {
  border-left: 3px solid var(--rule);
  padding-left: var(--s-lg);
  margin: 1.5em 0;
  font-style: italic;
  color: var(--ink-60);
}

.book-description h3,
.default-text h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5em 0 0.5em;
}

.book-description strong,
.default-text strong {
  font-weight: 700;
}

.book-description em,
.default-text em {
  font-style: italic;
}

/* ── Button ──────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--f-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.75rem 2rem;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: all var(--dur) var(--ease);
}

.btn-order {
  background: var(--ink);
  color: var(--paper);
}

.btn-order:hover {
  background: var(--ink-80);
  color: var(--paper);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* ── Author & Collection Grids ───────────────────────── */
.author-grid,
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--rule-light);
  border: 1px solid var(--rule-light);
  margin-bottom: var(--s-lg);
}

.author-card,
.collection-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--s-md) var(--s-lg);
  background: var(--surface);
  color: var(--ink);
  min-height: 4rem;
  transition: background var(--dur) var(--ease);
}

.author-card:hover,
.collection-card:hover {
  text-decoration: none;
  background: var(--ink-05);
}

.author-card strong,
.collection-card strong {
  font-family: var(--f-sans);
  font-size: 0.9rem;
  font-weight: 600;
}

.author-card .count,
.collection-card .count {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  color: var(--ink-40);
  margin-top: 0.15rem;
}

.collection-card p {
  font-size: 0.82rem;
  color: var(--ink-60);
  margin: 0.3rem 0 0;
  line-height: 1.5;
}

/* ── Collection List (home) ──────────────────────────── */
.collection-list {
  list-style: none;
  border-top: 1px solid var(--rule-light);
}

.collection-list li {
  border-bottom: 1px solid var(--rule-light);
}

.collection-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0;
  transition: padding-left var(--dur) var(--ease);
}

.collection-list a:hover {
  padding-left: 0.5rem;
  text-decoration: none;
}

.collection-list strong {
  font-family: var(--f-sans);
  font-size: 0.9rem;
  font-weight: 500;
}

.collection-list .count {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  color: var(--ink-40);
  flex-shrink: 0;
  margin-left: var(--s-md);
}

/* ── Search ──────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: 0;
  margin-bottom: var(--s-lg);
  max-width: 480px;
  border: 1px solid var(--rule);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}

.search-form:focus-within {
  border-color: var(--ink-40);
}

.search-form input[type="search"] {
  flex: 1;
  font-family: var(--f-sans);
  font-size: 0.9rem;
  padding: 0.65rem var(--s-md);
  border: none;
  background: var(--surface);
  outline: none;
}

.search-form input[type="search"]::placeholder {
  color: var(--ink-20);
}

.search-form button {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.65rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.search-form button:hover { background: var(--ink-80); }

.result-count {
  font-family: var(--f-sans);
  font-size: 0.8rem;
  color: var(--ink-40);
  margin-bottom: var(--s-lg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xl);
  font-family: var(--f-sans);
  font-size: 0.85rem;
  margin-top: var(--s-xl);
  padding-top: var(--s-lg);
  border-top: 1px solid var(--rule-light);
}

.pagination a {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}

.pagination a:hover {
  text-decoration-color: var(--ink);
}

.pagination span {
  color: var(--ink-40);
  font-size: 0.8rem;
}

/* ── Page titles ─────────────────────────────────────── */
.page-title {
  border-bottom: 2px solid var(--ink);
  padding-bottom: var(--s-sm);
  margin-bottom: var(--s-xl);
}

/* ── Text (static pages) ─────────────────────────────── */
.text {
  max-width: var(--max-w-text);
  font-size: 1.05rem;
}

.text p {
  margin-bottom: 1.2em;
}

/* ── Author Bio ──────────────────────────────────────── */
.author-bio {
  max-width: var(--max-w-text);
  margin-bottom: var(--s-xl);
  font-size: 1.05rem;
  color: var(--ink-60);
  border-left: 3px solid var(--rule);
  padding-left: var(--s-lg);
}

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--s-xl) 0;
  margin-top: var(--s-3xl);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s-md);
}

.site-footer p {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  color: var(--ink-40);
  margin: 0;
}

.site-footer a {
  color: var(--ink-40);
  text-decoration: underline;
  text-decoration-color: var(--rule);
}

.site-footer a:hover { color: var(--ink-60); }

/* ── Turbo transitions ───────────────────────────────── */
.turbo-progress-bar {
  height: 2px;
  background: var(--ink);
}

/* Page transition — keep padding from main rule above */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Collection detail columns ───────────────────────── */
.collection-list--two-col {
  columns: 2;
  column-gap: var(--s-2xl);
}
.collection-list--two-col li {
  break-inside: avoid;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { padding: var(--s-2xl) var(--gutter) var(--s-xl); }
  .hero h1 { font-size: clamp(1.8rem, 8vw, 2.5rem); }

  .book-detail-grid {
    grid-template-columns: 1fr;
    gap: var(--s-lg);
  }
  .book-detail-cover { max-width: 220px; }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--s-md);
  }

  .collection-list--two-col { columns: 1; }

  .site-header .container {
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    flex-wrap: wrap;
  }

  .site-nav { display: none; width: 100%; }
  .site-nav.open { display: block; }
  .site-nav ul {
    flex-direction: column;
    gap: 0;
  }
  .site-nav li {
    border-top: 1px solid var(--rule-light);
  }
  .site-nav a {
    display: block;
    padding: 0.6rem 0;
  }
  .site-nav a::after { display: none; }
  .nav-toggle { display: block; }

  .site-footer .container {
    flex-direction: column;
    text-align: center;
  }

  .section-header {
    flex-direction: column;
    gap: var(--s-sm);
  }

  .author-grid, .collection-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .nav-toggle { display: none; }
}
