/* ==========================================================================
   Nazilli Kedi Haritası — "Menderes & İncir Atlası" Editoryal-Kartografik Dil
   --------------------------------------------------------------------------
   Sanat Yönü:
     - Ege kireçtaşı kağıt (#F6F2EA), zeytin yaprağı (#4A5D3F), Aydın inciri (#5E3347),
       Menderes kiremidi (#B3542D) ve Ege denizi arduvazı (#2B5B6C).
     - Şablon izi yok: mor-mavi degrade, bulanık cam (backdrop-filter) yığını ve
       jenerik SaaS kartları kullanılmaz.
     - Tipografi çifti: 'Source Serif 4' (editoryal başlıklar) + 'Plus Jakarta Sans'
       (kartografik veri, tablo rakamları — ğ, ş, ı, İ, ö, ü, ç tam destekli).
     - Mekansal ızgara: Katı 8 pt grid (4 / 8 / 16 / 24 / 32 px).
   ========================================================================== */

:root {
  --paper: #F6F2EA;
  --paper-elevated: #EFE9DC;
  --paper-inset: #E6DEC8;
  --ink: #1F1D1A;
  --ink-secondary: #4E473F;
  --ink-muted: #6E655A;
  --rule: #CFC5B4;
  --rule-strong: #A89B87;

  --olive: #4A5D3F;
  --olive-deep: #36452E;
  --fig: #5E3347;
  --terracotta: #B3542D;
  --sea: #2B5B6C;
  --ochre: #A66E1E;
  --alert-bg: #F7E8DE;

  --header-h: 64px;
  --font-serif: 'Source Serif 4', 'Georgia', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --paper: #171614;
  --paper-elevated: #211F1C;
  --paper-inset: #2A2723;
  --ink: #EDE7DB;
  --ink-secondary: #C7BFAF;
  --ink-muted: #999081;
  --rule: #38342E;
  --rule-strong: #544E45;

  --olive: #7D966E;
  --olive-deep: #5E7550;
  --fig: #B87A96;
  --terracotta: #D4744A;
  --sea: #6BA3B8;
  --ochre: #D69B43;
  --alert-bg: #2E211B;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* Editoryal Atlas Üst Başlığı (8 pt grid: height 64px, padding 16px) */
.atlas-header {
  min-height: var(--header-h);
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 40;
}

.atlas-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.atlas-brand h1 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.atlas-subline {
  font-size: 11.5px;
  color: var(--ink-muted);
  border-left: 1px solid var(--rule);
  padding-left: 10px;
  white-space: nowrap;
  display: none;
}

@media (min-width: 1520px) {
  .atlas-subline { display: inline; }
}

.live-env-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-secondary);
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  padding: 4px 10px;
  border-radius: 3px;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  background: var(--paper-elevated);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 5px 9px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.btn:hover {
  background: var(--paper-inset);
}

.btn-olive {
  background: var(--olive);
  border-color: var(--olive-deep);
  color: #FAF8F4;
}

.btn-olive:hover {
  background: var(--olive-deep);
}

.btn-terracotta {
  background: var(--terracotta);
  border-color: #8F3E1E;
  color: #FAF8F4;
}

.btn-fig {
  background: var(--fig);
  border-color: #452333;
  color: #FAF8F4;
}

/* Ana İki Sütunlu Atlas Yerleşimi */
.atlas-layout {
  display: grid;
  grid-template-columns: 416px 1fr;
  height: calc(100vh - var(--header-h));
}

/* Sol Editoryal Kolon */
.editorial-rail {
  background: var(--paper);
  border-right: 1px solid var(--rule-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-elevated);
}

.rail-tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.rail-tab.active {
  color: var(--ink);
  border-bottom-color: var(--terracotta);
  background: var(--paper);
}

.rail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pane {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.pane.active {
  display: flex;
}

/* Editoryal Bölüm Blokları */
.atlas-block {
  border-top: 2px solid var(--ink);
  padding-top: 12px;
}

.atlas-block-subtle {
  background: var(--paper-elevated);
  border: 1px solid var(--rule);
  padding: 12px;
  border-radius: 3px;
}

.block-kicker {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--terracotta);
  margin-bottom: 4px;
}

.atlas-block h2, .atlas-block-subtle h2, .atlas-block-subtle h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.25;
}

/* İstatistik Satırı (Kart Yığını Yerine Tipografik Cetvel) */
.stat-ledger {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  padding: 8px 0;
  gap: 8px;
}

.ledger-cell {
  border-right: 1px solid var(--rule);
  padding-right: 8px;
}

.ledger-cell:last-child {
  border-right: none;
  padding-right: 0;
}

.ledger-num {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}

.ledger-lbl {
  font-size: 11px;
  color: var(--ink-muted);
}

/* Küçük, Şık Veri Kaynağı Rozeti (Büyük DEMO İbaresi Yok) */
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--rule-strong);
  background: var(--paper-inset);
  color: var(--ink-secondary);
}

.source-chip[data-source="saha"] {
  border-color: var(--olive);
  color: var(--olive);
}

.source-chip[data-source="topluluk"] {
  border-color: var(--sea);
  color: var(--sea);
}

.source-chip[data-source="tohum"] {
  border-color: var(--ochre);
  color: var(--ochre);
}

/* Çoklu Seçimli Tür Çipleri */
.pheno-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.pheno-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 3px;
  font-size: 11.5px;
  cursor: pointer;
}

.pheno-chip.selected {
  border-color: var(--ink);
  background: var(--paper-inset);
  font-weight: 600;
}

.pheno-chip img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Form Elemanları */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.field input, .field select, .field textarea {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 12.5px;
}

/* Boş Durum (Empty State) Kartı — "Yalnızca saha doğrulamalı" filtresi için */
.empty-state-box {
  border: 1px dashed var(--rule-strong);
  background: var(--paper-elevated);
  padding: 16px;
  border-radius: 3px;
}

/* Harita Tuvali ve Kartografik Donatılar */
.map-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#mapPrimary, #mapCompare {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#mapCompare {
  display: none;
  z-index: 4;
}

.swipe-divider {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--terracotta);
  z-index: 12;
  cursor: ew-resize;
}

.swipe-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  border: 2px solid var(--terracotta);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Kartografik Katman Cetveli (Sağ Üst) */
.carto-layer-box {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  max-height: calc(100% - 140px);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  padding: 12px;
  z-index: 20;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.mode-btn {
  border: 1px solid var(--rule);
  background: var(--paper-elevated);
  padding: 6px 8px;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
}

.mode-btn.active {
  border-color: var(--olive);
  background: var(--olive);
  color: #FAF8F4;
  font-weight: 600;
}

/* Kuzey Oku, CRS ve Sahne Tarihi Damgası (Sol Üst & Sol Alt) */
.north-compass {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  display: grid;
  place-items: center;
  z-index: 18;
  cursor: pointer;
}

.carto-legend-dock {
  position: absolute;
  left: 16px;
  bottom: 24px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  padding: 8px 12px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: calc(100% - 336px);
}

.legend-scale-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.swatch-ramp {
  display: flex;
  height: 8px;
  width: 128px;
  border: 1px solid var(--rule-strong);
}

/* 1,7 m Yaya Gözü & 360° Panorama Sahnesi */
.pedestrian-overlay {
  display: none;
  position: absolute;
  inset: 16px 312px 96px 16px;
  background: var(--paper);
  border: 2px solid var(--ink);
  z-index: 28;
  flex-direction: column;
}

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

.pedestrian-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

#pedestrianViewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #23211E;
}

/* Diyalog Pencereleri (Tür Rehberi, Small Multiples, İçe Aktarma Sihirbazı, Yükleme) */
.dialog-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 22, 20, 0.72);
  z-index: 90;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog-scrim.open {
  display: flex;
}

.dialog-sheet {
  background: var(--paper);
  border: 1px solid var(--ink);
  width: min(920px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

/* Tür Rehberi Gerçek Fotoğraf Kartları */
.ref-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.ref-card {
  border: 1px solid var(--rule-strong);
  background: var(--paper-elevated);
  display: flex;
  flex-direction: column;
}

.ref-card img {
  width: 100%;
  height: 184px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--rule);
}

.ref-card-body {
  padding: 10px 12px;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Small Multiples (9 Tür Mini Harita Matrisi) */
.small-multiples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.mini-map-cell {
  border: 1px solid var(--rule-strong);
  background: var(--paper-elevated);
  padding: 8px;
}

.mini-map-cell h4 {
  font-family: var(--font-serif);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* Modern SVG İkonlar */
.ui-ico {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.mobile-fab-bar {
  display: none;
}

/* Mobil ve Tablet Tam Uyum (≤ 960px) */
@media (max-width: 960px) {
  html, body {
    height: 100dvh;
  }
  .atlas-header {
    padding: 6px 10px;
    gap: 6px;
  }
  .atlas-subline, .live-env-strip {
    display: none;
  }
  .header-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .header-nav::-webkit-scrollbar {
    display: none;
  }
  .header-nav .btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .atlas-layout {
    display: block;
    position: relative;
    height: calc(100dvh - 102px);
  }
  .map-canvas-wrap {
    width: 100%;
    height: 100%;
  }
  .editorial-rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 68dvh;
    width: 100%;
    z-index: 60;
    border-right: none;
    border-top: 2px solid var(--ink);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.22);
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  .editorial-rail.mobile-open {
    transform: translateY(0);
  }
  .carto-layer-box {
    display: none;
    width: min(290px, 86vw);
    max-height: 62dvh;
    top: 10px;
    right: 10px;
    z-index: 55;
  }
  .carto-layer-box.mobile-open {
    display: block;
  }
  .mobile-fab-bar {
    display: flex;
    gap: 8px;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 50;
  }
  .mobile-fab-bar .btn {
    min-height: 38px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  .carto-legend-dock {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-width: none;
    font-size: 10.5px;
  }
  .dialog-sheet {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 92dvh !important;
    padding: 14px !important;
  }
  .small-multiples-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr !important;
  }
  .small-multiples-grid {
    grid-template-columns: 1fr;
  }
}

/* Kartografik PDF Çıktı Düzeni */
@media print {
  body {
    overflow: visible !important;
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .header-nav, .carto-layer-box, .dialog-scrim, .pedestrian-overlay {
    display: none !important;
  }
  .atlas-layout {
    display: block !important;
    height: auto !important;
  }
  .map-canvas-wrap {
    height: 380px !important;
    border: 1px solid #000;
    margin-bottom: 16px;
  }
  .editorial-rail, .rail-body {
    width: 100% !important;
    overflow: visible !important;
  }
  .pane {
    display: flex !important;
    page-break-inside: avoid;
  }
}
