/* Palette and chrome follow the Interactive Atlas of Painting (artatlas): warm paper, brown ink. */
:root {
  --bg: #f6f3ee;
  --bar: #ffffff;
  --ink: #241a12;
  --muted: #6f665c;
  --line: #e5e0d6;
  --accent: #7a4a2b;
  --accent-soft: #efe6d6;
  --s0: #ebe5da;   /* no gentilicio */
  --s1: #e6c89c;
  --s2: #c9905a;
  --s3: #8a4f2a;
  --cur: #7b3fb0;  /* curious */
  --ety: #2e6b6b;  /* etymology / history */
  --rose: #b6465f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; height: 100dvh;
}
.muted { color: var(--muted); }

#navbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 5px 12px; background: var(--ink); font-size: 12.5px;
}
#navbar .wordmark { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .2px; white-space: nowrap; }
#navbar .nav-sep { color: #8a7f72; }
#navbar .nav-home { color: #cbbfae; text-decoration: none; white-space: nowrap; }
#navbar a:hover { text-decoration: underline; }
#navbar .build { margin-left: auto; color: #8a7f72; font-size: 6.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* ES · FR · EN picker, same block as in prenoms_francia */
#lang-pick { margin-left: auto; display: inline-flex; gap: 2px; margin-right: 10px; }
#lang-pick button { border: 0; background: rgba(255,255,255,.12); color: #cbbfae; font: inherit; font-size: 10.5px; font-weight: 700;
  letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
#lang-pick button.on { background: #fff; color: #1d1a17; }
#navbar .build { margin-left: 0; }

#bar {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--bar); border-bottom: 1px solid var(--line); z-index: 500;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover strong { text-decoration: underline; }
.brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { color: var(--muted); }
.stats { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; font-size: 13.5px; }
.stats b { color: var(--ink); }

#modes {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 16px; background: #fbf9f5; border-bottom: 1px solid var(--line); z-index: 450;
}
#view-tabs, #colour-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.view-btn, .mode-btn {
  border: 0; background: transparent; padding: 5px 13px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink);
}
.mode-btn { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; padding: 4px 13px; text-align: left; }
.mode-btn b { font-weight: 600; font-size: 13px; }
.mode-btn small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.mode-btn.active small { color: #d8c7a6; }
#colour-modes { border-radius: 14px; }
.view-btn + .view-btn, .mode-btn + .mode-btn { border-left: 1px solid var(--line); }
.view-btn.active, .mode-btn.active { background: #3a2317; color: #fff; }
#filter-wrap { position: relative; margin-left: auto; flex: 0 1 340px; }
#filter { width: 100%; padding: 6px 12px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
#filter:focus { outline: 2px solid #d8c7a6; border-color: #c8b48c; }
#suggest {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 1000; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.16);
  max-height: 60vh; overflow-y: auto; padding: 4px;
}
.sug { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.sug:hover, .sug.on { background: var(--accent-soft); }
.sug .sn { font-weight: 600; }
.sug .ss { color: var(--muted); font-size: 12px; }
.sug mark { background: #f3dfb8; color: inherit; border-radius: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; cursor: pointer; user-select: none; font: inherit; font-size: 13px; color: var(--ink);
}
.chip.btn:hover { background: var(--accent-soft); border-color: #d8c7a6; }
.chip.toggle { position: relative; padding-left: 28px; }
.chip.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.toggle::before {
  content: ""; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border: 1.5px solid #c8b48c; border-radius: 4px; background: #fff;
}
.chip.toggle:has(input:checked) { background: var(--accent-soft); border-color: #d8c7a6; color: #3a2317; font-weight: 600; }
.chip.toggle:has(input:checked)::before { background: #3a2317; border-color: #3a2317; }
.chip.toggle:has(input:checked)::after {
  content: "✓"; position: absolute; left: 11px; top: 50%; transform: translateY(-52%); color: #fff; font-size: 10px; font-weight: 700;
}

#main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
#mapwrap { flex: 1 1 auto; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #dfe7ea; }
#legend {
  position: absolute; left: 10px; bottom: 22px; z-index: 400; background: rgba(255,255,255,.94);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
#legend .lr { display: flex; align-items: center; gap: 7px; margin: 2px 0; }
#legend .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); flex: 0 0 auto; }
#legend .lt { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
#legend .ln { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 10px; }
#go-canarias { position: absolute; left: 10px; top: 80px; z-index: 400; }
.leaflet-tooltip.mt { font: 13px/1.3 system-ui, sans-serif; border-radius: 8px; border-color: var(--line); box-shadow: 0 3px 12px rgba(0,0,0,.14); }
.mt b { display: block; }
.mt i { color: var(--muted); }

#panel {
  flex: 0 0 400px; max-width: 46vw; background: #fff; border-left: 1px solid var(--line);
  overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative;
}
/* close button, as in Batalla de Flores: discreet on a desktop (the panel covers nothing),
   the big red circle on a phone (the ficha covers the whole screen) */
.detail-close {
  display: none; position: sticky; top: 8px; float: right; margin: 8px 10px 0 0; z-index: 5;
  padding: 0; cursor: pointer; line-height: 1;
}
body.has-ficha .detail-close {
  display: block; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--muted); border: 1px solid var(--line); font-size: 14px;
}
body.has-ficha .detail-close:hover { border-color: var(--rose); color: var(--rose); }
.detail-close:active { transform: scale(.94); }
.ficha h2 { padding-right: 36px; }

/* bubble on the map */
.gpop .leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.gpop .leaflet-popup-content { margin: 12px 14px; font: 14px/1.35 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); }
.pop .pn { font-weight: 700; font-size: 16px; }
.pop .pp { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.pop .pg { font-family: Georgia, serif; font-size: 16px; line-height: 1.35; }
.pop .pf { color: #5b4a3c; font-size: 14px; }
.pop .pm { color: var(--muted); font-style: italic; font-family: system-ui, sans-serif; font-size: 13px; }
.pop .pk { font-size: 13px; color: #5b4a3c; margin-top: 4px; }
.pop .pc { font-size: 12px; color: var(--muted); margin: 6px 0 8px; }
.pop .more {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 999px; cursor: pointer;
  background: #3a2317; color: #fff; font: inherit; font-size: 14px; font-weight: 600;
}
.pop .more:hover { background: #5a3a25; }
#panel-body { padding: 16px 18px 40px; }
.intro h2 { font-size: 18px; margin: 0 0 6px; }
.intro p { margin: 6px 0; color: #3d3128; }
.intro .kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0 16px; }
.kpi { background: #fbf9f5; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12px; }
.h3 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.curlist { list-style: none; margin: 0; padding: 0; }
.curlist li { padding: 5px 6px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.curlist li:hover { background: var(--accent-soft); }
.curlist .cn { font-weight: 600; }
.curlist .cg { font-style: italic; color: var(--cur); }
.curlist .cp { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

.simlist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.simlist li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--line); }
.simlist li:first-child { border-top: 0; }
.simlist .sk { flex: 0 0 8.5em; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.simlist .sv { flex: 1; }
.simlist .sv a { color: var(--accent); text-decoration: none; }
.simlist .sv a:hover { text-decoration: underline; }
.simlist .sp, .simlist .sj { color: var(--muted); font-size: 12px; }

.ficha .back { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 0; margin-bottom: 8px; }
.ficha h2 { font-size: 22px; margin: 0; line-height: 1.15; }
.ficha .where { color: var(--muted); margin: 3px 0 8px; }
.ficha .ids { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.ficha .ids a, .ficha .ids span { color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.ficha .ids a:hover { background: var(--accent-soft); }
.form {
  border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; overflow: hidden; background: #fff;
}
.form > summary { list-style: none; cursor: pointer; padding: 8px 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.form > summary::-webkit-details-marker { display: none; }
.form > summary:hover { background: #fbf9f5; }
.form[open] > summary { background: #fbf9f5; border-bottom: 1px solid var(--line); }
.fm { font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-style: italic; }
.ff { font-family: Georgia, serif; font-style: italic; color: #5b4a3c; }
.badge { font-size: 11px; border-radius: 999px; padding: 1px 7px; background: #f1ece3; color: #5b4a3c; white-space: nowrap; }
.badge.cur { background: #efe3f8; color: var(--cur); }
.badge.prin { background: #3a2317; color: #fff; }
.form:has(.badge.prin) { border-color: #c8b48c; }
.badge.lang { background: #e6eef0; color: #2e5561; text-transform: uppercase; letter-spacing: .03em; }
.badge.nsrc { margin-left: auto; background: #3a2317; color: #fff; }
.badge.kind { background: #e3efec; color: var(--ety); }
.claim { padding: 9px 12px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.claim:first-of-type { border-top: 0; }
.claim .src { font-weight: 600; }
.claim .src a { color: var(--accent); }
.claim blockquote {
  margin: 5px 0; padding: 4px 10px; border-left: 3px solid #d8c7a6; color: #3d3128; background: #fbf9f5;
  border-radius: 0 6px 6px 0; white-space: pre-wrap; word-break: break-word;
}
.claim .meta { color: var(--muted); font-size: 11.5px; }
.claim .meta code { font-size: 11px; }
.empty { color: var(--muted); font-style: italic; margin: 6px 0; }
.note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

#table-view { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 1200; }
#table-view[hidden] { display: none; }
#table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 16px; }
#table-scroll { flex: 1 1 auto; overflow: auto; padding: 0 16px 20px; }
#table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
#table th {
  position: sticky; top: 0; background: #fbf9f5; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
#table th.sorted { color: var(--ink); }
#table td { padding: 6px 8px; border-bottom: 1px solid #f0ebe2; vertical-align: top; }
#table tr:hover td { background: #fbf6ee; cursor: pointer; }
#table .num { text-align: right; font-variant-numeric: tabular-nums; }
#table .g { font-family: Georgia, serif; font-style: italic; }
#table .cu { color: var(--cur); }
#t-more { margin: 12px auto; display: block; }

#about-btn { display: none; }
@media (max-width: 760px) {
  /* phone: the map takes the whole screen; the ficha (and "Acerca") open as a full-screen layer */
  #bar { padding: 7px 12px; gap: 4px 10px; }
  .brand strong { font-size: 15px; }
  .brand small { display: none; }
  .stats { margin-left: 0; font-size: 11.5px; flex: 1 1 100%; }
  #modes { padding: 6px 10px; gap: 6px; }
  .view-btn, .mode-btn { padding: 5px 9px; font-size: 12.5px; white-space: nowrap; }
  .mode-btn small { font-size: 9.5px; }
  #colour-modes { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #colour-modes::-webkit-scrollbar { display: none; }
  #about-btn { display: inline-flex; padding: 4px 9px; }
  #filter-wrap { flex: 1 1 100%; margin-left: 0; order: 5; }
  #panel {
    position: fixed; inset: 0; z-index: 2000; max-width: none; border: 0;
    display: none; box-shadow: 0 -8px 40px rgba(34,23,22,.25);
  }
  body.detail-open { overflow: hidden; }
  body.detail-open #panel { display: block; }
  body.detail-open .detail-close {
    display: block; position: sticky; top: 10px; margin: 10px 12px 0 0;
    width: 42px; height: 42px; border-radius: 50%; border: 0;
    background: var(--rose); color: #fff; font-size: 19px; box-shadow: 0 2px 10px rgba(182,70,95,.3);
  }
  #panel-body { padding: 14px 16px 60px; }
  .intro h2, .ficha h2 { padding-right: 50px; }
  #go-canarias { top: auto; bottom: 30px; left: auto; right: 10px; }
  #legend { bottom: 18px; left: 8px; padding: 6px 8px; font-size: 11px; }
  #legend .note { display: none; }
  #table-scroll { padding: 0 6px 20px; }
  #table { font-size: 12.5px; }
  #table th:nth-child(3), #table td:nth-child(3), #table th:nth-child(6), #table td:nth-child(6), #table th:nth-child(9), #table td:nth-child(9) { display: none; }
}

/* language groups inside the ficha: Spanish, other languages of Spain, foreign (folded) */
.lg { margin: 4px 0 10px; }
.lgt { font-size: 12px; font-weight: 600; color: #5b4a3c; margin: 8px 0 2px; }
.lg.co .lgt { color: #2e5561; }
details.lg.fx { margin: 6px 0 10px; }
details.lg.fx > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.h4 { font-size: 11px; font-weight: 600; color: var(--muted); margin: 8px 0 2px; }
details.tech { display: inline; }
details.tech > summary { display: inline; cursor: pointer; color: var(--muted); text-decoration: underline dotted; font-size: 11px; }
details.tech[open] { display: block; margin-top: 3px; font-size: 11px; word-break: break-word; }

/* route box */
#route-box {
  position: absolute; top: 10px; left: 56px; z-index: 900; width: min(340px, calc(100% - 70px));
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.16); max-height: calc(100% - 20px); overflow-y: auto;
}
.rb-row { position: relative; margin-bottom: 6px; }
.rb-row input { width: 100%; padding: 6px 10px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 999px; }
.rb-sug { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.14); max-height: 40vh; overflow-y: auto; padding: 3px; }
.rb-opts { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.rb-x { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; color: var(--muted); }
.rb-res .rb-sum { font-size: 13px; margin: 8px 2px 4px; }
.rb-res .ss, .rb-sug .ss { color: var(--muted); font-size: 11.5px; }
.rb-list { margin: 4px 0 0 20px; padding: 0; font-size: 13px; }
.rb-list li { padding: 2px 0; cursor: pointer; }
.rb-list li:hover .sn { text-decoration: underline; }
.rb-list i { font-family: Georgia, serif; color: #5b4a3c; }
@media (max-width: 760px) { #route-box { left: 8px; right: 8px; width: auto; top: 8px; max-height: 55%; } }
.sub-n { font-weight: 600; margin-right: 4px; }

/* context in the ficha */
.ctx-photo { margin: 8px -18px 8px; max-height: 190px; overflow: hidden; background: #efe9df; }
.ctx-photo img { width: 100%; height: 190px; object-fit: cover; display: block; }
.ctx-head { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 4px; }
.ctx-coat { width: 46px; height: auto; flex: 0 0 auto; }
.ctx-facts { font-size: 13.5px; color: #3d3128; line-height: 1.5; }
.ctx-facts .ss { color: var(--muted); font-size: 12px; }
.srcl { font-size: 10.5px; color: var(--muted); text-decoration: none; vertical-align: super; }
.srcl:hover { text-decoration: underline; }
.ctx-credit { font-size: 10.5px; color: var(--muted); margin: 2px 0 8px; }
.ctx-credit a { color: var(--muted); }
@media (max-width: 760px) { .ctx-photo { margin: 8px -16px; } }
.where a.terr { color: inherit; text-decoration: underline dotted; }
.where a.terr:hover { color: var(--accent); }
.note.warn { background: #fbf3e4; border-left: 3px solid #d9a441; padding: 4px 8px; border-radius: 0 6px 6px 0; color: #5b4a3c; }
.badge.orig { background: #efe3f8; color: #5a2d86; font-style: italic; }
.rb-title { font-weight: 700; font-size: 13.5px; margin: 0 2px 6px; }
.rb-exp { font-weight: 400; color: var(--muted); font-style: italic; }
#route-btn { order: 10; }
#legend .kinds { display: flex; margin-top: 6px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
#legend .kinds button { flex: 1; border: 0; background: #fff; font: inherit; font-size: 11.5px; padding: 3px 6px; cursor: pointer; }
#legend .kinds button + button { border-left: 1px solid var(--line); }
#legend .kinds button.active { background: #3a2317; color: #fff; }
.mt .tk { color: #5b4a3c; font-size: 12px; }
#legend .kinds + .kinds { margin-top: 4px; }
.form > summary .vars { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: -2px; }
.form > summary .vars i { font-family: Georgia, serif; color: #5b4a3c; }

/* population tab: its own accent (blue) so nobody reads it as gentilicio data */
:root { --pop: #1d5687; --pop-soft: #e8f0f5; }
.view-btn.pop.active { background: var(--pop); }
#pop-modes { display: inline-flex; align-items: stretch; border: 1px solid #b9d3e3; border-radius: 14px; overflow: hidden; background: #fff; }
#pop-modes[hidden] { display: none; }
#colour-modes[hidden] { display: none; }
.pop-banner { display: inline-flex; flex-direction: column; justify-content: center; padding: 3px 12px; background: var(--pop); color: #fff; line-height: 1.15; }
.pop-banner b { font-size: 13px; }
.pop-banner small { font-size: 10.5px; color: #cfe0ee; white-space: nowrap; }
.pmode-btn { display: inline-flex; flex-direction: column; align-items: flex-start; border: 0; background: transparent; padding: 4px 12px; font: inherit; cursor: pointer; line-height: 1.15; text-align: left; }
.pmode-btn + .pmode-btn { border-left: 1px solid #dbe7ef; }
.pmode-btn b { font-weight: 600; font-size: 13px; }
.pmode-btn small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.pmode-btn.active { background: var(--pop-soft); }
.pmode-btn.active b { color: var(--pop); }
body.view-pop #navbar { box-shadow: inset 0 -3px 0 var(--pop); }
body.view-pop #legend { border-color: #b9d3e3; }
.pop-flag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--pop); border-radius: 999px; padding: 2px 9px; margin-bottom: 8px; }
.popchart { width: 100%; height: auto; margin: 8px 0; }
.popchart .grid { stroke: #e5e0d6; stroke-width: 1; }
.popchart .ax { font-size: 9.5px; fill: var(--muted); }
.popchart .pad { fill: none; stroke: var(--pop); stroke-width: 2; }
.popchart .cen { fill: var(--pop); }
.popchart .cen.nc { fill: #fff; stroke: #9aa7b0; stroke-width: 1.2; }
.popchart .peak { fill: none; stroke: #b6465f; stroke-width: 2; }
@media (max-width: 760px) { #pop-modes { max-width: 100%; overflow-x: auto; } .pop-banner small { display: none; } }
.ficha.pop .kpis, .intro.pop .kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
