/* AP Human Geography - Unit 1 Stylesheet
   Author: Simon Gil | Topic: Thinking Geographically
*/

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(51, 65, 85, 0.7);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --accent-blue: #38bdf8;
  --accent-cyan: #22d3ee;
  --accent-indigo: #818cf8;
  --accent-purple: #c084fc;
  --accent-emerald: #34d399;
  --accent-amber: #fbbf24;
  --accent-rose: #fb7185;
  
  --badge-bg: rgba(56, 189, 248, 0.15);
  --badge-text: #38bdf8;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  
  --code-bg: #090d16;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #f8fafc;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  
  --accent-blue: #0284c7;
  --accent-cyan: #0891b2;
  --accent-indigo: #4f46e5;
  --accent-purple: #9333ea;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  
  --badge-bg: rgba(2, 132, 199, 0.1);
  --badge-text: #0369a1;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  
  --code-bg: #f1f5f9;
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.65;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* Header & Top Navigation Bar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1.5rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.85rem 0.5rem 2.25rem;
  font-size: 0.9rem;
  background-color: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.btn-icon {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  color: #ffffff;
  border: none;
}

.btn-primary:hover {
  opacity: 0.92;
  box-shadow: var(--shadow-md);
}

/* Layout Wrapper */
.layout-container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 2rem;
  padding: 2rem 1.5rem 4rem;
}

/* Sidebar Navigation */
.sidebar {
  position: sticky;
  top: 4.5rem;
  height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding-right: 0.75rem;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.sidebar-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-link {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  line-height: 1.35;
}

.toc-link:hover {
  color: var(--text-main);
  background-color: var(--bg-tertiary);
}

.toc-link.active {
  color: var(--accent-blue);
  background-color: var(--badge-bg);
  font-weight: 600;
  border-left: 3px solid var(--accent-blue);
}

.sidebar-meta {
  font-size: 0.825rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.meta-item {
  display: flex;
  justify-content: space-between;
}

.meta-val {
  font-weight: 600;
  color: var(--text-main);
}

/* Main Content Area */
.content-area {
  min-width: 0;
}

/* Hero Section */
.hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

[data-theme="light"] .hero-card {
  background: linear-gradient(135deg, #ffffff, #f1f5f9);
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  background: linear-gradient(to right, var(--text-main), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-title {
  background: linear-gradient(to right, #0f172a, #0284c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 800px;
  margin-bottom: 1.5rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.stat-box {
  background: var(--bg-tertiary);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.2rem;
}

/* Sections & Cards */
.topic-section {
  margin-bottom: 3rem;
  scroll-margin-top: 5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-main);
}

.section-number {
  font-size: 0.9rem;
  font-family: var(--font-mono);
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

/* Callouts */
.callout {
  border-left: 4px solid var(--accent-blue);
  background: rgba(56, 189, 248, 0.08);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 1.25rem 0;
}

.callout-case-study {
  border-left-color: var(--accent-amber);
  background: rgba(251, 191, 36, 0.08);
}

.callout-tip {
  border-left-color: var(--accent-emerald);
  background: rgba(52, 211, 153, 0.08);
}

.callout-warning {
  border-left-color: var(--accent-rose);
  background: rgba(251, 113, 133, 0.08);
}

.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout-case-study .callout-title { color: var(--accent-amber); }
.callout-tip .callout-title { color: var(--accent-emerald); }
.callout-warning .callout-title { color: var(--accent-rose); }
.callout .callout-title { color: var(--accent-blue); }

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--bg-tertiary);
  color: var(--text-main);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

/* Feature Cards & Badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.badge-blue { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.badge-purple { background: rgba(192, 132, 252, 0.15); color: var(--accent-purple); }
.badge-green { background: rgba(52, 211, 153, 0.15); color: var(--accent-emerald); }
.badge-amber { background: rgba(251, 191, 36, 0.15); color: var(--accent-amber); }
.badge-rose { background: rgba(251, 113, 133, 0.15); color: var(--accent-rose); }

/* S.A.D.D. Distortion Cards */
.sadd-card {
  text-align: center;
  padding: 1.25rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sadd-letter {
  font-size: 2.25rem;
  font-weight: 900;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.sadd-label {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.sadd-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Flashcard Deck Modal / Widget */
.flashcards-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.flashcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.card-flip-wrapper {
  perspective: 1000px;
  max-width: 650px;
  height: 280px;
  margin: 0 auto 1.5rem;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
}

.flashcard-inner.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--border-color);
}

.flashcard-front {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}

.flashcard-back {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  transform: rotateY(180deg);
  border-color: var(--accent-blue);
}

.flashcard-term {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.75rem 0;
}

.flashcard-def {
  font-size: 1.05rem;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.flashcard-example {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-style: italic;
}

.flashcard-tip {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.deck-progress {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Definition lists / Key terms */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.vocab-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.vocab-term {
  font-weight: 700;
  color: var(--accent-blue);
  font-size: 1rem;
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vocab-def {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.footer-link {
  color: var(--accent-blue);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Highlighted search match */
.search-highlight {
  background-color: rgba(251, 191, 36, 0.3);
  color: inherit;
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .layout-container {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none;
  }
  
  .search-box {
    width: 200px;
  }
}

@media (max-width: 640px) {
  .header-container {
    flex-wrap: wrap;
  }
  
  .search-box {
    width: 100%;
    order: 3;
  }
  
  .hero-title {
    font-size: 1.8rem;
  }
  
  .card-flip-wrapper {
    height: 320px;
  }
}

/* Print styles */
@media print {
  .site-header,
  .sidebar,
  .flashcards-container,
  .btn-icon,
  .site-footer {
    display: none !important;
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  
  .layout-container {
    padding: 0 !important;
    grid-template-columns: 1fr !important;
  }
  
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
}

/* Password Protection Gate */
html.is-unlocked .gate-overlay {
  display: none !important;
}

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

[data-theme="light"] .gate-overlay {
  background: rgba(248, 250, 252, 0.96);
}

.gate-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: gateCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes gateCardPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.gate-icon {
  font-size: 2.75rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}

.gate-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.gate-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.45;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.gate-input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1.05rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  text-align: center;
  letter-spacing: 0.15em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gate-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.gate-btn {
  width: 100%;
  padding: 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.gate-btn:hover {
  opacity: 0.92;
}

.gate-btn:active {
  transform: scale(0.98);
}

.gate-error {
  color: var(--accent-rose);
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.25rem;
  margin-top: 0.2rem;
}

