@font-face { font-family: "Cormorant Garamond"; font-weight: 500 600; font-style: normal; font-display: swap; src: url(fonts/cormorant.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 500; font-style: italic; font-display: swap; src: url(fonts/cormorant-italic.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400 600; font-style: normal; font-display: swap; src: url(fonts/inter.woff2) format("woff2"); }

:root {
  --paper: #f3ece0;
  --paper-2: #fbf7f0;
  --ink: #2b211a;
  --ink-2: #6b5a4c;
  --sepia: #5b3d2a;
  --accent: #a2482c;
  --line: rgba(43, 33, 26, .14);
  --glass: rgba(251, 247, 240, .9);
  --shadow: 0 10px 30px rgba(40, 25, 10, .18), 0 1px 3px rgba(40, 25, 10, .12);
  --c-parroquia: #8a2f1d;
  --c-convento: #5b3d2a;
  --c-hospital: #2f5d62;
  --c-civil: #7a5a12;
  --c-fuente: #2c5f8a;
  --c-retiro: #4c6b2c;
  --c-puerta: #6a3d6e;
  --c-palacio: #8a2f1d;
  --c-ermita: #5b3d2a;
  --c-calle: #2b211a;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9e1d3; color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

#stage { position: fixed; inset: 0; }
.map { position: absolute; inset: 0; }
#map-now { background: #d9d3c6; }
#map-1656 { background: transparent; will-change: clip-path; }

/* Divider */
#divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 44px; margin-left: -22px; cursor: ew-resize; z-index: 5; touch-action: none; outline: none; }
#divider::before { content: ""; position: absolute; left: 21px; top: 0; bottom: 0; width: 2px; background: var(--paper-2); box-shadow: 0 0 0 1px rgba(43,33,26,.25), 0 0 14px rgba(0,0,0,.25); }
#divider .grip { position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: var(--paper-2); box-shadow: var(--shadow); display: grid; place-items: center; transition: transform .15s; }
#divider .grip svg { width: 22px; height: 22px; fill: none; stroke: var(--sepia); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#divider:hover .grip, #divider.drag .grip, #divider:focus-visible .grip { transform: scale(1.08); }
#divider:focus-visible .grip { box-shadow: var(--shadow), 0 0 0 3px var(--accent); }
body:not(.mode-swipe) #divider { display: none; }

.era { position: absolute; bottom: 64px; z-index: 6; pointer-events: none; font: italic 600 22px/1 var(--serif); letter-spacing: .03em; padding: 6px 12px 7px; border-radius: 999px; box-shadow: var(--shadow); }
.era-old { right: calc(100% - var(--split, 50%) + 14px); color: var(--sepia); background: var(--glass); }
.era-now { left: calc(var(--split, 50%) + 14px); color: var(--paper-2); background: rgba(43,33,26,.78); }
body:not(.mode-swipe) .era { display: none; }

/* Lens */
#lens-ring { position: absolute; z-index: 4; pointer-events: none; border-radius: 50%; border: 2px solid var(--paper-2); box-shadow: 0 0 0 1px rgba(43,33,26,.3), 0 8px 30px rgba(0,0,0,.35); display: none; }
body.mode-lens #lens-ring { display: block; }

/* Header */
#brand { position: fixed; top: 16px; left: 16px; z-index: 10; padding: 12px 18px 12px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 14px; box-shadow: var(--shadow); pointer-events: none; }
#brand h1 { margin: 0; font: 600 28px/1 var(--serif); letter-spacing: .01em; }
#brand h1 span { color: var(--accent); font-style: italic; font-weight: 500; }
#brand p { margin: 4px 0 0; font: italic 500 15px/1.2 var(--serif); color: var(--ink-2); }

/* Tools */
#tools { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.seg { display: flex; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: 13px; color: var(--ink-2); transition: background .15s, color .15s; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--sepia); color: var(--paper-2); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#fade-wrap { display: flex; align-items: center; gap: 8px; background: var(--glass); backdrop-filter: blur(10px); border-radius: 999px; padding: 7px 14px; box-shadow: var(--shadow); font: italic 500 15px var(--serif); color: var(--ink-2); }
#fade-wrap[hidden] { display: none; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 140px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, #9fb0a6, var(--sepia)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--sepia); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--sepia); }

/* Panel */
#panel { position: fixed; top: 112px; left: 16px; bottom: 56px; width: 300px; z-index: 10; display: flex; flex-direction: column; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
#panel.collapsed { bottom: auto; }
#panel-toggle { display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; padding: 12px 16px 8px; font: 600 20px/1 var(--serif); text-align: left; }
#panel-toggle svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 2; transition: transform .2s; }
#panel.collapsed #panel-toggle svg { transform: rotate(-90deg); }
#panel.collapsed #panel-body { display: none; }
#panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#q { margin: 4px 14px 8px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper-2); font: inherit; color: var(--ink); outline: none; }
#q:focus { border-color: var(--sepia); box-shadow: 0 0 0 3px rgba(91,61,42,.12); }
#cats { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
#cats button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
#cats button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
#cats button.off { opacity: .45; text-decoration: line-through; }
#list { list-style: none; margin: 0; padding: 4px 6px; overflow: auto; flex: 1; scrollbar-width: thin; }
#list li { display: grid; grid-template-columns: 38px 1fr; gap: 8px; align-items: baseline; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
#list li:hover, #list li.active { background: rgba(91,61,42,.08); }
#list .r { font: 600 14px/1 var(--serif); color: var(--accent); text-align: right; }
#list .n { font-weight: 500; font-size: 13px; line-height: 1.3; }
#list .t { display: block; font-size: 12px; color: var(--ink-2); margin-top: 1px; }
#list .empty { display: block; color: var(--ink-2); font-style: italic; cursor: default; }
.hint { margin: 0; padding: 8px 16px 12px; font: italic 500 14px/1.3 var(--serif); color: var(--ink-2); border-top: 1px solid var(--line); }

/* Pins */
#pins { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
body.no-pins #pins { display: none; }
.pin { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; border: 0; padding: 0; background: none; }
.pin .dot { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--paper-2); color: var(--c, var(--sepia)); border: 2px solid var(--c, var(--sepia)); font: 600 13px/1 var(--serif); box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .12s; white-space: nowrap; }
.pin:hover .dot, .pin.active .dot { transform: scale(1.18); background: var(--c); color: var(--paper-2); }
.pin.small .dot { min-width: 12px; height: 12px; padding: 0; font-size: 0; border-width: 2px; }
.pin.calle { transform: translate(-50%, -50%); }
.pin.calle .dot { height: auto; padding: 3px 9px 4px; border-radius: 6px; border: 0; background: rgba(43,33,26,.82); color: var(--paper-2); font: italic 500 14px/1.15 var(--serif); }
.pin.calle .dot b { display: block; font: 600 10.5px/1.2 var(--sans); font-style: normal; color: #f2c9a8; letter-spacing: .02em; }
.pin.calle.small .dot { font-size: 0; padding: 0; width: 10px; height: 10px; min-width: 0; border-radius: 2px; transform: rotate(45deg); }
.pin.calle.small .dot b { display: none; }
.pin.hidden { display: none; }

/* Card */
#card { position: fixed; right: 16px; top: 16px; width: 340px; max-width: calc(100vw - 32px); z-index: 12; background: var(--paper-2); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px 16px; border-top: 4px solid var(--c, var(--sepia)); animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
#card .close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 24px; line-height: 1; color: var(--ink-2); padding: 4px 8px; border-radius: 6px; }
#card .close:hover { background: rgba(0,0,0,.05); }
#card .ref { font: 600 12px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--c, var(--accent)); }
#card h2 { margin: 6px 28px 12px 0; font: 600 24px/1.1 var(--serif); }
#card .row { display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
#card .row span { font: italic 600 16px/1.3 var(--serif); color: var(--ink-2); }
#card .row p { margin: 0; }
#card .status { margin-top: 8px; display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
#card .status.conserva { background: #e3eedc; color: #3f6129; }
#card .status.transformado { background: #f5ead2; color: #7a5a12; }
#card .status.desaparecido { background: #f3dfd8; color: #8a2f1d; }

/* Attribution */
#attrib { position: fixed; right: 12px; bottom: 10px; z-index: 10; font-size: 11.5px; color: var(--ink-2); background: var(--glass); padding: 5px 10px; border-radius: 8px; backdrop-filter: blur(8px); max-width: calc(100vw - 24px); }
#attrib a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.maplibregl-ctrl-bottom-right { bottom: 34px; }
.maplibregl-ctrl-group { border-radius: 10px !important; box-shadow: var(--shadow) !important; background: var(--glass) !important; }
.maplibregl-ctrl-attrib { display: none; }

/* Mobile */
@media (max-width: 760px) {
  #brand { top: 10px; left: 10px; right: 10px; padding: 8px 12px; text-align: center; }
  #brand h1 { font-size: 22px; }
  #brand p { font-size: 13px; }
  #tools { top: 76px; width: calc(100% - 20px); gap: 6px; }
  .seg button { padding: 6px 10px; font-size: 12px; }
  #panel { top: auto; left: 10px; right: 10px; bottom: 44px; width: auto; max-height: 46vh; }
  #panel.collapsed { max-height: none; }
  #card { top: auto; bottom: 44px; left: 10px; right: 10px; width: auto; max-height: 55vh; overflow: auto; }
  .era { font-size: 17px; bottom: auto; top: 168px; }
  #panel.collapsed { top: auto; bottom: 52px; }
  .seg.zoom { display: none !important; }
  #attrib { left: 10px; right: 10px; bottom: 6px; font-size: 10.5px; text-align: center; }
  .maplibregl-ctrl-top-right { top: 150px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
