/* colori di base del webgis Enogis: la view li sovrascrive con PublicWebGisView.theme (--wp-<nome>) */
:root {
    --wp-primary: #1ca1c1;
    --wp-primary-contrast: #ffffff;
    --wp-text: #333333;
    --wp-muted: #777777;
    --wp-bg: #ffffff;
    --wp-bg-alt: #f4f5f9;
    --wp-border: #dddddd;
    --wp-radius: 4px;
    --wp-shadow: 0 1px 6px rgba(0, 0, 0, .25);
    --wp-font: "Helvetica Neue", Arial, Helvetica, sans-serif;
    --wp-title-font: var(--wp-font);
    --wp-logo-height: 22px;  /* un emblema tondo vuole piu' altezza di un logo orizzontale */
    --wp-panel-width: 250px;  /* livelli e legenda: il progetto la adatta ai nomi dei suoi layer */
    --wp-layers-width: var(--wp-panel-width);  /* i soli livelli, quando i loro nomi sono piu' corti della legenda */
}

html, body.wp-body { height: 100%; margin: 0; }
.wp-map { width: 100%; height: 100vh; height: 100dvh; font: 13px/1.4 var(--wp-font); color: var(--wp-text); background: var(--wp-bg-alt); }

/* ########## controlli Leaflet con il tema ########## */
.wp-map .leaflet-bar,
.wp-map .leaflet-control-layers,
.wp-map .leaflet-popup-content-wrapper { border: 0; border-radius: var(--wp-radius); box-shadow: var(--wp-shadow); }
.wp-map .leaflet-bar a { color: var(--wp-text); background-color: var(--wp-bg); border-bottom-color: var(--wp-border); }
.wp-map .leaflet-bar a:hover, .wp-map .leaflet-bar a:focus { color: var(--wp-primary); background-color: var(--wp-bg-alt); }
.wp-map .leaflet-bar a:first-child { border-top-left-radius: var(--wp-radius); border-top-right-radius: var(--wp-radius); }
.wp-map .leaflet-bar a:last-child { border-bottom-left-radius: var(--wp-radius); border-bottom-right-radius: var(--wp-radius); }
.wp-map a { color: var(--wp-primary); }
.wp-tools a { display: flex; align-items: center; justify-content: center; }

/* livelli con l'intestazione e la larghezza della legenda */
.wp-map .leaflet-control-layers.wp-layers { width: var(--wp-layers-width); max-width: calc(100vw - 20px); padding: 0; color: var(--wp-text); background: var(--wp-bg); }
.wp-map .wp-layers .leaflet-control-layers-list { max-height: 45vh; overflow-y: auto; padding: 6px 12px 8px 8px; border-top: 1px solid var(--wp-border); }
.wp-map .wp-layers.wp-collapsed .leaflet-control-layers-list { display: none; }
.wp-map .leaflet-control-layers label { display: flex; align-items: center; gap: 2px; font-size: 13px; padding: 2px 0; }
.wp-map .leaflet-control-layers-group-name { display: block; margin: 4px 0 2px 3px; color: var(--wp-muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.wp-map .leaflet-control-layers-selector { accent-color: var(--wp-primary); }
.wp-filter-btn { display: inline-flex; margin-left: 6px; padding: 3px; border: 1px solid var(--wp-border); border-radius: var(--wp-radius); background: var(--wp-bg); color: var(--wp-muted); cursor: pointer; }
.wp-filter-btn:hover, .wp-filter-btn:focus { color: var(--wp-primary); border-color: var(--wp-primary); }

.wp-map .leaflet-control-attribution { background: rgba(255, 255, 255, .85); color: var(--wp-muted); }

/* basi in miniatura: le icone del plugin sono di 80 px */
.wp-map .leaflet-iconLayers-layer { width: 56px; height: 56px; border-radius: var(--wp-radius); box-shadow: var(--wp-shadow); overflow: hidden; }
.wp-map .leaflet-iconLayers-layerCell:focus-visible { outline: 2px solid var(--wp-primary); outline-offset: 2px; }
.wp-map .leaflet-iconLayers-layerTitleContainer { height: 34%; background: rgba(255, 255, 255, .85); font-size: 10px; }

.wp-map .leaflet-popup-content-wrapper { background: var(--wp-bg); color: var(--wp-text); }
.wp-map .leaflet-popup-content { margin: 12px 16px; font: 13px/1.4 var(--wp-font); }

/* ########## testata ########## */
.wp-brand { max-width: min(560px, calc(100vw - 90px)); overflow: hidden; background: var(--wp-bg); border-top: 3px solid var(--wp-primary); border-radius: var(--wp-radius); box-shadow: var(--wp-shadow); }
.wp-brand-main { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.wp-brand-logo { display: block; flex: none; max-height: var(--wp-logo-height); max-width: 140px; }
.wp-brand-text { min-width: 0; }
.wp-brand-text:not(:first-child), .wp-brand-partner { padding-left: 12px; border-left: 1px solid var(--wp-border); }
.wp-brand-title { margin: 0; color: var(--wp-primary); font: 400 16px/1.2 var(--wp-title-font); letter-spacing: .01em; white-space: pre-line; }  /* a capo del titolo nella view */
.wp-brand-enogis { display: block; width: max-content; }
.wp-brand-enogis img { display: block; height: 26px; }
.wp-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wp-brand-subtitle { margin-top: 2px; color: var(--wp-muted); font-size: 11px; line-height: 1.3; }
.wp-annata { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 14px; background: var(--wp-bg-alt); border-top: 1px solid var(--wp-border); }
.wp-annata-label { color: var(--wp-muted); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.wp-segmented { display: inline-flex; overflow: hidden; background: var(--wp-bg); border: 1px solid var(--wp-border); border-radius: var(--wp-radius); }
.wp-segmented button { padding: 3px 11px; border: 0; background: none; color: var(--wp-text); font: 600 12px/1.3 var(--wp-font); font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color .15s, color .15s; }
.wp-segmented button + button { border-left: 1px solid var(--wp-border); }
.wp-segmented button:hover { color: var(--wp-primary); }
.wp-segmented button:focus-visible { outline: 2px solid var(--wp-primary); outline-offset: -2px; }
.wp-segmented button.wp-active { background: var(--wp-primary); color: var(--wp-primary-contrast); cursor: default; }

.wp-map select { padding: 3px 6px; border: 1px solid var(--wp-border); border-radius: var(--wp-radius); background: var(--wp-bg); color: var(--wp-text); font: inherit; }
.wp-map select:focus { outline: 2px solid var(--wp-primary); outline-offset: 0; }

/* il sottotitolo solo dove la mappa ha spazio */
@media (max-width: 1279px), (max-height: 799px) { .wp-brand-subtitle { display: none; } }

/* ########## legenda unica ########## */
.wp-legend { width: var(--wp-panel-width); max-width: calc(100vw - 20px); background: var(--wp-bg); border-radius: var(--wp-radius); box-shadow: var(--wp-shadow); }
.wp-panel-head { display: flex; width: 100%; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px; border: 0; background: none; color: var(--wp-primary); font: 600 12px var(--wp-font); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.wp-arrow::after { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-bottom: 3px; }
.wp-collapsed .wp-arrow::after { transform: rotate(-135deg); margin-bottom: -3px; }
/* l'altezza massima la calcola fitLegend sullo spazio libero sotto i livelli */
.wp-legend-body { overflow-y: auto; padding: 0 12px 8px; border-top: 1px solid var(--wp-border); }
.wp-collapsed .wp-legend-body { display: none; }
.wp-legend-section { padding: 8px 0; }
.wp-legend-section + .wp-legend-section { border-top: 1px solid var(--wp-border); }
.wp-legend-title { display: flex; width: 100%; align-items: center; gap: 6px; margin-bottom: 4px; padding: 0; border: 0; background: none; color: inherit; font: 600 13px/1.4 var(--wp-font); text-align: left; }
button.wp-legend-title { cursor: pointer; }
button.wp-legend-title:hover .wp-legend-name, button.wp-legend-title:focus-visible .wp-legend-name { color: var(--wp-primary); }
.wp-legend-name { flex: 1 1 auto; min-width: 0; }
.wp-legend-title .wp-arrow { flex: none; color: var(--wp-muted); }
.wp-legend-section.wp-collapsed .wp-legend-title { margin-bottom: 0; }
.wp-legend-section.wp-collapsed .wp-legend-content { display: none; }
.wp-badge { padding: 0 6px; border-radius: 9px; background: var(--wp-primary); color: var(--wp-primary-contrast); font-size: 10px; font-weight: 400; }
.wp-legend-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.wp-legend-row img, .wp-swatch { flex: none; width: 16px; height: 16px; }
.wp-opacity { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; color: var(--wp-muted); font-size: 11px; }
.wp-opacity input { flex: 1; accent-color: var(--wp-primary); }
.wp-legend-hint { margin: 2px 0 6px; padding: 4px 8px; border-left: 3px solid var(--wp-primary); background: var(--wp-bg-alt); color: var(--wp-text); font-size: 11px; }
.wp-metric { width: 100%; margin: 2px 0 4px; }

/* ########## avvisi ########## */
.wp-notice { position: absolute; top: 10px; left: 50%; z-index: 1100; max-width: calc(100% - 40px); padding: 8px 14px; transform: translateX(-50%); background: var(--wp-bg); color: var(--wp-text); border-left: 3px solid var(--wp-primary); border-radius: var(--wp-radius); box-shadow: var(--wp-shadow); }

/* ########## filtro ########## */
.wp-backdrop { position: absolute; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .35); }
.wp-dialog { display: flex; flex-direction: column; max-width: 92%; max-height: 86%; background: var(--wp-bg); border-radius: var(--wp-radius); box-shadow: 0 6px 30px rgba(0, 0, 0, .35); }
.wp-filter { width: 1100px; }
.wp-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--wp-border); color: var(--wp-primary); font: 600 15px var(--wp-title-font); }
.wp-close { border: 0; background: none; color: var(--wp-muted); font-size: 22px; line-height: 1; cursor: pointer; }
.wp-filter-body { flex: 1 1 auto; min-height: 0; padding: 12px 16px; overflow: auto; column-gap: 20px; }
.wp-filter-group { break-inside: avoid; margin-bottom: 10px; }
.wp-filter-group-title, .wp-filter-item { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wp-filter-group-title { font-weight: 600; }
.wp-filter-item { padding-left: 20px; }
.wp-filter input[type=checkbox] { accent-color: var(--wp-primary); }
.wp-filter img { width: 12px; height: 12px; }
.wp-filter-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--wp-border); }
.wp-button { padding: 6px 14px; border: 1px solid var(--wp-border); border-radius: var(--wp-radius); background: var(--wp-bg); color: var(--wp-text); font: inherit; cursor: pointer; }
.wp-button:hover, .wp-button:focus { border-color: var(--wp-primary); color: var(--wp-primary); }
.wp-button.wp-primary { border-color: var(--wp-primary); background: var(--wp-primary); color: var(--wp-primary-contrast); }

/* ########## schede ########## */
.wp-info-title { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--wp-primary); color: var(--wp-primary); font: 700 17px/1.25 var(--wp-title-font); }
.wp-info-title small { display: block; margin-bottom: 1px; color: var(--wp-muted); font: 600 10px/1.4 var(--wp-font); letter-spacing: .08em; text-transform: uppercase; }
.wp-info { border-collapse: collapse; }
.wp-info-list { margin: 0 0 8px; padding: 0; list-style: none; }
.wp-info-list li { padding: 2px 0; }
.wp-info-list li + li { border-top: 1px solid var(--wp-border); }
.wp-info-section + .wp-info-section { margin-top: 8px; }
.wp-info-head { margin-bottom: 4px; color: var(--wp-muted); font: 600 10px/1.4 var(--wp-font); letter-spacing: .08em; text-transform: uppercase; }
.wp-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.wp-chip { padding: 2px 8px; border: 1px solid var(--wp-border); border-left: 3px solid var(--wp-primary); border-radius: var(--wp-radius); background: var(--wp-bg-alt); }
.wp-info th, .wp-info td { padding: 3px 0; text-align: left; vertical-align: top; }
.wp-info th { padding-right: 12px; color: var(--wp-muted); font-weight: 400; }
.wp-info tr + tr th, .wp-info tr + tr td { border-top: 1px solid var(--wp-border); }
.wp-chart { display: block; width: 600px; max-width: 100%; height: 460px; max-height: calc(100vh - 120px); border: 0; }

/* ########## schermi piccoli e iframe bassi ########## */
@media (max-width: 700px), (max-height: 520px) {
    .wp-brand-main { gap: 10px; padding: 6px 10px; }
    .wp-brand-logo { max-height: calc(var(--wp-logo-height) * .9); max-width: 110px; }
    .wp-brand-text:not(:first-child), .wp-brand-partner { padding-left: 10px; }
    /* con piu' loghi affiancati la testata deve restare a sinistra del pulsante dei livelli */
    .wp-brand:has(.wp-brand-partner) { max-width: calc(100vw - 120px); }
    .wp-brand-main:has(.wp-brand-partner) { gap: 8px; padding: 6px 8px; }
    .wp-brand-main:has(.wp-brand-partner) .wp-brand-logo { max-width: 72px; }
    .wp-brand-main:has(.wp-brand-partner) .wp-brand-partner, .wp-brand-main:has(.wp-brand-partner) .wp-brand-text { padding-left: 8px; }
    .wp-brand-main:has(.wp-brand-partner) .wp-brand-enogis img { height: 17px; }
    .wp-brand-title { font-size: 14px; }
    .wp-brand-subtitle { display: none; }
    .wp-annata { padding: 4px 10px; }
    .wp-brand-enogis img { height: 20px; }
    .wp-segmented button { padding: 3px 9px; }
    .wp-legend.wp-collapsed, .wp-map .leaflet-control-layers.wp-layers.wp-collapsed { width: auto; }
    .wp-map .leaflet-iconLayers-layer { width: 44px; height: 44px; }
    .wp-dialog { width: 100%; max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
    .wp-chart { flex: 1; width: 100%; height: auto; max-height: none; }
}
