/* Patrimoni: el catàleg i el mapa comparteixen un sol espai d'exploració. */
.heritage-page .capcal { padding-block: 56px 52px; }
.heritage-page .capcal > .wrap { grid-template-columns: 1.3fr 1fr; gap: 72px; }
.heritage-page .capcal .title { font-size: clamp(2.5rem, 4vw, 3.75rem); max-width: 19ch; }
.heritage-page .capcal .lead { max-width: 49ch; margin-top: 24px; }
.heritage-page .capcal-foto img { aspect-ratio: 2; }
.heritage-page .capcal-foto figcaption { max-width: 48ch; }
.heritage-explorer { padding-bottom: 80px; }
.heritage-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 44px; align-items: start; border-top: 1px solid var(--rule); padding-top: 28px; }
.heritage-sidebar { position: sticky; top: calc(var(--bar) + 28px); min-width: 0; }
.heritage-label { font: 400 .6875rem/1.5 var(--sans); color: var(--ink-2); margin: 12px 12px 18px; }
.heritage-categories { display: grid; gap: 6px; }
.heritage-category { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; border: 0; padding: 12px; background: transparent; color: var(--ink-2); border-radius: 8px; text-align: left; font: 400 .8125rem/1.5 var(--sans); cursor: pointer; transition: background .18s, color .18s; }
.heritage-category:hover { background: var(--paper-2); color: var(--ink); }
.heritage-category[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 500; }
.heritage-category-count { font-size: .6875rem; font-variant-numeric: tabular-nums; }
.heritage-category:first-child { margin-bottom: 12px; }
.heritage-results { min-width: 0; }
.heritage-tools { position: sticky; top: var(--bar); z-index: 15; display: flex; align-items: center; gap: 16px; padding-block: 12px; margin-top: -12px; background: var(--paper); }
.heritage-search { position: relative; display: flex; flex: 1; min-width: 0; }
.heritage-search > svg { position: absolute; left: 16px; top: 16px; width: 18px; height: 18px; stroke: var(--ink-2); stroke-width: 1.5; pointer-events: none; }
.heritage-search .camp { width: 100%; max-width: none; padding: 13px 14px 13px 44px; min-height: 50px; font-size: 16px; }
.heritage-views { display: flex; flex-shrink: 0; gap: 2px; padding: 3px; border-radius: 9px; background: var(--paper-2); border: 1px solid var(--rule); }
.heritage-views button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; min-height: 44px; background: transparent; border: 0; border-radius: 6px; color: var(--ink-2); font: 500 .8125rem var(--sans); cursor: pointer; }
.heritage-views button[aria-pressed="true"] { background: var(--sup); color: var(--ink); box-shadow: 0 1px 4px #0001; }
.heritage-views svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.heritage-change { display: none; }
.heritage-result-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; padding-block: 24px; }
.heritage-result-heading h2 { font: 500 1.25rem/1.4 var(--sans); letter-spacing: -.025em; margin: 0; }
[data-heritage-count] { font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.heritage-result-heading .filter-reset { margin: -12px 0 -12px auto; }
.heritage-subtypes { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 24px; }
.heritage-subtype { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--ink-2); font: .75rem/1.4 var(--sans); cursor: pointer; }
.heritage-subtype > span { font-size: .6875rem; font-variant-numeric: tabular-nums; }
.heritage-subtype:hover { border-color: var(--ink-2); }
.heritage-subtype[aria-pressed="true"] { background: var(--paper-2); color: var(--ink); border-color: var(--ink-2); }
.heritage-page .fitxes[data-vista="patrimoni"] { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 0; gap: 44px 24px; }
.heritage-page .patrimoni-card-category { line-height: 1.6; }
.heritage-page .patrimoni-card h2 { font-size: 1.1875rem; }
.heritage-page .patrimoni-card p { margin-top: 12px; }
.heritage-page .catalogue-credit { max-width: none; margin-top: 48px; }
.heritage-map-note, .heritage-map-status { font-size: .8125rem; line-height: 1.7; color: var(--ink-2); margin: 0 0 20px; max-width: 72ch; }
.heritage-map-status:empty { display: none; }
.heritage-map-empty { padding: 40px 28px; background: var(--paper-2); border-radius: 8px; }
.heritage-map-empty h3 { font: 500 1.25rem/1.4 var(--sans); margin: 0 0 12px; }
.heritage-map-empty p { font: .875rem/1.75 var(--sans); color: var(--ink-2); max-width: 56ch; margin: 0; }
.heritage-map-empty .btn { margin-top: 24px; }
.heritage-map .mapa-graella { grid-template-columns: 1fr; }
.heritage-map .mapa-caixa { height: clamp(440px, 62svh, 680px); min-width: 0; }
.heritage-map .mapa-punt.fora { visibility: hidden; }
.heritage-map .mapa-nota { max-width: none; font-size: .5625rem; padding: 10px 12px; border-radius: 0 0 8px 8px; }
.heritage-map-places { margin-top: 20px; border-block: 1px solid var(--rule); }
.heritage-map-places > summary { display: flex; align-items: center; gap: 12px; list-style: none; min-height: 56px; padding-block: 16px; font-size: .8125rem; cursor: pointer; }
.heritage-map-places > summary::-webkit-details-marker { display: none; }
.heritage-map-places [data-recompte-mapa] { color: var(--ink-2); font-size: .6875rem; }
.heritage-chevron { margin-left: auto; transition: transform .2s; }
.heritage-map-places[open] .heritage-chevron { transform: rotate(180deg); }
.heritage-map-places .mapa-llista { max-height: 340px; margin: 0 0 20px; }
.heritage-page [hidden] { display: none !important; }
#categories, #explora { scroll-margin-top: 24px; }
.heritage-results { scroll-margin-top: 0; }
@media (min-width: 1440px) { .heritage-page .fitxes[data-vista="patrimoni"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) {
  .heritage-page .capcal > .wrap { gap: 40px; }
  .heritage-layout { grid-template-columns: 180px minmax(0, 1fr); gap: 28px; }
  .heritage-tools { gap: 12px; }
  .heritage-views button { padding-inline: 10px; }
  .heritage-views svg { display: none; }
}
@media (max-width: 760px) {
  .heritage-page .capcal { padding-block: 32px 24px; }
  .heritage-page .capcal > .wrap { grid-template-columns: 1fr; }
  .heritage-page .capcal .eyebrow { margin-bottom: 18px; }
  .heritage-page .capcal .title { font-size: clamp(2rem, 8.5vw, 3rem); max-width: 20ch; }
  .heritage-page .capcal .lead { margin-top: 16px; font-size: .9375rem; line-height: 1.75; }
  .heritage-page .capcal-foto { display: none; }
  .heritage-layout { display: block; padding-top: 16px; }
  .heritage-sidebar { position: static; margin-bottom: 20px; }
  .heritage-label { margin: 0 0 8px; }
  .heritage-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
  .heritage-category { min-height: 44px; font-size: .75rem; gap: 6px; padding: 10px 12px; border: 1px solid var(--rule); }
  .heritage-category:first-child { grid-column: 1 / -1; margin-bottom: 0; }
  .heritage-tools { flex-wrap: wrap; gap: 6px; padding-block: 8px; margin-top: 0; border-bottom: 1px solid var(--rule); }
  .heritage-search { flex-basis: 100%; }
  .heritage-views button { min-width: 78px; }
  .heritage-views svg { display: block; }
  .heritage-change { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-left: auto; font-size: .75rem; text-decoration: underline; text-underline-offset: 4px; }
  .heritage-result-heading { gap: 8px 12px; padding-block: 20px 16px; }
  .heritage-result-heading h2 { font-size: 1.125rem; }
  .heritage-result-heading .filter-reset { font-size: .75rem; }
  .heritage-subtypes { gap: 6px; padding-bottom: 20px; }
  .heritage-subtype { padding-inline: 12px; }
  .heritage-map .mapa-caixa { height: clamp(420px, 58svh, 560px); }
  .heritage-map .mapa-eines { top: 12px; right: 12px; }
  .heritage-map-note { font-size: .75rem; }
  .heritage-explorer { padding-bottom: 48px; }
}
@media (max-width: 480px) {
  .heritage-page .fitxes[data-vista="patrimoni"] { grid-template-columns: 1fr; gap: 36px; }
  .heritage-page .patrimoni-card h2 { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) { .heritage-category, .heritage-chevron { transition: none; } }
@media print { .heritage-sidebar, .heritage-tools, .heritage-subtypes, .heritage-result-heading .filter-reset { display: none; } .heritage-layout { display: block; } }

/* Una superfície estable: controls, mapa i ajuda tenen el seu espai. */
.heritage-map .map-workspace { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.map-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.map-topline > p { font: .6875rem/1.5 var(--sans); color: var(--ink-2); margin: 0; font-variant-numeric: tabular-nums; }
.map-top-actions { display: flex; flex-shrink: 0; gap: 8px; }
.map-top-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; color: var(--ink); background: var(--paper); font: .75rem/1.4 var(--sans); cursor: pointer; }
.map-top-actions button:hover { background: var(--paper-2); border-color: var(--rule-2); }
.map-top-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.heritage-map .mapa-caixa { border-radius: 10px; isolation: isolate; }
.heritage-map .mapa { border: 0; border-radius: 0; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.heritage-map .mapa:focus-visible { outline: 2px solid var(--foix); outline-offset: -3px; }
.heritage-map .mapa-terme { stroke: var(--ink-3); stroke-opacity: .4; fill: light-dark(#edece5,#171b18); }
.heritage-map .amb-satelit .mapa-terme { fill:none;stroke:#fff;stroke-opacity:.6; }
.heritage-map .mapa-cami-0 { stroke:light-dark(#b1afa5,#69736a);opacity:.55; }
.heritage-map .mapa-cami-1 { stroke:light-dark(#a3a194,#8a9187);opacity:.8; }
.heritage-map .mapa-cami-2 { stroke:light-dark(#8c8b7e,#a0a699);opacity:.9; }
.heritage-map .amb-satelit .mapa-cami { stroke:#fff;opacity:.55; }
.map-road-label { fill:var(--ink-2);stroke:light-dark(#edece5,#171b18);stroke-width:calc(3px * var(--escala,1));paint-order:stroke;stroke-linejoin:round;font:400 calc(10px * var(--escala,1))/1 var(--sans);pointer-events:none; }
.heritage-map .mapa-aigua { opacity: .6; }
.heritage-map .mapa-lloc text { font-size: calc(11px * var(--escala,1)); stroke-width: calc(3px * var(--escala,1)); }
.heritage-map .mapa-lloc circle { r: calc(2px * var(--escala,1)); }
.heritage-map .mapa-lloc { pointer-events: none; }
.map-marker { cursor: pointer; outline: none; }
.map-marker-hit { fill: transparent; pointer-events: all; }
.map-marker-dot { fill: var(--marker-color); stroke: var(--paper); }
.map-marker text { fill: var(--paper); font-family: var(--sans); font-weight: 600; pointer-events: none; }
.map-marker .map-place-label { fill: var(--ink); font-weight: 400; stroke: var(--paper-2); stroke-width: calc(3px * var(--escala,1)); paint-order: stroke; pointer-events: visiblePainted; }
.amb-satelit .map-marker .map-place-label { fill: #fff; stroke: #17251ecc; }
.map-marker:hover .map-marker-dot, .map-marker:focus-visible .map-marker-dot, .map-marker.is-selected .map-marker-dot { stroke: var(--ink); stroke-width: calc(3px * var(--escala,1)); }
.map-marker:focus-visible .map-marker-hit { fill: var(--foix-soft); fill-opacity: .65; }
.heritage-map .mapa-eines { top: 12px; right: 12px; gap: 0; }
.heritage-map .mapa-eina { width: 44px; height: 44px; border-radius: 8px; box-shadow: none; background: var(--paper); }
.heritage-map .mapa-eina:nth-child(1) { border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.heritage-map .mapa-eina:nth-child(2) { border-radius: 0 0 8px 8px; }
.heritage-map .mapa-eina:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.heritage-map .mapa-eina-ample { width: auto; margin-top: 8px; height: 44px; font-size: .6875rem; }
.map-zoom-level { width: 44px; padding: 6px 0; text-align: center; color: var(--ink-2); font: .625rem/1.5 var(--sans); font-variant-numeric: tabular-nums; pointer-events: none; }
.heritage-map .capes-mapa { top: 12px; left: 12px; }
.heritage-map .capes-obre { background: var(--paper); border-radius: 8px; box-shadow: none; }
.heritage-map .capes-panell { max-height: min(360px, calc(58svh - 80px)); overflow-y: auto; background: var(--paper); overscroll-behavior: contain; }
.heritage-map .capes-fons span, .heritage-map .capa-sobre { min-height: 44px; display: flex; align-items: center; }
.heritage-map .capes-fons span { justify-content: center; }
.heritage-map .mapa-globus { max-width: min(270px, calc(100% - 16px)); white-space: normal; background: var(--paper); z-index: 4; }
.heritage-map .map-place-card { top: auto; left: 12px; bottom: 12px; width: min(520px, calc(100% - 130px)); max-width: none; max-height: 196px; padding: 16px; display: flex; align-items: flex-start; gap: 16px; border-radius: 10px; background: var(--paper); box-shadow: 0 6px 28px #0002; animation: none; }
.map-place-photo { flex: 0 0 96px; width: 96px; height: 96px; object-fit: cover; border-radius: 6px; }
.map-place-content { min-width: 0; flex: 1; }
.map-place-card h3 { font: 500 1.0625rem/1.35 var(--sans); letter-spacing: -.02em; padding-right: 28px; margin: 4px 0 8px; }
.map-place-category { padding-right: 26px; color: var(--ink-2); font: .625rem/1.5 var(--sans); margin: 0; }
.map-place-description { font: .75rem/1.65 var(--sans); color: var(--ink-2); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.map-place-link { display: inline-flex; align-items: center; gap: 16px; min-height: 44px; font: 500 .75rem/1.4 var(--sans); text-decoration: underline; text-underline-offset: 4px; }
.map-place-card .fitxa-mapa-tanca { top: 4px; right: 4px; min-height: 44px; min-width: 44px; }
.map-coincident { list-style: none; margin: 8px 0 0; padding: 0; max-height: 128px; overflow-y: auto; }
.map-coincident button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 0; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--rule); font: .8125rem/1.5 var(--sans); text-align: left; cursor: pointer; }
.map-gesture-hint { position: absolute; z-index: 8; left: 50%; top: 46%; transform: translate(-50%,-50%); margin: 0; max-width: calc(100% - 32px); width: max-content; padding: 14px 18px; font: .8125rem/1.6 var(--sans); background: var(--ink); color: var(--paper); border-radius: 8px; text-align: center; pointer-events: none; }
.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 14px; }
.map-instructions { margin: 0; max-width: 72ch; color: var(--ink-2); font: .6875rem/1.65 var(--sans); }
.map-scale { display: flex; align-items: center; flex-direction: column; gap: 4px; flex-shrink: 0; color: var(--ink-2); font: .625rem/1.4 var(--sans); }
[data-map-scale-line] { display: block; height: 5px; border: 1px solid currentColor; border-top: 0; }
.map-source { margin: 12px 0 0; font: .5625rem/1.7 var(--sans); color: var(--ink-2); }
.map-source a { text-decoration: underline; text-underline-offset: 2px; }
.map-tile-status { font: .75rem/1.6 var(--sans); color: var(--ink-2); padding: 14px 16px; background: var(--paper-2); border-radius: 8px; }
.map-legend { margin-top: 16px; font: .75rem/1.6 var(--sans); }
.map-legend summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 10px; color: var(--ink-2); list-style: none; }
.map-legend summary::-webkit-details-marker { display: none; }
.map-legend summary::after { content: '+'; }
.map-legend[open] summary::after { content: '−'; }
.map-legend ul { display: flex; flex-wrap: wrap; gap: 12px 24px; list-style: none; padding: 4px 0 16px; margin: 0; }
.map-legend li { display: inline-flex; align-items: center; gap: 8px; font-size: .6875rem; color: var(--ink-2); }
.map-legend li > span { height: 8px; width: 8px; border-radius: 50%; }
.heritage-map-places { margin-top: 8px; }
.heritage-map .mapa-llista button.fila { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; font: inherit; cursor: pointer; }
.heritage-map .mapa-llista button.fila:hover, .heritage-map .mapa-llista button.fila.triat { background: var(--paper-2); }
.heritage-map .mapa-llista .fila-text { flex: 1; }
.map-focus:not([open]) { display: none; }
.map-focus[open] { position: fixed; inset: 0; max-width: none; max-height: none; width: 100%; height: 100dvh; margin: 0; padding: 20px 28px; border: 0; background: var(--paper); color: var(--ink); overflow: hidden; }
.map-focus::backdrop { background: var(--paper); }
.map-focus .map-workspace { width: 100%; max-width: none; height: 100%; }
.map-focus .mapa-caixa { flex: 1 1 auto; height: auto; min-height: 160px; }
.map-focus .mapa { touch-action: none; }
.map-focus .heritage-map-places, .map-focus .map-legend { display: none; }
.map-focus .map-source { margin-top: 8px; }
@media (max-width: 760px) {
  .map-topline { flex-wrap: wrap; gap: 8px; }
  .map-topline > p { flex-basis: 100%; }
  .map-top-actions { width: 100%; }
  .map-top-actions button { flex: 1; padding-inline: 10px; font-size: .6875rem; }
  .map-top-actions svg { width: 16px; height: 16px; }
  .heritage-map .map-place-card { left: 8px; bottom: 8px; width: calc(100% - 16px); padding: 12px; gap: 12px; max-height: 180px; }
  .map-place-photo { flex-basis: 64px; width: 64px; height: 76px; }
  .map-place-description { display: none; }
  .map-place-card h3 { font-size: .9375rem; margin-bottom: 0; padding-right: 24px; }
  .map-place-category { font-size: .5625rem; }
  .map-place-link { font-size: .6875rem; }
  .map-footer { gap: 12px; align-items: flex-start; }
  .map-instructions { font-size: .625rem; }
  .map-source { font-size: .5625rem; }
  .map-focus[open] { padding: 12px; }
  .map-focus .map-topline { flex-shrink: 0; }
  .map-focus .map-source { font-size: .5rem; }
}

.map-focus :is(.map-topline,.map-footer,.map-source,.map-tile-status) { flex-shrink:0; }
