/* ============================================================
   The Cozy Grimoire — main.css
   All colors via CSS custom properties — theme-agnostic
   ============================================================ */

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

html {
  font-size: 18px; /* Generous base for older readers */
  scroll-behavior: smooth;
}

body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  background-color: var(--s1);
  color: var(--t1);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Screen-reader only */
.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;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: 'Cinzel', serif;
  font-weight: 400;
  line-height: 1.25;
  color: var(--t1);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

a { color: var(--ac); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--ac); outline-offset: 3px; border-radius: 2px; }

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

/* --- Layout wrappers --- */
.site-wrap { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
main { flex: 1; }

/* --- Navigation --- */
.site-header {
  background: var(--s2);
  border-bottom: 1px solid var(--bo);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--ac);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.nav-logo:hover { text-decoration: none; opacity: 0.85; }

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.25rem;
  flex: 1;
}
.nav-links a {
  font-size: 0.85rem;
  color: var(--t2);
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--ac); text-decoration: none; }

.nav-auth {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--t2);
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
  min-width: 48px;
  min-height: 48px;
}

/* --- Buttons --- */
.btn-primary, .btn-secondary, .btn-ghost, .btn-amazon, .btn-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 1.1rem;
  border-radius: 24px;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  border: 1.5px solid transparent;
}

.btn-primary {
  background: var(--sb);
  color: var(--sbc);
  border-color: var(--sbo);
}
.btn-primary:hover { filter: brightness(1.1); text-decoration: none; color: var(--sbc); }

.btn-secondary {
  background: transparent;
  color: var(--t2);
  border-color: var(--bo);
}
.btn-secondary:hover { border-color: var(--ac); color: var(--ac); text-decoration: none; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--t2);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
}
.btn-ghost:hover { color: var(--ac); text-decoration: underline; }

.btn-amazon {
  background: transparent;
  border-color: var(--bo);
  color: var(--t2);
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  font-style: italic;
  padding: 0.4rem 0.9rem;
}
.btn-amazon:hover { border-color: var(--ac); color: var(--ac); text-decoration: none; }

.btn-search {
  background: var(--sb);
  color: var(--sbc);
  border-color: var(--sbo);
  border-radius: 0;
  border-left-color: var(--sbo);
  font-size: 0.82rem;
  padding: 0 1.25rem;
  min-height: 52px;
}
.btn-search:hover { filter: brightness(1.1); }

.btn-large { padding: 0.75rem 2rem; font-size: 0.9rem; }

/* Reading list button */
.rl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--bo);
  background: var(--s2);
  color: var(--t2);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.rl-btn:hover { border-color: var(--ac); color: var(--ac); text-decoration: none; }
.rl-btn.rl-read { color: var(--ac); border-color: var(--ac); }
.rl-btn.rl-reading { color: var(--a2); border-color: var(--a2); }

/* --- Hero --- */
.hero {
  background: var(--s1);
  border-bottom: 1px solid var(--bo);
  padding: 3.5rem 1.25rem 2.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-inner {
  max-width: 620px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 0.6rem;
  font-family: 'Cormorant Garamond', serif;
}

.hero-title {
  font-size: 2.4rem;
  color: var(--ac);
  margin-bottom: 0.6rem;
}

.hero-sub {
  font-size: 1rem;
  color: var(--t2);
  font-style: italic;
  margin-bottom: 1.5rem;
  max-width: 480px;
}

.hero-search {
  display: flex;
  width: 100%;
  max-width: 500px;
  border: 2px solid var(--bo);
  border-radius: 10px;
  overflow: hidden;
  background: var(--s2);
  margin-bottom: 1rem;
}

.search-input {
  flex: 1;
  padding: 0.8rem 1rem;
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--t1);
  outline: none;
  min-width: 0;
  font-family: 'Cormorant Garamond', serif;
}
.search-input::placeholder { color: var(--t3); font-style: italic; }

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

/* --- Tags / pills --- */
.tag-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  background: var(--tb);
  color: var(--tc);
  border: 1px solid var(--tbo);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  text-decoration: none;
}
.tag-pill:hover { border-color: var(--ac); color: var(--ac); text-decoration: none; }
.tag-sm { font-size: 0.72rem; padding: 0.15rem 0.6rem; }

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
}
.badge-ku    { background: var(--bd); color: var(--bc); }
.badge-staff { background: var(--a2); color: #fff; }

/* --- Ads --- */
.ad-unit { padding: 0.5rem 1.25rem; background: var(--s2); border-bottom: 1px solid var(--bo); }
.ad-label {
  font-size: 0.6rem;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
  margin-bottom: 0.2rem;
  font-family: 'Cormorant Garamond', serif;
}
.ad-leaderboard { display: flex; flex-direction: column; align-items: center; }
.ad-mid-mobile  { display: none; }

/* --- Content sections --- */
.content-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  border-bottom: 1px solid var(--bo);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title { font-size: 1rem; letter-spacing: 0.06em; color: var(--t1); }
.section-more  { font-size: 0.85rem; color: var(--ac); font-style: italic; }

/* --- Book grid --- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.book-card {
  background: var(--s2);
  border: 1px solid var(--bo);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.book-card:hover { border-color: var(--ac); }

.book-cover {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--s1);
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--s2), var(--bo));
}
.book-cover .badge { position: absolute; top: 0.4rem; left: 0.4rem; }
.book-cover .badge + .badge { top: 1.8rem; }

.book-info { padding: 0.875rem; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.book-title a { color: var(--t1); font-size: 0.95rem; font-weight: 500; }
.book-title a:hover { color: var(--ac); text-decoration: none; }
.book-author { font-size: 0.82rem; color: var(--t2); font-style: italic; }
.book-author a { color: var(--t2); }
.book-author a:hover { color: var(--ac); }
.book-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.2rem 0; }
.staff-note { font-size: 0.78rem; color: var(--t2); font-style: italic; line-height: 1.5; }
.book-meta  { font-size: 0.72rem; color: var(--t3); }
.meta-item  { display: block; }

.book-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

/* --- Gate section --- */
.gate-section {
  background: var(--s2);
  border-top: 1px solid var(--bo);
  padding: 3rem 1.25rem;
  text-align: center;
}
.gate-inner { max-width: 480px; margin: 0 auto; }
.gate-title { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--t1); }
.gate-sub   { font-size: 1rem; color: var(--t2); font-style: italic; margin-bottom: 1.25rem; line-height: 1.7; }
.gate-actions { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }

/* --- Sidebar layout (for inner pages) --- */
.page-with-sidebar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 2rem;
  align-items: start;
}

.sidebar-ad {
  position: sticky;
  top: 80px;
}

/* --- Footer --- */
.site-footer {
  background: var(--s2);
  border-top: 1px solid var(--bo);
  margin-top: auto;
  padding: 1.25rem;
}
.footer-inner { max-width: 1100px; margin: 0 auto; }
.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.footer-logo { font-family: 'Cinzel', serif; font-size: 0.95rem; color: var(--ac); }
.site-footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-footer nav a { font-size: 0.78rem; color: var(--t3); font-style: italic; }
.site-footer nav a:hover { color: var(--ac); }
.footer-easter {
  font-size: 0.75rem;
  color: var(--t3);
  text-align: center;
  font-style: italic;
  border-top: 1px solid var(--bo);
  padding-top: 0.75rem;
  line-height: 1.8;
}
.footer-easter a { color: var(--ac); }

/* --- Pagination --- */
.pagination ul { display: flex; gap: 0.4rem; list-style: none; justify-content: center; padding: 1.5rem 0; flex-wrap: wrap; }
.pagination a  { display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; border-radius: 8px;
  border: 1px solid var(--bo); color: var(--t2); font-size: 0.9rem;
  transition: border-color 0.15s; text-decoration: none; }
.pagination a:hover { border-color: var(--ac); color: var(--ac); }
.pagination .active a { background: var(--sb); color: var(--sbc); border-color: var(--sbo); }

/* ============================================================
   RESPONSIVE — mobile first adjustments
   ============================================================ */
@media (max-width: 768px) {
  html { font-size: 17px; }

  /* Nav: hide links, show hamburger */
  .nav-links   { display: none; flex-direction: column; position: absolute;
    top: 60px; left: 0; right: 0; background: var(--s2);
    border-bottom: 1px solid var(--bo); padding: 1rem 1.25rem; gap: 0.75rem; z-index: 99; }
  .nav-links.open { display: flex; }
  .nav-hamburger { display: flex; }
  .nav-auth { display: none; }
  .nav-auth.open { display: flex; flex-direction: column; }

  /* Hero */
  .hero { padding: 2rem 1rem 1.5rem; }
  .hero-title { font-size: 1.8rem; }

  /* Book grid: 2 col */
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }

  /* Page with sidebar: single column */
  .page-with-sidebar { grid-template-columns: 1fr; }
  .sidebar-ad { position: static; }

  /* Show mid-page mobile ad */
  .ad-mid-mobile { display: flex; flex-direction: column; align-items: center; }

  /* Gate: full-width button */
  .gate-actions .btn-primary { width: 100%; max-width: 320px; }

  /* Footer: stack */
  .footer-top { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  html { font-size: 16px; }
  .book-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .hero-title { font-size: 1.6rem; }
}
