/*==============================================================================================================
  pizzi.css - shared styles for pizzi.html, excursions.html and compare.html
  all classes use the "pz-" prefix
==============================================================================================================*/

/* ---- design tokens ---- */
:root {
    --bar-height: 52px;
    --nav-height: 44px;
    --bg: #fff;
    --accent: #3b82f6;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --surface: #f8fafc;
    --hover: #eff6ff;
    --radius: 4px;
}

/* ---- base: every page is a full-height grid, nav on top ---- */
html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
}
body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}
body.pz-with-footer {
    grid-template-rows: auto minmax(0, 1fr) auto;
}
#map {
    min-width: 0;
    min-height: 0;
}

/* ---- utilities ---- */
.pz-muted {
    color: var(--text-muted);
}
.pz-push-right {
    flex-shrink: 0;
    margin-left: auto;
}
.pz-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pz-row.pz-wrap {
    flex-wrap: wrap;
}

/*==============================================================================================================
  COMPONENTS
==============================================================================================================*/

/* ---- site navigation ---- */
.pz-nav {
    display: flex;
    align-items: stretch;
    gap: 4px;
    height: var(--nav-height);
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.pz-nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    color: var(--text);
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
}
.pz-nav-brand img {
    width: 24px;
    height: 24px;
}
.pz-nav-link {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
}
.pz-nav-link:hover {
    color: var(--text);
    background: var(--hover);
}
.pz-nav-link.active {
    border-bottom-color: var(--accent);
    color: var(--text);
    font-weight: bold;
}

/* ---- bar: white strip with a bottom border (panel header, info bar) ---- */
.pz-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--bar-height);
    padding: 4px 12px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

/* ---- footer: bottom panel with a top border ---- */
.pz-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ---- buttons ---- */
.pz-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface);
    font: inherit;
    cursor: pointer;
}
.pz-button:hover {
    border-color: var(--accent);
    background: var(--hover);
}
.pz-button.plain {
    padding: 3px;
    border-color: transparent;
    background: transparent;
}
.pz-button.plain:hover {
    border-color: var(--border);
    background: var(--hover);
}
/* a <label class="pz-button"> wrapping a file input acts as upload button */
.pz-button input[type="file"] {
    display: none;
}

/* a <label class="pz-button pz-select"> wrapping a <select> acts as dropdown button */
.pz-select {
    padding-top: 2px;
    padding-bottom: 2px;
}
.pz-select select {
    padding: 2px 0;
    border: none;
    outline: none;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

/* ---- icons ---- */
.pz-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-repeat: no-repeat;
}
.pz-icon-settings {
    background-image: url('IMG/settings.svg');
    background-size: 16px 16px;
}
.pz-icon-save {
    background-image: url('IMG/save.svg');
    background-size: 16px 16px;
}
.pz-icon-layers {
    background-image: url('IMG/layers.svg');
    background-size: 16px 16px;
}
.pz-icon-open {
    background-image: url('IMG/open.svg');
    background-size: 16px 16px;
}
.pz-icon-clear {
    background-image: url('IMG/clear.svg');
    background-size: 16px 16px;
}

/* ---- chips: small boxed items (legend of loaded tracks) ---- */
.pz-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}
.pz-chip:hover {
    border-color: var(--accent);
    background: var(--hover);
}
.pz-chip.selected {
    border-color: var(--accent);
    font-weight: bold;
}
.pz-chip-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(15,23,42,0.25);
}
.pz-chip-note {
    padding: 0 6px;
    color: var(--text-muted);
    font-weight: normal;
}
.pz-chip-note:empty {
    padding: 0;
}
.pz-chip-remove {
    margin-left: 4px;
    padding: 0 3px;
    border-radius: 3px;
    color: var(--text-muted);
    font-weight: normal;
    line-height: 1;
    cursor: pointer;
}
.pz-chip-remove:hover {
    color: #fff;
    background: var(--text-muted);
}

/* ---- toggle filters: faded image, highlighted when the hidden checkbox is checked ---- */
.pz-filter input[type="checkbox"] {
    display: none;
}
.pz-filter span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px 2px 3px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    opacity: 0.45;
    cursor: pointer;
}
.pz-filter input[type="checkbox"]:checked + span {
    border-color: var(--accent);
    background: var(--hover);
    opacity: 1;
}
.pz-filter img {
    display: block;
    width: 24px;
    height: 30px;
}
/* number of items of the filter, next to its pin */
.pz-filter-count {
    min-width: 14px;
    color: var(--text);
    font-size: 12px;
    font-weight: bold;
}
.pz-table td img {
    display: block;
    width: 16px;
    height: 20px;
}

/* ---- data table ---- */
.pz-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;     /* dense data: a bit smaller than the rest of the page */
}
.pz-table th,
.pz-table td {
    border-bottom: 1px solid var(--border);
    padding: 5px 6px;
    text-align: left;
}
.pz-table .pz-unit {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}
.pz-table .num {
    text-align: right;
}
.pz-table th {
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: normal;
    vertical-align: bottom;
    cursor: pointer;
    user-select: none;
}
.pz-table tbody tr {
    cursor: pointer;
}
.pz-table th.sorted-asc::after {
    content: " \25B2";
    font-size: 9px;
}
.pz-table th.sorted-desc::after {
    content: " \25BC";
    font-size: 9px;
}
.pz-table tbody tr:hover {
    background: var(--hover);
}
/* row whose track is drawn on the map */
.pz-table tbody tr.active {
    background: var(--hover);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: bold;
}

/* ---- draggable dialog ---- */
.pz-dialog {
    display: none;
    position: fixed;
    z-index: 9000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15,23,42,0.25);
}
.pz-dialog.open {
    display: block;
}
.pz-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: move;
    user-select: none;
}
.pz-dialog-title {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pz-dialog-close {
    color: var(--text);
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}
.pz-dialog-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
}
.pz-dialog-body form {
    margin: 0;
}

/*==============================================================================================================
  PIZZI PAGE: west panel | splitter | info bar + map
==============================================================================================================*/
.pz-layout {
    --west-width: min(500px, 85vw); /* never wider than the screen on phones */
    display: grid;
    grid-template-columns: var(--west-width) 5px 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
}
.pz-layout.west-collapsed {
    grid-template-columns: 32px 5px 1fr;
}
.pz-west {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    border-right: 1px solid var(--border);
}
.pz-west-header {
    justify-content: space-between;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.5px;
    user-select: none;
}
.pz-west-toggle {
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
}
.pz-west-toggle:hover {
    background: var(--hover);
    color: var(--accent);
}
.pz-west-body {
    overflow: auto;
    min-height: 0;
}
.pz-west-filters {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
}
.pz-west-search {
    flex: 1;
    min-width: 60px;
    margin-left: 8px;
}
.pz-layout.west-collapsed .pz-west-body {
    display: none;
}
.pz-layout.west-collapsed .pz-west-header {
    flex-direction: column;
    justify-content: flex-start;
    padding: 14px 0;
    height: 100%;
    cursor: pointer;
}
.pz-layout.west-collapsed .pz-west-title {
    writing-mode: vertical-rl;
}
.pz-splitter {
    background: var(--border);
    cursor: col-resize;
}
.pz-splitter:hover,
.pz-splitter.dragging {
    background: var(--accent);
}
.pz-layout.west-collapsed .pz-splitter {
    cursor: default;
    pointer-events: none;
}
.pz-center {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

/* ---- route info bar above the map ---- */
.pz-info-data {
    display: none;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}
.pz-info-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
}
.pz-info.has-data .pz-info-empty {
    display: none;
}
.pz-info.has-data .pz-info-data {
    display: flex;
}
/* buttons on the right of the info bar: GPX, Clear, base map */
.pz-info-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}
/* "GPX": visible only while a route is shown in the bar */
.pz-info-gpx {
    display: none;
}
.pz-info.has-data .pz-info-gpx {
    display: inline-flex;
}
/* "Clear": visible only while some track is drawn on the map */
.pz-clear-tracks {
    display: none;
}
.pz-info.has-tracks .pz-clear-tracks {
    display: inline-flex;
}
.pz-info-title {
    font-weight: bold;
    font-size: 15px;
    line-height: 1.2;
    padding-left: 8px;
    border-left: 3px solid var(--accent);
}
.pz-info-sub {           /* e.g. the date next to the title */
    margin-left: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: normal;
}
.pz-info-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
}
.pz-info-label {
    color: var(--text-muted);
    font-size: 12px;
}
.pz-info-item span + span {
    font-weight: bold;
}

/* ---- settings dialog ---- */
#manage {
    width: 310px;
    left: 100px;
    top: 100px;
}

/*==============================================================================================================
  EXCURSIONS PAGE: same layout as the pizzi page, activities downloaded from Garmin
==============================================================================================================*/
/* widths of the content (padding excluded): what is left goes to the excursion name */
#excGrid th:nth-child(1) { width: 68px; }   /* date */
#excGrid th:nth-child(3) { width: 48px; }   /* distance */
#excGrid th:nth-child(4) { width: 44px; }   /* ascent */
#excGrid th:nth-child(5) { width: 48px; }   /* max elevation */
#excGrid th:nth-child(6) { width: 52px; }   /* duration */
#excGrid th:nth-child(7) { width: 28px; }   /* type */
#excGrid th,
#excGrid td {
    padding-left: 4px;
    padding-right: 4px;
}
#excGrid td {
    white-space: nowrap;
}
#excGrid td:nth-child(2) {   /* long excursion names wrap, as the peak names of the pizzi page */
    white-space: normal;
    overflow-wrap: anywhere;  /* also a single long word (e.g. Chuebodenhorn) */
}
.pz-west-title .pz-muted {
    font-weight: normal;
}

/* ---- Leaflet controls in the style of the site ---- */
.leaflet-container {
    font-family: inherit;
}
.leaflet-bar {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15) !important;
    overflow: hidden;
}
.leaflet-bar a,
.leaflet-bar a:hover {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    border-bottom-color: var(--border) !important;
    color: var(--text) !important;
    font-weight: normal;
}
.leaflet-bar a:hover {
    background: var(--hover) !important;
    color: var(--accent) !important;
}
.leaflet-control-attribution {
    border-top-left-radius: var(--radius);
    background: rgba(255, 255, 255, 0.8) !important;
    color: var(--text-muted);
    font-size: 10px;
}

/* ---- groups of close markers (Leaflet.markercluster), in the colors of the site ---- */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(59, 130, 246, 0.25);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: var(--accent);
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(15, 23, 42, 0.3);
}

/*==============================================================================================================
  COMPARE PAGE: map + footer with timeline and legend
==============================================================================================================*/
.pz-timeline {
    position: relative;
    padding: 22px 0 4px;
}
.pz-timeline-tip {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-50%);
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--text);
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
}
.pz-timeline-tip:empty {
    display: none;
}
.pz-timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 4px;
    margin: 0;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}
.pz-timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    cursor: pointer;
}
.pz-timeline-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    cursor: pointer;
}
.pz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style-type: none;
}
.pz-timeline-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11px;
}
.pz-disclaimer {
    font-size: 12px;
    text-align: right;
    cursor: help;
}
img.pz-icon {
    object-fit: contain;   /* pin images are taller than wide */
}

/* ---- excursions picker dialog ---- */
.pz-dialog.pz-picker {
    top: 60px;
    left: 50%;
    width: 460px;
    max-width: calc(100vw - 32px);
    transform: translateX(-50%);
}
.pz-picker .pz-dialog-header {
    cursor: default;
}
.pz-picker .pz-dialog-body {
    align-items: stretch;
}
.pz-picker-filters .pz-input {
    flex: 1;
    min-width: 0;
}
.pz-picker-list {
    height: 50vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.pz-picker-row {
    display: grid;
    grid-template-columns: 18px 76px 1fr auto;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.pz-picker-row:hover {
    background: var(--hover);
}
.pz-picker-row .num {
    text-align: right;
}
.pz-picker-actions {
    gap: 8px;
}

/* ---- form controls ---- */
.pz-input {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--bg);
    font: inherit;
    outline: none;
}
.pz-input:focus {
    border-color: var(--accent);
}
.pz-button.pz-primary {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
}
.pz-button.pz-primary:hover {
    background: #2563eb;
}
.pz-button:disabled {
    opacity: 0.5;
    cursor: default;
}

/*==============================================================================================================
  SMALL SCREENS
==============================================================================================================*/
@media (max-width: 700px) {
    .pz-nav-brand {
        margin-right: 4px;
    }
    /* info bar: let items wrap so the Map Type button stays on screen */
    .pz-info {
        flex-wrap: wrap;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .pz-disclaimer {
        margin-left: 0;
        text-align: left;
    }
}
