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

:root {
  --ink:     #141e17;
  --deep:    #192519;
  --surface: #1e2e22;
  --moss:    #355c3d;
  --river:   #4a8c5c;
  --foam:    #90c4a0;
  --mist:    #cde3d3;
  --light:   #eef6f1;
  --gold:    #c8a96e;
  --amber:   #e8c27a;
  --text:    #b8d4c0;
  --subtle:  #7aaa88;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--deep); }
::-webkit-scrollbar-thumb { background: var(--moss); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--river); }
* { scrollbar-width: thin; scrollbar-color: var(--moss) var(--deep); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ── */
header {
  padding: 2rem 3rem 1.5rem;
  border-bottom: 1px solid rgba(61,122,82,0.2);
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

.app-back {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--subtle);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.3s;
}

.app-back::before { content: '←'; }
.app-back:hover { color: var(--mist); }

.app-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--light);
  letter-spacing: 0.08em;
}

.app-title span { color: var(--gold); }
.app-title em { font-style: italic; color: var(--subtle); font-size: 1rem; }

.app-subtitle {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-left: auto;
}

/* ── MAP SECTION ── */
.map-section {
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  height: calc(100vh - 5.5rem);
  min-height: 460px;
}

.map-container {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(61,122,82,0.2);
  overflow: hidden;
  min-height: 0;
}

/* ── D3 MAP ELEMENTS ── */
.map-ocean {
  fill: var(--surface);
}

.map-graticule {
  fill: none;
  stroke: rgba(61,122,82,0.07);
  stroke-width: 0.5;
}

.map-equator {
  fill: none;
  stroke: rgba(200,169,110,0.25);
  stroke-width: 1;
}

.map-borders {
  fill: none;
  stroke: rgba(61,122,82,0.15);
  stroke-width: 0.4;
  pointer-events: none;
}

/* Non-region countries — decorative */
.country-deco {
  fill: rgba(30,48,36,0.8);
  stroke: rgba(74,140,92,0.18);
  stroke-width: 0.4;
  pointer-events: none;
}

/* Clickable region countries */
.region-country {
  stroke: rgba(74,140,92,0.3);
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.25s, filter 0.25s, stroke 0.25s;
}

.region-amazon       { fill: rgba(30,90,50,0.75); }
.region-africa       { fill: rgba(90,62,15,0.72); }
.region-europe       { fill: rgba(38,38,90,0.70); }
.region-northamerica { fill: rgba(65,38,90,0.68); }
.region-asia         { fill: rgba(15,60,90,0.72); }

.region-country.hovered {
  filter: brightness(1.8);
  stroke: rgba(200,169,110,0.4);
  stroke-width: 1;
}

/* active must come after hovered so it wins */
.region-country.active {
  stroke: var(--amber);
  stroke-width: 1.2;
  filter: brightness(2.2);
}

/* ── REGION PANEL ── */
.region-panel {
  background: var(--surface);
  border: 1px solid rgba(74,140,92,0.2);
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--moss) var(--surface);
}

.region-panel::-webkit-scrollbar { width: 4px; }
.region-panel::-webkit-scrollbar-track { background: var(--surface); }
.region-panel::-webkit-scrollbar-thumb { background: var(--moss); }

/* ── ACCORDION ── */
.accordion-item {
  border-bottom: 1px solid rgba(74,140,92,0.15);
}

.accordion-item:last-child { border-bottom: none; }

.accordion-header {
  width: 100%;
  background: none;
  border: none;
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  transition: background 0.2s;
}

.accordion-header:hover { background: rgba(74,140,92,0.06); }

.accordion-item.active .accordion-header { background: rgba(74,140,92,0.08); }

.accordion-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--light);
  margin-bottom: 0.15rem;
  transition: color 0.2s;
}

.accordion-meta {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--subtle);
  transition: color 0.2s;
}

.accordion-item.active .accordion-name { color: var(--amber); }
.accordion-item.active .accordion-meta { color: var(--gold); }

.accordion-chevron {
  color: var(--subtle);
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.3s ease, color 0.2s;
}

.accordion-item.active .accordion-chevron {
  transform: rotate(90deg);
  color: var(--amber);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.accordion-item.active .accordion-body { max-height: 520px; }

.accordion-body .region-desc {
  padding: 0 1.5rem;
  margin-bottom: 1rem;
}

.accordion-body .region-stats {
  padding: 0 1.5rem;
  margin-bottom: 0.8rem;
}

.accordion-body .region-fish-count {
  padding: 0 1.5rem;
  margin-bottom: 0.8rem;
  margin-top: 0;
}

.accordion-body .btn-explore {
  margin: 0 1.5rem 1.5rem;
  width: calc(100% - 3rem);
}

.region-desc {
  font-size: 0.82rem;
  color: var(--subtle);
  line-height: 1.7;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(61,122,82,0.15);
  padding-bottom: 1rem;
}

.region-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat-item {
  background: rgba(61,122,82,0.08);
  padding: 0.6rem 0.8rem;
  border-left: 2px solid var(--river);
}

.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  color: var(--foam);
  line-height: 1;
  margin-bottom: 0.15rem;
}

.stat-key {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--moss);
}

.region-fish-count {
  font-size: 0.72rem;
  color: var(--subtle);
  margin-bottom: 0.8rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.btn-explore {
  width: 100%;
  padding: 0.75rem;
  background: var(--river);
  color: var(--light);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-explore:hover { background: var(--moss); }

/* ── FISH SECTION ── */
.fish-section {
  padding: 0 3rem 3rem;
  display: none;
}

.fish-section.visible { display: block; }

.fish-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(61,122,82,0.2);
}

.fish-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--light);
}

.fish-section-title span { font-style: italic; color: var(--foam); }

.btn-back-region {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--subtle);
  background: none;
  border: 1px solid rgba(61,122,82,0.3);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-back-region:hover { color: var(--mist); border-color: var(--river); }

.fish-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.4rem 1rem;
  background: transparent;
  border: 1px solid rgba(61,122,82,0.3);
  color: var(--subtle);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
}

.filter-btn:hover,
.filter-btn.active { background: var(--moss); border-color: var(--river); color: var(--mist); }

.fish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2px;
}

/* ── FISH CARD ── */
.fish-card {
  background: var(--surface);
  cursor: pointer;
  transition: background 0.3s;
  overflow: hidden;
}

.fish-card:hover { background: var(--deep); }

.fish-card-img-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.fish-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85) brightness(0.9);
  transition: filter 0.4s;
}

.fish-card:hover .fish-card-img { filter: saturate(1.1) brightness(1); }

.fish-card-img-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--moss) 0%, var(--ink) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.4;
}

.fish-card-body { padding: 1.4rem 1.6rem 1.8rem; }

.fish-difficulty {
  display: inline-flex;
  gap: 3px;
  margin-bottom: 0.6rem;
}

.diff-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moss);
}

.diff-dot.filled { background: var(--river); }

.fish-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--light);
  margin-bottom: 0.1rem;
  line-height: 1.2;
}

.fish-latin {
  font-size: 0.72rem;
  color: var(--subtle);
  font-style: italic;
  margin-bottom: 0.8rem;
}

.fish-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.fish-tag {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(200,169,110,0.25);
  padding: 0.2rem 0.5rem;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,22,18,0.92);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--deep);
  border: 1px solid rgba(61,122,82,0.3);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 280px 1fr;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: 1px solid rgba(61,122,82,0.3);
  color: var(--subtle);
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: 10;
}

.modal-close:hover { color: var(--light); border-color: var(--river); }

.modal-img-side {
  position: relative;
  background: linear-gradient(135deg, var(--moss) 0%, var(--ink) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  opacity: 0.5;
  overflow: hidden;
}

.modal-img-side img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.95;
}

.img-credit {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.35rem 0.6rem;
  background: rgba(11,22,18,0.75);
  font-size: 0.6rem;
  color: rgba(180,210,190,0.7);
  letter-spacing: 0.06em;
  z-index: 2;
  line-height: 1.3;
}

.modal-content-side {
  padding: 2rem 2.5rem 2.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--moss) var(--deep);
}

.modal-content-side::-webkit-scrollbar { width: 4px; }
.modal-content-side::-webkit-scrollbar-track { background: var(--deep); }
.modal-content-side::-webkit-scrollbar-thumb { background: var(--moss); }
.modal-content-side::-webkit-scrollbar-thumb:hover { background: var(--river); }

.modal-eyebrow {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.modal-fish-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 300;
  color: var(--light);
  line-height: 1.1;
  margin-bottom: 0.3rem;
}

.modal-fish-latin {
  font-size: 0.8rem;
  color: var(--subtle);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--subtle);
  line-height: 1.85;
  margin-bottom: 1.5rem;
}

.modal-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.param {
  background: rgba(200,169,110,0.07);
  padding: 0.6rem 0.8rem;
  border-left: 2px solid rgba(200,169,110,0.25);
}

.param-key {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 0.2rem;
}

.param-val { font-size: 0.85rem; color: var(--foam); }

.modal-facts {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(61,122,82,0.05);
  border-left: 2px solid rgba(61,122,82,0.3);
}

.modal-facts-title {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.8rem;
}

.modal-facts p {
  font-size: 0.82rem;
  color: var(--subtle);
  line-height: 1.75;
  margin-bottom: 0.5rem;
}

.modal-difficulty-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 0.4rem;
}

.modal-difficulty-bar { display: flex; gap: 4px; }

.diff-bar-seg {
  height: 5px;
  flex: 1;
  background: var(--moss);
  border-radius: 2px;
  opacity: 0.35;
  transition: background 0.3s, opacity 0.3s;
}

.diff-bar-seg.filled { opacity: 1; }

.diff-bar-seg:nth-child(1).filled { background: var(--river); }
.diff-bar-seg:nth-child(2).filled { background: var(--gold); }
.diff-bar-seg:nth-child(3).filled { background: #bf5a3e; }

/* ── ENC FOOTER ── */
.enc-footer {
  padding: 1.5rem 3rem;
  border-top: 1px solid rgba(61,122,82,0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--subtle);
  letter-spacing: 0.06em;
}

.enc-footer-link {
  color: var(--subtle);
  text-decoration: none;
  transition: color 0.3s;
}

.enc-footer-link:hover { color: var(--mist); }

/* ── LOADING ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--subtle);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .map-section { grid-template-columns: 1fr; padding: 1rem; height: auto; min-height: unset; }
  .fish-section { padding: 0 1.5rem 3rem; }
  .modal { grid-template-rows: 200px 1fr; }
  header { padding: 1.2rem 1.5rem; flex-wrap: wrap; gap: 0.8rem; }
  .app-subtitle { margin-left: 0; }
}
