/* ============================================
   Jewish Mythology — The Living Library
   Editorial, magazine-quality design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Crimson+Pro:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
  /* Warm, refined palette */
  --bg: #FDFBF7;
  --bg-warm: #F7F3EB;
  --bg-card: #FFFFFF;
  --text-primary: #1C1917;
  --text-secondary: #57534E;
  --text-muted: #A8A29E;
  --accent: #92751A;
  --accent-light: #D4A853;
  --accent-bg: rgba(146, 117, 26, 0.08);
  --navy: #1B2A4A;
  --navy-light: #2D4A7C;
  --border: rgba(28, 25, 23, 0.08);
  --border-hover: rgba(28, 25, 23, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --max-width: 1200px;
  --header-height: 64px;

  /* Typography scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(146, 117, 26, 0.025) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(27, 42, 74, 0.025) 0%, transparent 50%);
}

/* Elegant scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background: var(--accent-bg);
  color: var(--text-primary);
}

/* --- App Layout --- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--text-primary);
  color: white;
  padding: var(--space-3) var(--space-5);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 1000;
  transition: top 0.2s;
  font-weight: 500;
  text-decoration: none;
  font-size: var(--text-sm);
}

.skip-link:focus {
  top: 0;
}

/* ===========================
   HEADER
   =========================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
}

.logo:hover {
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
  filter: drop-shadow(0 1px 4px var(--accent-bg));
}

.logo-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  white-space: nowrap;
}

h1.logo-title {
  margin: 0;
  font-size: var(--text-xl);
}

.logo-subtitle {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: var(--space-4);
  padding-left: var(--space-4);
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

/* Search */
.search-wrapper {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  padding: 10px var(--space-4) 10px 44px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-base);
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-warm);
  color: var(--text-primary);
  transition: all 0.25s var(--ease-out);
  outline: none;
}

.search-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background: var(--bg-card);
}

.search-wrapper input::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

/* Header About Link */
.header-about {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  flex-shrink: 0;
  transition: color 0.2s;
}

.header-about:hover {
  color: var(--accent);
}

/* ===========================
   CATEGORY BAR
   =========================== */
.category-bar {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.category-bar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-bar-inner::-webkit-scrollbar {
  display: none;
}

.category-tab {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.2s var(--ease-out);
  border-bottom: 2px solid transparent;
  min-height: 44px;
}

.category-tab:hover {
  color: var(--text-primary);
}

.category-tab.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* ===========================
   INTRO
   =========================== */
.intro {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) 0;
  text-align: center;
}

.intro-text {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 680px;
  margin: 0 auto;
}

/* ===========================
   MAIN CONTENT
   =========================== */
.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-6) var(--space-12);
  width: 100%;
}

/* ===========================
   TOOLBAR
   =========================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-shrink: 0;
}

/* Filter Toggle Button */
.filter-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-4);
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  min-height: 36px;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.filter-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Active Filters (removable pills) */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.active-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(146, 117, 26, 0.2);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
}

.active-filter-pill:hover {
  background: rgba(146, 117, 26, 0.15);
  border-color: var(--accent);
}

/* Results Count */
.results-count {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sort Group */
.sort-group {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sort-btn {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 400;
  padding: 6px var(--space-3);
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  white-space: nowrap;
  min-height: 36px;
}

.sort-btn:hover {
  color: var(--text-primary);
  background: var(--bg-warm);
}

.sort-btn.active {
  background: var(--text-primary);
  color: white;
  font-weight: 500;
}

/* ===========================
   EXPANDABLE FILTER PANEL
   =========================== */
.filter-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s var(--ease-out), opacity 0.25s var(--ease-out), margin 0.35s var(--ease-out);
  margin-bottom: 0;
}

.filter-panel.open {
  max-height: 600px;
  opacity: 1;
  margin-bottom: var(--space-5);
}

.filter-panel.hidden {
  display: block;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

.filter-panel-inner {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
}

.filter-group {
  margin-bottom: var(--space-5);
}

.filter-group:last-of-type {
  margin-bottom: var(--space-4);
}

.filter-group-label {
  display: block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Filter Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 400;
  padding: 6px var(--space-3);
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
  min-height: 32px;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--text-primary);
}

.chip.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
  font-weight: 500;
}

/* Clear Filters Button */
.clear-filters-btn {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 8px var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.clear-filters-btn:hover {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}

/* ===========================
   PARSHA BANNER (compact)
   =========================== */
.parsha-banner {
  background: linear-gradient(135deg, #FBF6EC 0%, #F7F1E3 50%, #FDF9F0 100%);
  border: 1px solid rgba(146, 117, 26, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-5);
  position: relative;
  overflow: hidden;
}

.parsha-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--navy), var(--accent));
  opacity: 0.7;
}

.parsha-banner.hidden {
  display: none;
}

.parsha-inner {
  position: relative;
}

.parsha-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.parsha-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.parsha-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: var(--space-1);
}

.parsha-dismiss {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.06);
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
  line-height: 1;
}

.parsha-dismiss:hover {
  background: rgba(28, 25, 23, 0.12);
  color: var(--text-primary);
}

.parsha-scroll {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-top: var(--space-2);
  margin-top: calc(-1 * var(--space-2));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}

.parsha-scroll::-webkit-scrollbar {
  display: none;
}

.parsha-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 200px;
  max-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.25s var(--ease-out);
  flex-shrink: 0;
}

.parsha-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.parsha-card-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.parsha-card-excerpt {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.parsha-view-all {
  display: inline-block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s var(--ease-out);
}

.parsha-view-all:hover {
  color: var(--navy);
  text-decoration: underline;
}

/* ===========================
   LOADING STATE
   =========================== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  color: var(--text-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-4);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-lg);
  font-style: italic;
}

.loading.hidden {
  display: none;
}

/* ===========================
   RESULTS GRID
   =========================== */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--space-5);
}

.results-grid.hidden {
  display: none;
}

/* ===========================
   TEXT CARD
   =========================== */
.myth-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  animation: cardFadeIn 0.4s var(--ease-out) both;
}

/* Stagger card fade-in */
.myth-card:nth-child(1) { animation-delay: 0ms; }
.myth-card:nth-child(2) { animation-delay: 30ms; }
.myth-card:nth-child(3) { animation-delay: 60ms; }
.myth-card:nth-child(4) { animation-delay: 90ms; }
.myth-card:nth-child(5) { animation-delay: 120ms; }
.myth-card:nth-child(6) { animation-delay: 150ms; }
.myth-card:nth-child(7) { animation-delay: 180ms; }
.myth-card:nth-child(8) { animation-delay: 210ms; }
.myth-card:nth-child(9) { animation-delay: 240ms; }
.myth-card:nth-child(n+10) { animation-delay: 270ms; }

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

/* Left accent bar */
.myth-card::before {
  content: '';
  position: absolute;
  top: var(--space-4);
  left: 0;
  width: 3px;
  height: calc(100% - var(--space-8));
  background: linear-gradient(to bottom, var(--accent), var(--navy));
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transform: scaleY(0.3);
  transform-origin: center;
  transition: all 0.3s var(--ease-out);
}

.myth-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.myth-card:hover::before {
  opacity: 1;
  transform: scaleY(1);
}

.myth-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-2);
  gap: var(--space-3);
}

.myth-card-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  transition: color 0.2s var(--ease-out);
}

.myth-card:hover .myth-card-title {
  color: var(--navy);
}

.myth-card-number {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-warm);
  padding: 2px var(--space-2);
  border-radius: 4px;
  font-weight: 500;
  flex-shrink: 0;
}

.myth-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  align-items: center;
}

.myth-card-source {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy);
  font-weight: 600;
}

.myth-card-citation {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-left: var(--space-2);
  border-left: 1px solid var(--border);
}

.myth-card-excerpt {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.myth-card-themes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.theme-tag {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  background: var(--bg-warm);
  color: var(--text-muted);
  border-radius: 4px;
  text-transform: capitalize;
  font-weight: 400;
  transition: all 0.2s var(--ease-out);
}

.myth-card:hover .theme-tag {
  background: rgba(146, 117, 26, 0.06);
  color: var(--text-secondary);
}

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-4);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.35;
}

.empty-state h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-2xl);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.empty-state p {
  color: var(--text-muted);
  font-size: var(--text-base);
}

/* ===========================
   PAGINATION
   =========================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.pagination.hidden {
  display: none;
}

.page-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all 0.25s var(--ease-out);
  min-height: 44px;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-btn svg {
  width: 16px;
  height: 16px;
}

.page-info {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: var(--text-base);
  color: var(--text-muted);
  font-weight: 500;
}

/* ===========================
   FOOTER
   =========================== */
.footer {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

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

.footer p {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--text-sm);
  line-height: 1.6;
  margin-bottom: var(--space-2);
}

.footer-sources {
  font-size: var(--text-xs) !important;
  color: var(--text-muted);
}

/* ===========================
   RESPONSIVE — TABLET
   =========================== */
@media (max-width: 1024px) {
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }

  .toolbar {
    flex-wrap: wrap;
  }
}

/* ===========================
   RESPONSIVE — MOBILE
   =========================== */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  /* Header: collapse to logo + search icon */
  .header-inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  .logo-title {
    font-size: var(--text-lg);
  }

  .logo-icon {
    font-size: 1.5rem;
  }

  .search-wrapper {
    max-width: none;
  }

  .search-wrapper input {
    font-size: var(--text-sm);
    padding: 8px var(--space-3) 8px 38px;
  }

  .header-stats {
    display: none;
  }

  /* Category tabs: scroll horizontally */
  .category-bar {
    top: 56px;
  }

  .category-bar-inner {
    padding: 0 var(--space-4);
  }

  .category-tab {
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
    min-height: 40px;
  }

  /* Main content */
  .main {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

  /* Toolbar stacks */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .toolbar-left {
    width: 100%;
  }

  .toolbar-right {
    justify-content: space-between;
    width: 100%;
  }

  /* Filter panel full width */
  .filter-panel-inner {
    padding: var(--space-4);
  }

  /* Single column grid */
  .results-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Cards less padding */
  .myth-card {
    padding: var(--space-4) var(--space-5);
  }

  /* Parsha banner */
  .parsha-banner {
    padding: var(--space-4);
  }

  .parsha-name {
    font-size: var(--text-xl);
  }

  .parsha-card {
    min-width: 170px;
  }

  /* Pagination */
  .page-btn {
    padding: 8px var(--space-3);
    font-size: var(--text-xs);
  }

  .footer {
    padding: var(--space-6) var(--space-4);
  }
}

@media (max-width: 480px) {
  .logo-title {
    font-size: var(--text-base);
  }

  .logo-icon {
    font-size: 1.25rem;
  }

  .search-wrapper input {
    font-size: var(--text-sm);
  }

  .sort-group {
    display: none;
  }

  .myth-card-title {
    font-size: var(--text-lg);
  }
}

/* ===========================
   PRINT STYLES
   =========================== */
@media print {
  .header,
  .category-bar,
  .toolbar,
  .filter-panel,
  .parsha-banner,
  .pagination,
  .footer,
  .skip-link {
    display: none !important;
  }

  .main {
    max-width: 100%;
    padding: 0;
  }

  .results-grid {
    display: block;
  }

  .myth-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    margin-bottom: 1rem;
    page-break-inside: avoid;
  }

  .myth-card::before {
    display: none;
  }

  body {
    background: white;
    color: black;
  }
}

/* ===========================
   ACCESSIBILITY
   =========================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles — gold outline */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: rgba(0, 0, 0, 0.3);
    --border-hover: rgba(0, 0, 0, 0.5);
    --text-muted: #666;
  }

  .chip,
  .theme-tag,
  .category-tab,
  .sort-btn,
  .page-btn {
    border: 1px solid currentColor;
  }

  .myth-card {
    border-width: 2px;
  }
}
