/* ============================================================
   US States & Capitals Flashcards — Styles
   ============================================================ */

:root {
  --navy:       #1a2744;
  --navy-light: #2d3f6b;
  --red:        #c0392b;
  --red-light:  #e74c3c;
  --gold:       #f0a500;
  --gold-light: #f5c542;
  --bg:         #f0f4f8;
  --surface:    #ffffff;
  --surface2:   #f7f9fc;
  --border:     #dde3ed;
  --text:       #1e2a3a;
  --text2:      #4a5568;
  --text3:      #718096;
  --green:      #27ae60;
  --green-bg:   #eafaf1;
  --orange:     #e67e22;
  --orange-bg:  #fef5ec;
  --blue:       #2980b9;
  --blue-bg:    #eaf4fd;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --transition: .2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  text-decoration: none;
  color: white;
}

.header-logo .flag-icon { font-size: 1.4rem; }

nav {
  display: flex;
  gap: 4px;
}

nav button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.75);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  transition: var(--transition);
}
nav button:hover { background: rgba(255,255,255,.12); color: white; }
nav button.active { background: rgba(255,255,255,.18); color: white; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ── Home ── */
.home-hero {
  text-align: center;
  padding: 60px 24px 40px;
  max-width: 700px;
  margin: 0 auto;
}
.home-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
  margin-bottom: 12px;
}
.home-hero p {
  font-size: 1.1rem;
  color: var(--text2);
  margin-bottom: 36px;
}

.home-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 600px;
  margin: 0 auto 40px;
}

.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.mode-card:hover {
  border-color: var(--navy);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.mode-card .mode-icon { font-size: 2.5rem; margin-bottom: 12px; }
.mode-card h2 { font-size: 1.2rem; color: var(--navy); margin-bottom: 8px; }
.mode-card p { font-size: .875rem; color: var(--text2); }

.home-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px 60px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.stat-pill .stat-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}
.stat-pill .stat-label { font-size: .8rem; color: var(--text3); }

/* ── Browse View ── */
.browse-header {
  padding: 24px 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.browse-header h1 { font-size: 1.5rem; color: var(--navy); }

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  max-width: 480px;
}
.search-row input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
  background: var(--surface);
}
.search-row input:focus { border-color: var(--navy); }

.region-filter {
  display: flex;
  gap: 8px;
  padding: 0 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.region-btn {
  padding: 6px 16px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text2);
}
.region-btn:hover { border-color: var(--navy-light); color: var(--navy); }
.region-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 24px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.state-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.state-card:hover {
  border-color: var(--navy-light);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.state-card .flag-wrap {
  width: 80px;
  height: 50px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.state-card .flag-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.flag-fallback {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}
.state-card .state-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
}
.state-card .state-abbr {
  font-size: .8rem;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
}
.state-card .capital-label {
  font-size: .85rem;
  color: var(--text2);
}
.state-card .region-badge {
  font-size: .75rem;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 500;
}
.region-South   { background: #fef3e2; color: #9a5c00; }
.region-Midwest { background: #e8f5e9; color: #2e7d32; }
.region-Northeast { background: #e3f2fd; color: #1565c0; }
.region-West    { background: #f3e5f5; color: #7b1fa2; }

/* ── Detail View ── */
.detail-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: 20px;
  padding: 6px 0;
  background: none;
  border: none;
  transition: var(--transition);
}
.detail-back:hover { color: var(--navy); }

.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.detail-flag-wrap {
  width: 140px;
  height: 88px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-flag-wrap img { width: 100%; height: 100%; object-fit: contain; }

.detail-locator-wrap {
  width: 140px;
  height: 88px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-locator-wrap img { width: 100%; height: 100%; object-fit: contain; }

.detail-title-block { flex: 1; min-width: 200px; }
.detail-title-block h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}
.detail-title-block .detail-abbr {
  display: inline-block;
  background: var(--navy);
  color: white;
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  margin-right: 8px;
}
.detail-title-block .detail-nickname {
  font-size: .9rem;
  color: var(--text3);
  font-style: italic;
}
.detail-capital-line {
  margin-top: 12px;
  font-size: 1rem;
  color: var(--text2);
}
.detail-capital-line strong { color: var(--navy); font-size: 1.1rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.detail-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.fact-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface2);
  font-size: .875rem;
  gap: 8px;
}
.fact-row:last-child { border-bottom: none; }
.fact-label { color: var(--text3); white-space: nowrap; }
.fact-value { color: var(--text); font-weight: 500; text-align: right; }

.detail-known-for {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.detail-known-for h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.known-for-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.known-for-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.4;
}
.known-for-list li::before {
  content: '★';
  color: var(--gold);
  font-size: .8rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.fun-facts-section {
  background: linear-gradient(135deg, #eef2ff 0%, #f0f4ff 100%);
  border: 1px solid #c5cdf5;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.fun-facts-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #3730a3;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fun-fact {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #dde3f5;
  font-size: .9rem;
  color: #374151;
  line-height: 1.5;
}
.fun-fact:last-child { border-bottom: none; }
.fun-fact-num {
  background: #3730a3;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Study View ── */
.study-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.study-header h2 { font-size: 1.2rem; color: var(--navy); font-weight: 700; }

.study-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}
.study-tab {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  background: transparent;
  color: var(--text2);
  transition: var(--transition);
}
.study-tab.active { background: var(--navy); color: white; }
.study-tab:hover:not(.active) { background: var(--surface2); }

.study-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}
.study-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy) 0%, var(--blue) 100%);
  border-radius: 3px;
  transition: width .4s ease;
}

.study-queue-info {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  font-size: .85rem;
}
.queue-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 100px;
  font-weight: 600;
}
.queue-badge.new-badge { background: var(--blue-bg); color: var(--blue); }
.queue-badge.due-badge { background: var(--orange-bg); color: var(--orange); }
.queue-badge.done-badge { background: var(--green-bg); color: var(--green); }

/* ── Flashcard ── */
.flashcard-scene {
  perspective: 1000px;
  margin-bottom: 24px;
}
.flashcard {
  width: 100%;
  min-height: 300px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
  cursor: pointer;
  border-radius: var(--radius-lg);
}
.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  min-height: 300px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.card-face.front {
  background: linear-gradient(145deg, #fff 0%, #f8f9ff 100%);
}
.card-face.back {
  background: linear-gradient(145deg, #fff 0%, #f0f4ff 100%);
  transform: rotateY(180deg);
}

.card-type-label {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.card-hint {
  position: absolute;
  bottom: 16px;
  font-size: .8rem;
  color: var(--text3);
}

.card-media-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 14px;
}
.card-media-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.card-media-label {
  font-size: .7rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.card-main-flag {
  width: 100px;
  height: 63px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.card-locator-map {
  width: 90px;
  height: 70px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  padding: 4px;
}

.card-question { text-align: center; }
.card-question .card-label {
  font-size: .85rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
.card-question .card-answer {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}
.card-question .card-sub {
  font-size: .95rem;
  color: var(--text2);
  margin-top: 8px;
}

/* Back face content */
.back-answer {
  text-align: center;
  margin-bottom: 16px;
}
.back-answer .answer-label {
  font-size: .8rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.back-answer .answer-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
}
.back-answer .answer-sub {
  font-size: .9rem;
  color: var(--text2);
  margin-top: 4px;
}

.back-facts {
  width: 100%;
  max-width: 420px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 8px;
}
.back-fact-item {
  font-size: .82rem;
  color: var(--text2);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
  align-items: flex-start;
  line-height: 1.4;
}
.back-fact-item:last-child { border-bottom: none; }
.back-fact-item::before { content: '→'; color: var(--navy-light); flex-shrink: 0; }

/* Rating buttons */
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.rating-buttons.hidden { display: none; }
.rate-btn {
  padding: 12px 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.rate-btn .rate-label { font-size: .75rem; opacity: .8; font-weight: 500; }
.rate-btn.again { background: #fde8e8; color: #c0392b; }
.rate-btn.again:hover { background: #c0392b; color: white; }
.rate-btn.hard  { background: #fff3e0; color: #e67e22; }
.rate-btn.hard:hover  { background: #e67e22; color: white; }
.rate-btn.good  { background: #e8f5e9; color: #27ae60; }
.rate-btn.good:hover  { background: #27ae60; color: white; }
.rate-btn.easy  { background: #e3f2fd; color: #2980b9; }
.rate-btn.easy:hover  { background: #2980b9; color: white; }

.show-answer-btn {
  width: 100%;
  padding: 16px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}
.show-answer-btn:hover { background: var(--navy-light); }

.study-complete {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.study-complete h2 { font-size: 1.8rem; color: var(--navy); margin-bottom: 8px; }
.study-complete p { color: var(--text2); margin-bottom: 24px; }
.complete-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── Stats View ── */
.stats-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}
.stats-container h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stats-card .stats-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
}
.stats-card .stats-desc { font-size: .85rem; color: var(--text3); }

.reset-section {
  padding: 24px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  margin-top: 24px;
}
.reset-section h3 { color: var(--red); margin-bottom: 8px; }
.reset-section p { font-size: .875rem; color: var(--text2); margin-bottom: 12px; }
.btn-danger {
  padding: 10px 20px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-danger:hover { background: var(--red-light); }

/* ── Utility ── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-light); }
.btn-secondary { background: var(--surface); color: var(--navy); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--navy); }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.2rem; color: var(--text2); margin-bottom: 8px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .home-modes { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .states-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .home-hero h1 { font-size: 1.8rem; }
  .detail-header { gap: 16px; }
  nav button { padding: 8px 10px; font-size: .8rem; }
  .rating-buttons { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  header { padding: 0 16px; }
  .browse-header { flex-direction: column; align-items: stretch; }
  .search-row { max-width: 100%; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view.active { animation: fadeIn .2s ease; }
