/* ── Custom properties ── */
:root {
  --bg: #f5f0e8;
  --surface: #ffffff;
  --surface2: #f0ece4;
  --text: #1a1a2e;
  --text-muted: #666;
  --primary: #1a7a45;
  --primary-light: #e8f5ee;
  --accent: #d4881a;
  --found: #2ecc71;
  --found-stroke: #27ae60;
  --unfound: #ddd8cc;
  --unfound-stroke: #bbb;
  --hover: #a8e6c0;
  --border: #ddd;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --surface2: #2d3748;
  --text: #f0f0f0;
  --text-muted: #9ca3af;
  --primary: #34d399;
  --primary-light: #064e2b;
  --accent: #f59e0b;
  --found: #10b981;
  --found-stroke: #059669;
  --unfound: #374151;
  --unfound-stroke: #4b5563;
  --hover: #065f46;
  --border: #374151;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

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

html { font-size: 18px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
}

#score {
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
  transition: background 0.3s;
}

#score.complete {
  background: var(--accent);
  color: #fff;
  animation: pulse 0.6s ease 3;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

#dark-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#dark-toggle:hover { background: rgba(255,255,255,0.3); }

/* ── Input bar ── */
#input-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

#dept-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

#dept-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

#dept-input {
  font-size: 1.2rem;
  font-weight: 700;
  width: 4.5rem;
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  text-transform: uppercase;
  transition: border-color 0.2s;
}
#dept-input:focus {
  outline: none;
  border-color: var(--primary);
}

#dept-form button[type="submit"] {
  padding: 0.45rem 1.1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.2s;
}
#dept-form button[type="submit"]:hover { opacity: 0.85; }

#reset-btn {
  margin-left: auto;
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, color 0.2s;
}
#reset-btn:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
[data-theme="dark"] #reset-btn:hover { background: #4c1d1d; color: #fca5a5; border-color: #7f1d1d; }

#feedback {
  font-size: 0.9rem;
  min-height: 1.4em;
  margin-top: 0.3rem;
  font-weight: 600;
  transition: color 0.2s;
}
.feedback-success { color: var(--found-stroke); }
.feedback-warning { color: var(--accent); }
.feedback-error   { color: #e74c3c; }
.feedback-info    { color: var(--text-muted); }

/* ── Tabs ── */
#tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.7rem;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  min-height: 44px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Main content ── */
main { flex: 1; overflow: hidden; }

.tab-panel { display: none; height: 100%; }
.tab-panel.active { display: block; }

/* ── Map tab ── */
#tab-map {
  padding: 0.5rem;
}

#map-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  gap: 0.5rem;
}

#france-map {
  width: 100%;
  height: auto;
  display: block;
}

#france-map path, #idf-map path {
  fill: var(--unfound);
  stroke: var(--unfound-stroke);
  stroke-width: 0.8;
  cursor: default;
  transition: fill 0.4s ease;
}

#france-map path.found, #idf-map path.found {
  fill: var(--found);
  stroke: var(--found-stroke);
}

#france-map path:hover, #idf-map path:hover {
  fill: var(--hover);
  stroke: var(--primary);
}

/* ── IDF Inset ── */
#idf-inset {
  width: min(260px, 50%);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  box-shadow: var(--card-shadow);
  align-self: flex-end;
}

.inset-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#idf-map {
  width: 100%;
  height: auto;
  display: block;
}

#idf-map path {
  stroke-width: 1.2;
}

/* ── Unlocked tab ── */
#tab-unlocked {
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(100dvh - 200px);
}

#empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 1rem;
}

#cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Department card ── */
.dept-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: card-in 0.35s ease;
}

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

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}

.code-badge {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: monospace;
}

.card-title h2 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}

.card-title .region {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.card-section {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.card-section:last-child { border-bottom: none; }

.card-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.card-section p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.card-section ul {
  list-style: none;
  padding: 0;
}

.card-section ul li {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.2rem 0;
  padding-left: 1.2rem;
  position: relative;
  color: var(--text);
}
.card-section ul li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--found-stroke);
  font-size: 0.6rem;
  top: 0.4rem;
}

/* ── Mobile adjustments ── */
@media (max-width: 600px) {
  html { font-size: 16px; }

  #tab-unlocked {
    max-height: calc(100dvh - 190px);
  }

  #cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  #dept-form label { display: none; }
}
