/* =========================================================
   GLOBAL VARIABLES
   ========================================================= */
:root {
  --bg-main: #f7f5f1;
  --bg-panel: #ffffff;
  --border: #e6e1d9;
  --accent: #8a6d3b;
  --text-main: #18202a;
  --shadow-soft: 0 8px 30px rgba(40,30,20,.05);
  --radius-card: 18px;
  --radius-small: 10px;
  --radius-medium: 12px;
  --radius-large: 14px;
  --font-serif: Georgia, serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* =========================================================
   BASE ELEMENTS
   ========================================================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

/* =========================================================
   SITE HEADER (Public Library)
   ========================================================= */
.site-header {
  height: 76px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-medium);
  background: var(--text-main);
  color: white;
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  display: block;
}

.brand small {
  display: block;
  color: #777;
  font-size: 12px;
}

.admin-link {
  font-size: 14px;
  color: #666;
}

/* =========================================================
   HERO & SHELL WRAPPERS
   ========================================================= */
.library-shell,
.series-main,
.author-main,
.book-main {
  max-width: 1240px;
  margin: auto;
  padding: 40px 24px;
  width: 100%;
}

.hero {
  max-width: 900px;
  margin: 0 auto 50px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: .18em;
  font-weight: 800;
  color: var(--accent);
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(44px, 7vw, 78px);
  line-height: .95;
  margin: 12px 0;
}

.hero p:not(.eyebrow) {
  font-size: 19px;
  color: #68717a;
}

/* =========================================================
   PAGE HEADINGS / TITLES
   ========================================================= */
.page-title-section {
  text-align: center;
  margin-bottom: 35px;
  width: 100%;
}

.page-title-section h1 {
  font-family: var(--font-serif);
  font-size: clamp(32px, 5vw, 54px);
  margin: 0 0 8px 0;
  line-height: 1.1;
}

.book-subtitle {
  font-size: 16px;
  color: var(--accent);
  margin: 0;
}

/* =========================================================
   UNIFIED GRID LAYOUT SYSTEM
   ========================================================= */
.book-grid, 
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 32px;
  width: 100%;
}

.book-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-width: 0; /* Keeps grids dimensionally stable in Chrome */
}

.cover-wrap {
  aspect-ratio: 3/4;
  background: #e9e5de;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.cover-wrap img,
.book-cover {
  width: 100%;
  height: 100%;
  min-height: 0; /* Blocks flex alignment collapse issues */
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  height: 100%;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 18px;
  background: #f4f2ee;
  color: #777;
}

.book-info {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.book-meta {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 4px;
}

.book-info h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin: 4px 0 8px 0;
  line-height: 1.2;
}

.author {
  font-weight: 650;
  font-size: 14px;
  color: #555;
  margin: 0 0 15px 0;
}

.author a { display: inline; }
.author a:hover { text-decoration: underline; color: var(--accent); }

.details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #777;
  font-size: 12px;
  margin: 18px 0;
}

.details span {
  padding: 6px 8px;
  background: #f4f2ee;
  border-radius: 7px;
}

.card-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: auto;
}

/* =========================================================
   UI BUTTONS & UTILITIES
   ========================================================= */
.button {
  display: inline-block;
  border: 0;
  border-radius: 9px;
  padding: 11px 15px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}

.primary {
  background: var(--text-main);
  color: #fff;
}

.book-btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-weight: bold;
  margin-right: 8px;
  margin-bottom: 8px;
}

.small {
  padding: 8px 11px;
  font-size: 12px;
  width: 100%;
}

/* =========================================================
   SPLIT SHOWCASE FEATURE SECTIONS
   ========================================================= */
.series-info-section,
.author-bio-section,
.book-info-section {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 3rem;
  width: 100%;
}

.series-description,
.author-bio,
.book-details-panel,
.book-description {
  flex: 1 1 400px;
  background: var(--bg-panel);
  padding: 2rem;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.series-description h2,
.author-bio h2,
.book-details-panel h2,
.book-description h2 {
  font-family: var(--font-serif);
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--accent);
}

.series-image,
.author-portrait,
.book-cover-panel {
  flex: 0 1 300px;
  text-align: center;
  width: 100%;
}

.series-image img,
.author-portrait img,
.book-detail-cover {
  width: 100%;
  max-width: 280px;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius-medium);
  box-shadow: 0 8px 30px rgba(40,30,20,.1);
  display: block;
  margin: 0 auto;
}

.no-series-image, .no-cover {
  background: #f4f2ee;
  padding: 40px;
  border-radius: var(--radius-medium);
  color: #777;
  font-family: var(--font-serif);
  font-size: 18px;
  max-width: 280px;
  margin: 0 auto;
}

/* =========================================================
   ADMIN PANEL CONTROL CODES
   ========================================================= */
.admin-body {
  background: #f3f5f7;
  min-height: 100vh;
}

.admin-header {
  height: 76px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e7e2da;
}

.admin-shell {
  max-width: 1100px;
  margin: auto;
  padding: 42px 24px;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.page-heading h1 { margin: 0; }
.muted { color: #737b84; }

.stats {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}

.stat {
  background: #fff;
  border: 1px solid #e0e4e8;
  border-radius: var(--radius-large);
  padding: 20px;
  min-width: 140px;
}

.stat b { display: block; font-size: 30px; }
.stat span { color: #777; }

.book-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #eee;
  padding: 15px 0;
}

.pill {
  background: #eee;
  padding: 5px 8px;
  border-radius: 20px;
  font-size: 11px;
}

.site-footer {
  text-align: center;
  padding: 40px;
  color: #888;
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 50px;
}

/* =========================================================
   RESPONSIVE RULES
   ========================================================= */
@media (max-width: 700px) {
  .book-grid, .library-grid {
    grid-template-columns: 1fr;
  }
  .series-info-section,
  .author-bio-section,
  .book-info-section {
    flex-direction: column;
    align-items: center;
  }
  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
