/* Reading Sanctum — all styles scoped to .books-section */

.books-section {
  --bg-deep:    #0a0c10;
  --bg-mid:     #0f1318;
  --bg-card:    #131820;
  --bg-raised:  #1a2030;
  --bg-hover:   #1e2638;
  --gold:       #c9a84c;
  --gold-dim:   #8a6f30;
  --gold-glow:  rgba(201,168,76,0.18);
  --amber:      #e8b84b;
  --cream:      #f0e6cc;
  --text-main:  #d4c9b0;
  --text-muted: #6b7a8f;
  --text-dim:   #3d4a5c;
  --border:     rgba(201,168,76,0.15);
  --border-dim: rgba(255,255,255,0.05);
  --red-accent: #c0392b;
  --teal:       #2a9d8f;
  --radius:     6px;

  font-family: 'Crimson Pro', serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: calc(100vh - 48px);
  overflow-x: hidden;
  position: relative;
  /* Override grooming's animated body gradient */
  background-image: none !important;
  animation: none !important;
}

.books-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% 10%, rgba(201,168,76,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(42,157,143,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 80% 80% at 50% 50%, rgba(10,12,16,0) 0%, rgba(5,6,8,0.3) 100%);
  pointer-events: none;
  z-index: 0;
}

.books-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.books-section .layout-root {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ── HEADER ── */
.books-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  grid-column: unset;
  flex-wrap: nowrap;
  gap: 0;
}

.books-section .logo-group { display: flex; flex-direction: column; }

.books-section .logo-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  line-height: 1;
}

.books-section .logo-sub {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-top: 3px;
}

.books-section .header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.books-section .header-day {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
}

.books-section .header-dayofyear {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* ── GRID ── */
.books-section .main-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.books-section .sidebar { display: flex; flex-direction: column; gap: 20px; }
.books-section .content-col { display: flex; flex-direction: column; gap: 20px; }

/* ── CARD ── */
.books-section .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
  padding: 0;
  animation: fadeUpBooks 0.5s ease both;
}

.books-section .card:hover { border-color: rgba(201,168,76,0.28); }

.books-section .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-dim);
}

.books-section .card-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.books-section .card-body { padding: 18px; }

/* ── STATS ROW ── */
.books-section .stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.books-section .stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  animation: fadeUpBooks 0.5s ease both;
}

.books-section .stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold), var(--gold-dim));
  opacity: 0.6;
}

.books-section .stat-card:hover { background: var(--bg-raised); border-color: var(--gold-dim); }

.books-section .stat-icon { font-size: 0.85rem; color: var(--gold-dim); }

.books-section .stat-val {
  font-family: 'Playfair Display', serif;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.books-section .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── FORM ── */
.books-section .entry-form { display: flex; flex-direction: column; gap: 14px; }
.books-section .form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.books-section .form-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 130px; }

.books-section .form-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.books-section input[type="text"],
.books-section input[type="number"],
.books-section input[type="date"],
.books-section select {
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 9px 12px;
  color: var(--text-main);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  width: 100%;
  outline: none;
  transition: all 0.2s;
  color-scheme: dark;
  appearance: auto;
  -webkit-appearance: auto;
}

.books-section input:focus,
.books-section select:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.books-section input::placeholder { color: var(--text-dim); }

.books-section .btn-primary {
  background: linear-gradient(135deg, #b8922a, var(--gold));
  border: none;
  border-radius: 4px;
  color: #0a0c10;
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.books-section .btn-primary:hover {
  background: linear-gradient(135deg, var(--gold), var(--amber));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,168,76,0.25);
}

/* ── CHART ── */
.books-section #chartCanvas {
  width: 100%;
  height: 200px;
  display: block;
}

/* ── CALENDAR ── */
.books-section .cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  cursor: default;
  color: inherit;
}

.books-section .cal-nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
  font-size: 0.75rem;
}

.books-section .cal-nav-btn:hover { color: var(--gold); }

.books-section .cal-month {
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cream);
}

.books-section .cal-dow-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin: 10px 0 4px;
}

.books-section .cal-dow {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 2px 0;
  letter-spacing: 0;
}

.books-section .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.books-section .cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: default;
  background: transparent;
  border: 1px solid transparent;
  flex-direction: row;
  gap: 0;
}

.books-section .cal-cell:hover { background: rgba(201,168,76,0.08); }

.books-section .cal-cell.has-event {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  font-weight: 700;
  border: 1px solid rgba(201,168,76,0.3);
}

.books-section .cal-cell.today {
  background: var(--gold);
  color: #0a0c10;
  font-weight: 700;
  border-color: var(--gold);
}

/* ── RECENT LIST ── */
.books-section .event-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-dim);
  transition: background 0.15s;
}

.books-section .event-item:last-child { border-bottom: none; }
.books-section .event-item:hover { background: var(--bg-raised); }

.books-section .book-spine {
  width: 36px;
  height: 52px;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
}

.books-section .spine-1 { background: linear-gradient(160deg, #2c3e5e, #1a2540); }
.books-section .spine-2 { background: linear-gradient(160deg, #3d2c1e, #261a10); }
.books-section .spine-3 { background: linear-gradient(160deg, #1e3d2c, #102618); }
.books-section .spine-4 { background: linear-gradient(160deg, #3d1e2c, #261018); }
.books-section .spine-5 { background: linear-gradient(160deg, #2c3d1e, #182610); }

.books-section .book-spine::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255,255,255,0.08);
}

.books-section .event-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-style: italic;
  color: var(--cream);
  line-height: 1.2;
}

.books-section .event-stats {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.books-section .event-stat-pill {
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: 20px;
  padding: 1px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.books-section .event-stat-pill span { color: var(--gold); font-weight: 700; }

.books-section .event-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-top: 5px;
  flex: unset;
}

/* ── PACE METER ── */
.books-section .pace-arc-container {
  display: flex;
  justify-content: center;
  position: relative;
  margin: 8px 0;
}

.books-section .pace-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 4px;
}

.books-section .pace-legend span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* ── HEATMAP ── */
.books-section .heatmap-grid {
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  gap: 2px;
  margin-top: 6px;
}

.books-section .hm-cell {
  aspect-ratio: 1;
  border-radius: 1px;
  background: var(--bg-raised);
  transition: transform 0.1s;
}

.books-section .hm-cell:hover { transform: scale(1.4); cursor: default; }

.books-section .hm-0 { background: rgba(201,168,76,0.05); }
.books-section .hm-1 { background: rgba(201,168,76,0.2); }
.books-section .hm-2 { background: rgba(201,168,76,0.4); }
.books-section .hm-3 { background: rgba(201,168,76,0.65); }
.books-section .hm-4 { background: rgba(201,168,76,0.9); }

.books-section .heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 6px;
}

.books-section .hm-legend-cell { width: 10px; height: 10px; border-radius: 1px; }
.books-section .hm-legend-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* ── TOP BOOKS ── */
.books-section .top-book-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-dim);
}

.books-section .top-book-row:last-child { border-bottom: none; }

.books-section .top-book-rank {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--gold-dim);
  width: 22px;
  flex-shrink: 0;
  text-align: center;
}

.books-section .top-book-name {
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  color: var(--text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.books-section .top-book-pages {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── GOAL PROGRESS ── */
.books-section .goal-track { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.books-section .goal-row { display: flex; flex-direction: column; gap: 5px; }

.books-section .goal-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.books-section .goal-row-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Crimson Pro', serif;
}

.books-section .goal-row-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--gold);
}

.books-section .goal-bar-bg {
  height: 5px;
  background: var(--bg-raised);
  border-radius: 10px;
  overflow: hidden;
}

.books-section .goal-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

/* ── DATA MANAGEMENT ── */
.books-section .data-mgmt { display: flex; flex-direction: column; gap: 8px; }

.books-section .data-btn {
  background: none;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: 'Crimson Pro', serif;
  font-size: 0.9rem;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.books-section .data-btn:hover { background: var(--bg-raised); color: var(--gold); border-color: var(--gold-dim); }
.books-section .data-btn.danger:hover { color: #e74c3c; border-color: rgba(231,76,60,0.3); background: rgba(231,76,60,0.05); }
.books-section .data-btn i { width: 14px; text-align: center; }

/* ── TOAST ── */
#booksToast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #1a2030;
  border: 1px solid #8a6f30;
  border-radius: 6px;
  padding: 12px 20px;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  color: #c9a84c;
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s;
  pointer-events: none;
}

#booksToast.show { opacity: 1; transform: translateY(0); }

/* ── MEDIA QUERIES ── */
@media (max-width: 900px) {
  .books-section .main-grid { grid-template-columns: 1fr; }
  .books-section .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .books-section .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ── ANIMATIONS ── */
@keyframes fadeUpBooks {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.books-section .stat-card:nth-child(1) { animation-delay: 0.05s; }
.books-section .stat-card:nth-child(2) { animation-delay: 0.1s; }
.books-section .stat-card:nth-child(3) { animation-delay: 0.15s; }
.books-section .stat-card:nth-child(4) { animation-delay: 0.2s; }
