/* CropAtlas Türkiye -- static front end. Light theme only (the map basemap is light). */
:root {
  color-scheme: light;
  --surface-0: #f5f5f2;      /* page */
  --surface-1: #ffffff;      /* cards, chart surface */
  --grid: #e7e6e1;           /* hairline grid / borders */
  --border: #dcdbd5;
  --text-primary: #1a1a18;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2e7d32;         /* brand green = province series */
  --accent-dark: #1b5e20;
  --natl: #6250d6;           /* national reference (violet; CVD-safe vs green, dE 26) */
  --obs: #3d3d3a;            /* observed (prediction tab) */
  --warn: #b26a00;
  --good: #2e7d32;
  --font: "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface-0); color: var(--text-primary); font: 15px/1.45 var(--font); }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; padding-top: env(safe-area-inset-top, 0px); background: var(--surface-1); border-bottom: 1px solid var(--border); }
.brand { font-size: 1.2rem; font-weight: 600; white-space: nowrap; padding: 12px 0; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 14px 10px 12px;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text-primary); }
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.lang { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.lang button { background: var(--surface-1); border: 0; padding: 4px 10px; cursor: pointer; color: var(--text-secondary); }
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---- layout ---- */
main { padding: 16px; }
.boot { padding: 40px; text-align: center; color: var(--text-muted); }
.tab { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.tab#tab-about { grid-template-columns: minmax(0, 1fr); }
.side { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  display: flex; flex-direction: column; gap: 14px; position: sticky; top: 64px; }
.side label, .side fieldset { display: flex; flex-direction: column; gap: 4px; border: 0; margin: 0; padding: 0; }
.side label > span, .side legend, .yearctl .yl { font-size: .85rem; font-weight: 600; color: var(--text-secondary); padding: 0; }
.side select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); }
.radios { display: flex; flex-direction: column; gap: 3px; }
.radios label { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; font-size: .95rem; }
.radios input { accent-color: var(--accent); margin: 0; }
.note { font-size: .8rem; color: var(--text-muted); margin: 0; }
.content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid75 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; }
.about { max-width: 900px; }

/* ---- year control ---- */
.yearctl { display: flex; flex-direction: column; gap: 4px; }
.yearctl .row { display: flex; align-items: center; gap: 8px; }
.yearctl input[type=range] { flex: 1; accent-color: var(--accent); }
.yearctl output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; }
.yearctl .play { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-1);
  cursor: pointer; display: grid; place-items: center; padding: 0; color: var(--accent); }
.yearctl .play:hover { background: var(--surface-0); }

/* ---- cards ---- */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.card-h { padding: 10px 14px; border-bottom: 1px solid var(--grid); font-weight: 600; display: flex; flex-wrap: wrap;
  gap: 4px 10px; align-items: baseline; }
.card-h .sub { font-weight: 400; font-size: .85rem; color: var(--text-muted); }
.card-b { padding: 10px 12px; }
.mapbox { height: 430px; border-radius: 4px; background: #eceae6; }
.mapbox.tall { height: 520px; }
.chart { position: relative; height: 430px; }
.chart.tall { height: 520px; }
.chart.xtall { height: 560px; }
.chart svg { display: block; overflow: visible; }
.chart .msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-muted); padding: 20px; }
.loading { opacity: .45; transition: opacity .15s; }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px;
  border-top: 3px solid var(--accent); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .lab { font-size: .85rem; color: var(--text-secondary); }
.kpi .val { font-size: 1.65rem; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.kpi .val small { font-size: .95rem; font-weight: 400; color: var(--text-secondary); }
.kpi .sub { font-size: .8rem; color: var(--text-muted); }
.kpi.warn { border-top-color: var(--warn); }
.kpi.neutral { border-top-color: var(--text-muted); }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.narr { margin: 0; padding: 12px 14px 12px 32px; }
.narr li { margin: 2px 0; }

/* ---- badges (trends) ---- */
.badges p { margin: 0 0 6px; }
.badge { display: inline-block; background: #ece9fb; color: #3b2fa0; border-radius: 4px; padding: 2px 8px; font-size: .85rem; }

/* ---- chart pieces ---- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .85rem; color: var(--text-secondary); margin: 0 0 4px 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis .ylab { fill: var(--text-secondary); font-size: 12px; }
.grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.lb text { font-size: 12px; fill: var(--text-secondary); }
.lb .val { fill: var(--text-primary); font-variant-numeric: tabular-nums; }
.lb .sel text { fill: var(--text-primary); font-weight: 700; }
.lb g.row { cursor: pointer; }
.lb g.row:hover rect.hit { fill: rgba(0,0,0,.04); }

/* ---- tooltip ---- */
.tip { position: fixed; z-index: 2000; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.12); padding: 6px 9px; font-size: .82rem; min-width: 120px; }
.tip .t { color: var(--text-muted); margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .r em { font-style: normal; color: var(--text-secondary); }

/* ---- map legend ---- */
.cm-legend { background: rgba(255,255,255,.92); padding: 6px 8px; border-radius: 4px; font: 12px/1.3 var(--font);
  box-shadow: 0 0 4px rgba(0,0,0,.2); color: var(--text-primary); }
.cm-legend-title { font-weight: 600; margin-bottom: 4px; max-width: 170px; }
.cm-legend-body { display: flex; gap: 6px; height: 104px; }
.cm-legend-bar { width: 14px; border-radius: 2px; }
.cm-legend-labels { display: flex; flex-direction: column; justify-content: space-between; font-variant-numeric: tabular-nums; }
.cm-legend-na { margin-top: 4px; color: var(--text-secondary); }
.cm-legend-na i { display: inline-block; width: 12px; height: 12px; background: #f0f0f0; border: 1px solid #ccc; margin-right: 4px; vertical-align: -2px; }
.leaflet-container { font-family: var(--font); }

/* ---- table ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--grid); }
.tbl th { text-align: left; color: var(--text-secondary); font-weight: 600; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.best td { font-weight: 600; }

/* ---- about ---- */
.prose { padding: 8px 22px 18px; }
.prose h4 { font-size: 1.35rem; margin: 14px 0 8px; }
.prose h5 { font-size: 1.05rem; margin: 18px 0 6px; }
.prose li { margin: 4px 0; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid75, .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; }
  .brand { padding: 10px 0 0; }
  .tabs { order: 3; flex-basis: 100%; }
  .lang { margin-left: auto; }
  .tab { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .mapbox, .mapbox.tall { height: 380px; }
  .chart, .chart.tall { height: 380px; }
  .chart.xtall { height: 420px; }
  .kpi .val { font-size: 1.35rem; }
}
