/* ===== CA Bar Study Guide — Global Styles ===== */

:root {
  --bg: #faf9f6;
  --bg-secondary: #f0eee9;
  --bg-tertiary: #e8e5de;
  --text: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #7a7a7a;
  --accent: #8b2500;
  --accent-light: #c4553a;
  --accent-bg: #fdf0ec;
  --border: #d4d0c8;
  --border-light: #e8e5de;
  --highlight-bg: #fffde7;
  --highlight-border: #f9a825;
  --tip-bg: #e8f5e9;
  --tip-border: #43a047;
  --warning-bg: #fff3e0;
  --warning-border: #ef6c00;
  --ca-bg: #e3f2fd;
  --ca-border: #1565c0;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --sidebar-width: 280px;
  --header-height: 56px;
  --serif: "Georgia", "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  --radius: 6px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #1a1a1e;
  --bg-secondary: #242428;
  --bg-tertiary: #2e2e34;
  --text: #e4e4e4;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;
  --accent: #e07050;
  --accent-light: #ff9070;
  --accent-bg: #2a1a14;
  --border: #3a3a40;
  --border-light: #2e2e34;
  --highlight-bg: #2a2810;
  --highlight-border: #c8a020;
  --tip-bg: #1a2e1a;
  --tip-border: #4caf50;
  --warning-bg: #2a1e10;
  --warning-border: #ff9800;
  --ca-bg: #1a2030;
  --ca-border: #42a5f5;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 17px; scroll-behavior: smooth; }

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  z-index: 1000;
  gap: 1rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius);
}
.menu-toggle:hover { background: var(--bg-tertiary); }

.site-title {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition);
}
.header-search input:focus { border-color: var(--accent); }
.header-search::before {
  content: "\1F50D";
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  opacity: 0.5;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow-hover);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}
.search-results.active { display: block; }
.search-results a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}
.search-results a:hover { background: var(--bg-secondary); }
.search-results a:last-child { border-bottom: none; }
.search-results .search-subject { font-size: 0.7rem; color: var(--text-muted); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.theme-toggle, .progress-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.8rem;
  transition: all var(--transition);
  white-space: nowrap;
}
.theme-toggle:hover, .progress-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0;
  z-index: 900;
  transition: transform var(--transition);
}

.sidebar-section {
  padding: 0 1rem;
  margin-bottom: 1.5rem;
}

.sidebar-section h3 {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}

.sidebar-nav { list-style: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.82rem;
  border-radius: var(--radius);
  transition: all var(--transition);
  line-height: 1.3;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}
.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.sidebar-nav .check {
  font-size: 0.75rem;
  opacity: 0;
  margin-left: auto;
  transition: opacity var(--transition);
  color: var(--tip-border);
}
.sidebar-nav .check.done { opacity: 1; }

.sidebar-progress {
  margin: 0 1.5rem 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.sidebar-progress .label {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 2.5rem 3rem 4rem;
  max-width: 900px;
  flex: 1;
}

/* ===== LANDING PAGE ===== */
.landing-hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.landing-hero h1 {
  font-family: var(--sans);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}
.landing-hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 550px;
  margin: 0 auto;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}

.subject-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  position: relative;
}
.subject-card:hover {
  border-color: var(--accent);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-1px);
}
.subject-card h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--accent);
}
.subject-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.subject-card .card-check {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity var(--transition);
  color: var(--tip-border);
}
.subject-card .card-check.done { opacity: 1; }

/* ===== CONTENT TYPOGRAPHY ===== */
.content h1 {
  font-family: var(--sans);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}
.content .subject-meta {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.content h2 {
  font-family: var(--sans);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
}

.content h3 {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.content h4 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
}

.content p {
  margin-bottom: 1rem;
}

.content ul, .content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
.content li { margin-bottom: 0.3rem; }
.content li ul, .content li ol { margin-top: 0.3rem; margin-bottom: 0.3rem; }

.content strong { font-weight: 700; }

.content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-light);
  text-underline-offset: 2px;
}
.content a:hover { color: var(--accent-light); }

/* ===== CALLOUT BOXES ===== */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin: 1.25rem 0;
  border-left: 4px solid;
  font-size: 0.92rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout-title {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.callout-rule {
  background: var(--highlight-bg);
  border-color: var(--highlight-border);
}
.callout-rule .callout-title { color: var(--highlight-border); }

.callout-tip {
  background: var(--tip-bg);
  border-color: var(--tip-border);
}
.callout-tip .callout-title { color: var(--tip-border); }

.callout-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}
.callout-warning .callout-title { color: var(--warning-border); }

.callout-california {
  background: var(--ca-bg);
  border-color: var(--ca-border);
}
.callout-california .callout-title { color: var(--ca-border); }

/* ===== ELEMENTS LIST ===== */
.elements-list {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.elements-list ol { padding-left: 1.25rem; }
.elements-list li {
  padding: 0.2rem 0;
  font-size: 0.92rem;
}

/* ===== COMPARISON TABLE ===== */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.88rem;
}
.comparison-table th {
  font-family: var(--sans);
  font-weight: 700;
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}
.comparison-table td {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-light);
  vertical-align: top;
}
.comparison-table tr:nth-child(even) td { background: var(--bg-secondary); }

/* ===== COLLAPSIBLE SECTIONS ===== */
details {
  margin: 1rem 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}
details[open] { border-color: var(--border); }

summary {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: var(--bg-secondary);
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background var(--transition);
}
summary:hover { background: var(--bg-tertiary); }
summary::before {
  content: "\25B6";
  font-size: 0.6rem;
  transition: transform var(--transition);
  color: var(--text-muted);
}
details[open] summary::before { transform: rotate(90deg); }

.details-content {
  padding: 1rem 1.25rem;
}

/* ===== MNEMONIC BOX ===== */
.mnemonic {
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  text-align: center;
}
.mnemonic .mnemonic-word {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}
.mnemonic .mnemonic-breakdown {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.mnemonic .mnemonic-breakdown span {
  font-weight: 700;
  color: var(--accent);
}

/* ===== CHECKLIST ===== */
.checklist {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.checklist li {
  padding: 0.4rem 0 0.4rem 1.75rem;
  position: relative;
  font-size: 0.92rem;
}
.checklist li::before {
  content: "\2610";
  position: absolute;
  left: 0;
  font-size: 1.1rem;
  line-height: 1;
  top: 0.4rem;
}

/* ===== MARK COMPLETE BUTTON ===== */
.mark-complete-wrap {
  text-align: center;
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
}
.mark-complete {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.mark-complete:hover {
  background: var(--accent);
  color: #fff;
}
.mark-complete.completed {
  background: var(--tip-border);
  border-color: var(--tip-border);
  color: #fff;
}

/* ===== PAGE NAV (prev/next) ===== */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  gap: 1rem;
}
.page-nav a {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.5rem 0;
  transition: color var(--transition);
}
.page-nav a:hover { color: var(--accent-light); }
.page-nav .next { margin-left: auto; text-align: right; }
.page-nav .dir-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .menu-toggle { display: flex; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 2rem 1.5rem 3rem;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,0.3);
    z-index: 899;
  }
  .sidebar-overlay.active { display: block; }
}

@media (max-width: 600px) {
  html { font-size: 16px; }
  .main-content { padding: 1.5rem 1rem 2rem; }
  .landing-hero h1 { font-size: 1.6rem; }
  .subject-grid { grid-template-columns: 1fr; }
  .header-search { display: none; }
}
