{"id":12555,"date":"2026-11-03T23:50:26","date_gmt":"2026-11-03T23:50:26","guid":{"rendered":"https:\/\/paragliding-in-madeira.com\/weather\/?page_id=12555"},"modified":"2026-11-17T14:53:37","modified_gmt":"2026-11-17T14:53:37","slug":"sounding","status":"publish","type":"page","link":"https:\/\/paragliding-in-madeira.com\/weather\/sounding\/","title":{"rendered":""},"content":{"rendered":"\n<figure class=\"wp-block-image alignfull size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"3333\" height=\"1860\" src=\"https:\/\/paragliding-in-madeira.com\/weather\/wp-content\/uploads\/2026\/11\/1000472782.webp\" alt=\"1000472782\" class=\"wp-image-12581\" srcset=\"https:\/\/paragliding-in-madeira.com\/weather\/wp-content\/uploads\/2026\/11\/1000472782.webp 3333w, https:\/\/paragliding-in-madeira.com\/weather\/wp-content\/uploads\/2026\/11\/1000472782-300x167.webp 300w\" sizes=\"auto, (max-width: 3333px) 100vw, 3333px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-0aa01211 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/paragliding-in-madeira.com\/weather\/\">Home<\/a><\/div>\n\n\n\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/paragliding-in-madeira.com\/weather\/weather-info\/\">Weather Info<\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><a href=\"https:\/\/www.windy.com\/sounding\/32.792\/-16.804?gfs,clouds,32.422,-16.804,10,i:pressure\" target=\"_blank\" rel=\"noopener nofollow\" title=\"\">Windy model<\/a><\/p>\n\n\n\n<div style=\"height:11px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">Sounding profile using the most reliable European model today<br><br>Shows the evolution of temperature and wind on different altitude layers<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"height:22px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<template>\n<link rel=\"stylesheet\" href=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.css\">\n<style>#sounding-chart-container th, #sounding-chart-container td { white-space: nowrap; padding: 4px 3px; text-align: center; font-size: 13px; }<\/style>\n<div id=\"sounding-map\" style=\"width:100%;height:420px;border:1px solid #ccc;\"><\/div>\n<div id=\"spot-buttons\" style=\"margin:10px 0;\"><\/div>\n<div id=\"sounding-chart-container\"><p style=\"font-size:16px;\">Tap the map or buttons to load the sounding<\/p><\/div>\n<p style=\"font-size:12.5px;color:#666;\">Weather data by <a href=\"https:\/\/open-meteo.com\" target=\"_blank\">Open-Meteo.com<\/a> (ICON-EU)<\/p>\n<script src=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.js\"><\/script>\n<script>\nfunction startSoundingMap() {\n    const weatherStations = [\n        { name: \"Maiata\", lat: 32.76724, lon: -16.82228 },\n        { name: \"Portela\", lat: 32.74718, lon: -16.82599 },\n        { name: \"Canhas\", lat: 32.70353, lon: -17.12599 },\n        { name: \"Pico Areeiro\", lat: 32.7355, lon: -16.928 }\n    ];\n\n    function toCardinal(deg) {\n        const pts = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'];\n        return pts[Math.round(deg \/ 22.5) % 16];\n    }\n\n    async function fetchOpenMeteoSounding(lat, lon, stationName) {\n        const MODEL = 'icon_eu';\n        const container = document.getElementById('sounding-chart-container');\n        const levels = [1000,975,950,925,900,875,850,825,800,775,750,700,600,500,400,300,200,100];\n        const vars = ['temperature','dew_point','wind_speed','wind_direction','geopotential_height'];\n        const hourly = vars.flatMap(v => levels.map(l => `${v}_${l}hPa`)).join(',') + ',temperature_2m,dew_point_2m,surface_pressure,wind_speed_10m,wind_direction_10m';\n        container.innerHTML = `<p>Fetching sounding data for <strong>${stationName}<\/strong>...<\/p>`;\n        try {\n            const url = 'https:\/\/api.open-meteo.com\/v1\/forecast?' + new URLSearchParams({ latitude: lat, longitude: lon, hourly: hourly, models: MODEL, forecast_days: 2 });\n            const r = await fetch(url);\n            if (!r.ok) throw new Error(`Status ${r.status}`);\n            const d = await r.json();\n            const times = d.hourly.time;\n            let i = times.findIndex(t => new Date(t + 'Z') >= Date.now());\n            if (i < 0) i = 0;\n            let rows = '';\n            const sp = d.hourly.surface_pressure[i], st = d.hourly.temperature_2m[i], sd = d.hourly.dew_point_2m[i];\n            const SHOW_GROUND_ROW = true;\n            \n            if (SHOW_GROUND_ROW) {\n                rows += `<tr><td>${Math.round(sp)}<\/td><td>${Math.round(d.elevation)}<\/td><td>${st.toFixed(1)}<\/td><td>${sd.toFixed(1)}<\/td><td>${Math.round(d.hourly.wind_speed_10m[i])}\/${Math.round(d.hourly.wind_direction_10m[i])}\u00b0 (${toCardinal(d.hourly.wind_direction_10m[i])})<\/td><\/tr>`;\n            }\n            \n            levels.forEach(l => {\n                const t = d.hourly[`temperature_${l}hPa`][i];\n                const td = d.hourly[`dew_point_${l}hPa`][i];\n                const h = d.hourly[`geopotential_height_${l}hPa`][i];\n                \n\/\/ CRUCIAL Replaced '&&' and '<' with safe nested ifs to fix WordPress live view\n                if (sp > l) {\n                    if ([t, td].every(v => v !== null)) {\n                        rows += `<tr><td>${l}<\/td><td>${Math.round(h)}<\/td><td>${t.toFixed(1)}<\/td><td>${td.toFixed(1)}<\/td><td>${Math.round(d.hourly[`wind_speed_${l}hPa`][i])}\/${Math.round(d.hourly[`wind_direction_${l}hPa`][i])}\u00b0 (${toCardinal(d.hourly[`wind_direction_${l}hPa`][i])})<\/td><\/tr>`;\n                    }\n                }\n            });\n            \n            const d0 = new Date(times[i] + 'Z');\n            const stamp = `${String(d0.getUTCDate()).padStart(2,'0')}\/${String(d0.getUTCMonth()+1).padStart(2,'0')}\/${d0.getUTCFullYear()} ${String(d0.getUTCHours()).padStart(2,'0')}:${String(d0.getUTCMinutes()).padStart(2,'0')} UTC`;\n            \n            container.innerHTML = `<h3>Sounding for ${stationName}<\/h3><p style=\"font-size:14px;white-space:nowrap;\">${stamp} \u00b7 model elev. ${d.elevation} m<\/p><table style=\"font-size:14px;width:100%;\"><tr><th>hPa<\/th><th>Height m<\/th><th>Temp \u00b0C<\/th><th>Dew \u00b0C<\/th><th>Wind km\/h<\/th><\/tr>${rows}<\/table>`;\n        } catch (error) {\n            console.error(error);\n            container.innerHTML = `<p>Could not load sounding data (${error.message}).<\/p>`;\n        }\n    }\n\n    const map = L.map('sounding-map').setView([32.75, -16.95], 9);\n    L.tileLayer('https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png', {\n        maxZoom: 18,\n        attribution: '\\u00a9 OpenStreetMap contributors'\n    }).addTo(map);\n\n    let pin = null;\n    function pick(lat, lon, name) {\n        if (pin) map.removeLayer(pin);\n        pin = L.marker([lat, lon]).addTo(map);\n        fetchOpenMeteoSounding(lat, lon, name);\n    }\n\n    const btnBox = document.getElementById('spot-buttons');\n    weatherStations.forEach(s => {\n        const b = document.createElement('button');\n        b.textContent = s.name;\n        b.style.cssText = 'margin:0 6px 6px 0;padding:6px 12px;border-radius:16px;border:1px solid #3b5775;background:#fff;color:#3b5775;';\n        b.onclick = () => { map.setView([s.lat, s.lon], 11); pick(s.lat, s.lon, s.name); };\n        btnBox.appendChild(b);\n    });\n\n    map.on('click', e => pick(e.latlng.lat, e.latlng.lng, `Map point (${e.latlng.lat.toFixed(3)}, ${e.latlng.lng.toFixed(3)})`));\n}\n(function waitForLeaflet() {\n    if (window.L) { startSoundingMap(); } else { setTimeout(waitForLeaflet, 200); }\n})();\n<\/script>\n<\/template>\n\n\n\n<template>\n<link rel=\"stylesheet\" href=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.css\">\n\n<style>\n\/* ============================================================\n   SOUNDING WIDGET \u2014 \"Cockpit Light\" look\n   Same design language as the Airport Time widget:\n   soft card, rounded corners, airy type, muted colors.\n   All styles live here so tweaks stay in one place.\n   ============================================================ *\/\n\n\/* ---- The whole widget is one soft card ---- *\/\n#sounding-widget {\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n  background: rgba(237,237,237,0.8);\n  border: 1px solid #eef2f5;\n  border-radius: 12px;\n  box-shadow: 0 10px 30px rgba(0,0,0,0.04);\n  max-width: 590px;         \/* a touch wider than the time widget so the table breathes *\/\n  margin: 10px auto;\n  overflow: hidden;          \/* rounds the map's top corners cleanly *\/\n  color: #444;\n}\n\n\/* ---- Map ---- *\/\n#sounding-map {\n  width: 100%;\n  height: 380px;\n  border-bottom: 1px solid #eef2f5;\n}\n\n\/* ---- Spot buttons ---- *\/\n#spot-buttons {\n  padding: 8px 9px 3px;\n  text-align: center;\n}\n.spot-btn {\n  margin: 0 4px 6px;\n  padding: 4px 10px;\n  border-radius: 20px;\n  border: 0px solid #eef2f5;\n  background: #fff;\n  color: #3b5775;\n  font: inherit;\n  font-size: 0.75rem;\n  font-weight: 500;\n  letter-spacing: 0.3px;\n  cursor: pointer;\n  transition: background 0.15s ease, border-color 0.15s ease;\n}\n.spot-btn:hover {\n  background: rgba(59,87,117,0.06);\n  border-color: #3b5775;\n}\n\n\/* ---- Results panel (graph and table live here) ---- *\/\n#sounding-chart-container {\n  padding: 12px 11px 15px;\n  font-variant-numeric: tabular-nums;   \/* keeps numbers aligned in columns *\/\n}\n\n\/* Small uppercase tag above the station name *\/\n.sounding-tag {\n  font-size: 0.7rem;\n  text-transform: uppercase;\n  letter-spacing: 2px;\n  color: #8898aa;\n  text-align: center;\n  font-weight: 600;\n  margin-bottom: 4px;\n}\n\n\/* Station name \u2014 big & delicate *\/\n#sounding-chart-container h3 {\n  font-size: 1.3rem;\n  font-weight: 400;\n  letter-spacing: -0.5px;\n  color: #2d3436;\n  text-align: center;\n  margin: 0 0 4px;\n  padding-bottom: 10px;\n  white-space: nowrap;\n}\n\n\/* Date + model elevation line \u2014 muted, centered *\/\n#sounding-chart-container .sounding-meta {\n  font-size: 0.8rem;\n  font-weight: 600;          \/* keeps the same weight it had before the move *\/\n  color: #8898aa;\n  text-align: center;\n  margin: 6px 0;\n  white-space: nowrap;\n  padding-bottom: 10px;\n}\n\n\/* Holds date + slider together. Graph: date on top. Table: slider on top. *\/\n.snd-time-block {\n  display: flex;\n  flex-direction: column;\n}\n.snd-time-block.table-mode {\n  flex-direction: column-reverse;\n}\n\n\/* Loading \/ error messages \u2014 quiet and centered *\/\n#sounding-chart-container > p {\n  text-align: center;\n  color: #8898aa;\n  font-size: 0.9rem;\n  font-weight: 600;\n}\n\n\/* ---- Graph \/ Table switch (two gentle pills) ---- *\/\n.snd-toggle {\n  display: flex;\n  justify-content: center;\n  gap: 6px;\n  margin: 0 0 12px;\n}\n.snd-toggle-btn {\n  padding: 5px 18px;\n  border-radius: 20px;\n  border: 0;\n  background: #fff;\n  color: #3b5775;\n  font: inherit;\n  font-size: 0.75rem;\n  font-weight: 500;\n  letter-spacing: 0.3px;\n  cursor: pointer;\n  transition: background 0.15s ease, color 0.15s ease;\n}\n.snd-toggle-btn:hover {\n  background: rgba(59,87,117,0.06);\n}\n\/* The pill that is currently showing *\/\n.snd-toggle-btn.active {\n  background: #3b5775;\n  color: #fff;\n}\n\n\/* ---- Time slider row ---- *\/\n.snd-slider-row {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 0 4px;\n  margin: 0 0 6px;\n}\n.snd-slider-row input[type=\"range\"] {\n  flex: 1;\n  margin: 0;\n  accent-color: #3b5775;\n  cursor: pointer;\n}\n.snd-slider-label {\n  min-width: 42px;\n  text-align: right;\n  font-size: 0.78rem;\n  font-weight: 500;\n  color: #3b5775;\n}\n.snd-slider-end {\n  min-width: 42px;\n  font-size: 0.75rem;\n  color: #8898aa;\n}\n\n\/* ---- Skew-T graph ---- *\/\n.snd-svg {\n  display: block;\n  width: 100%;\n  height: auto;\n  touch-action: none;        \/* lets a finger drag along the graph without scrolling the page *\/\n  cursor: crosshair;\n  margin-top: -40px;\n}\n.snd-plot-bg {\n  fill: rgba(255,255,255,0.65);\n}\n.snd-ground {\n  fill: rgba(59,87,117,0.12);\n}\n.snd-ground-edge {\n  stroke: rgba(59,87,117,0.35);\n  stroke-width: 1;\n}\n.snd-isobar {\n  stroke: #d6dde4;\n  stroke-width: 1;\n}\n.snd-isotherm {\n  stroke: #dde4ea;\n  stroke-width: 1;\n}\n.snd-isotherm-zero {\n  stroke: #8fb6d6;\n  stroke-width: 1.4;\n  stroke-dasharray: 4 3;\n}\n.snd-axis-text {\n  fill: #8898aa;\n  font-size: 11px;\n}\n.snd-line-t {\n  fill: none;\n  stroke: #d1604d;\n  stroke-width: 2.4;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n}\n.snd-line-d {\n  fill: none;\n  stroke: #3f87a6;\n  stroke-width: 2.4;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n}\n.snd-barb {\n  stroke: #5c6f82;\n  stroke-width: 1.3;\n  stroke-linecap: round;\n  fill: #5c6f82;\n}\n.snd-probe-line {\n  stroke: #3b5775;\n  stroke-width: 1;\n  stroke-dasharray: 3 3;\n  opacity: 0.6;\n}\n.snd-probe-t {\n  fill: #fff;\n  stroke: #d1604d;\n  stroke-width: 2;\n}\n.snd-probe-d {\n  fill: #fff;\n  stroke: #3f87a6;\n  stroke-width: 2;\n}\n\/* Gentle tooltip labels on the probe line *\/\n.snd-tip {\n  font-size: 12px;\n  font-weight: 500;\n  paint-order: stroke;\n  stroke: rgba(255,255,255,0.9);\n  stroke-width: 3px;\n  stroke-linejoin: round;\n  pointer-events: none;\n}\n.snd-tip-h, .snd-tip-w { \nfill: #5c6f82; \n}\n.snd-tip-t { \nfill: #d1604d; \n}\n.snd-tip-d { \nfill: #3f87a6; \n}\n\n\/* ---- Touch readout under the graph ---- *\/\n.snd-readout {\n  min-height: 66px;           \/* keeps the layout steady when the text changes *\/\n  margin-top: 6px;\n  text-align: center;\n  font-size: 0.82rem;\n  color: #444;\n}\n.snd-readout-top {\n  margin-bottom: 3px;\n  font-weight: 500;\n  color: #2d3436;\n}\n.snd-readout-hint {\n  color: #8898aa;\n}\n.snd-dot {\n  display: inline-block;\n  width: 8px;\n  height: 8px;\n  margin: 0 4px 0 8px;\n  border-radius: 50%;\n}\n.snd-dot-t {\n  background: #d1604d;\n}\n.snd-dot-d {\n  background: #3f87a6;\n}\n.snd-dot-h {\n  background: #7d9b76;\n}\n\n\/* ---- Table ---- *\/\n#sounding-chart-container table {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13.5px;\n}\n\n\/* Header row: small caps, muted, thin bottom rule *\/\n#sounding-chart-container th {\n  font-size: 0.65rem;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 1.5px;\n  color: #444;\n  padding: 8px 4px 10px;\n  border-bottom: 1px solid #eef2f5;\n  text-align: center;\n  white-space: nowrap;\n}\n\n\/* Body cells: centered, airy, quiet *\/\n#sounding-chart-container td {\n  padding: 8px 4px;\n  text-align: center;\n  white-space: nowrap;\n  color: #444;\n  font-weight: 410;\n}\n\n\/* Zebra stripes \u2014 whisper-light, every other level row *\/\n#sounding-chart-container tbody tr:nth-child(odd) td {\n  background: rgba(0,0,0,0.025);\n}\n\n\/* Ground row: gentle slate tint so it reads as \"the surface\" *\/\n#sounding-chart-container tr.sounding-ground td {\n  background: rgba(59,87,117,0.08);\n  font-weight: 500;\n  color: #2d3436;\n}\n\n\/* ---- Full screen button + immersive mode ---- *\/\n#sounding-chart-container { position: relative; }\n\n.snd-fs-btn {\n  position: absolute;\n  top: 8px;\n  right: 10px;\n  z-index: 2;\n  width: 32px;\n  height: 32px;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  background: #fff;\n  color: #3b5775;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n.snd-fs-btn:hover {\n  background: rgba(59,87,117,0.06);\n}\n.snd-fs-btn svg {\n  width: 16px;\n  height: 16px;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 2;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.snd-fs-btn .snd-fs-exit { display: none; }\n.snd-full .snd-fs-btn .snd-fs-enter { display: none; }\n.snd-full .snd-fs-btn .snd-fs-exit { display: block; }\n\n#sounding-chart-container.snd-full {\n  position: fixed;\n  inset: 0;\n  z-index: 999999;           \/* above the WordPress admin bar *\/\n  box-sizing: border-box;\n  background: #ededed;\n  overflow-y: auto;\n  -webkit-overflow-scrolling: touch;\n  padding: max(12px, env(safe-area-inset-top)) 6px 20px;\n}\n.snd-full .snd-fs-btn {\n  top: max(8px, env(safe-area-inset-top));\n}\n\/* Keeps content a comfortable width on wide screens *\/\n#sounding-chart-container.snd-full > *:not(.snd-fs-btn) {\n  max-width: 640px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\/* The 300 must match the 300 in setGraphHeight() *\/\n.snd-full .snd-svg {\n  max-height: max(320px, calc(100vh - 300px));\n  max-height: max(320px, calc(100dvh - 300px));\n}\n\/* Desktop only: less reserved space, so the graph can grow *\/\n@media (min-width: 601px) {\n  .snd-full .snd-svg {\n    max-height: max(320px, calc(100vh - 215px));\n    max-height: max(320px, calc(100dvh - 215px));\n  }\n}\n\n\/* ---- Credit line under the card ---- *\/\n.sounding-credit {\n  font-size: 0.75rem;\n  color: #8898aa;\n  text-align: center;\n  padding: 0 15px 18px;\n}\n.sounding-credit a {\n  color: #8898aa;\n  text-decoration: underline;\n}\n\n\/* ---- Mobile: tighten the table a notch ---- *\/\n@media (max-width: 600px) {\n\/* Less side padding so the graph uses more of the screen *\/\n  #sounding-chart-container { padding: 12px 3px 15px; }\n\n  \/* Bigger touch target for the time slider *\/\n  .snd-slider-row input[type=\"range\"] {\n    -webkit-appearance: none;\n    appearance: none;\n    height: 44px;\n    background: transparent;\n  }\n  .snd-slider-row input[type=\"range\"]::-webkit-slider-runnable-track {\n    height: 4px;\n    background: #cfd8e0;\n    border-radius: 2px;\n  }\n  .snd-slider-row input[type=\"range\"]::-webkit-slider-thumb {\n    -webkit-appearance: none;\n    width: 26px;\n    height: 26px;\n    margin-top: -11px;       \/* centers the thumb on the track *\/\n    border-radius: 50%;\n    background: #3b5775;\n  }\n  .snd-slider-row input[type=\"range\"]::-moz-range-track {\n    height: 4px;\n    background: #cfd8e0;\n    border-radius: 2px;\n  }\n  .snd-slider-row input[type=\"range\"]::-moz-range-thumb {\n    width: 26px;\n    height: 26px;\n    border: 0;\n    border-radius: 50%;\n    background: #3b5775;\n  }\n\n  #sounding-chart-container table { font-size: 12.5px; }\n  #sounding-chart-container th { letter-spacing: 1px; font-size: 0.6rem; }\n}\n\n\/* ---- Mobile: bigger axis + tooltip text for easier reading ---- *\/\n@media (max-width: 600px) {\n  .snd-axis-text {\n    font-size: 14px;\n  }\n  .snd-tip {\n    font-size: 14px;\n    stroke-width: 4px;   \/* thicker white outline so it pops over the curves *\/\n  }\n  .snd-svg {\n    \/* push the SVG a hair higher so the bigger text doesn't clip at the top *\/\n    margin-top: -32px;\n  }\n}\n\n<\/style>\n\n<div id=\"sounding-widget\">\n  <div id=\"sounding-map\"><\/div>\n  <div id=\"spot-buttons\"><\/div>\n  <div id=\"sounding-chart-container\"><p>Tap the map or buttons to load the sounding<\/p><\/div>\n  <div class=\"sounding-credit\">Weather data by <a href=\"https:\/\/open-meteo.com\" target=\"_blank\">Open-Meteo.com<\/a> (ICON-EU)<\/div>\n<\/div>\n\n<script src=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.js\"><\/script>\n<script>\nfunction startSoundingMap() {\n    const weatherStations = [\n        { name: \"Maiata\", lat: 32.76724, lon: -16.82228 },\n        { name: \"Portela\", lat: 32.74718, lon: -16.82599 },\n        { name: \"Canhas\", lat: 32.70353, lon: -17.12599 },\n        { name: \"Madalena\", lat: 32.6985, lon: -17.131 },\n        { name: \"Pico Areeiro\", lat: 32.7355, lon: -16.928 },\n        { name: \"Porto Santo\", lat: 33.0313, lon: -16.3679 }\n    ];\n\n    \/* ============================================================\n       SETTINGS \u2014 gentle knobs you can adjust by hand\n       ============================================================ *\/\n    const LEVELS = [1000,975,950,925,900,875,850,825,800,775,750,700,600,500,400,300,200,100];\n    const FORECAST_DAYS = 4;     \/\/ how many days of hours the slider can reach\n    const P_BOTTOM = 1030;       \/\/ bottom of the graph (hPa)\n    const P_TOP = 300;           \/\/ top of the graph (hPa), changed from 400\n    let T_MIN = -10;             \/\/ coldest temperature on the bottom edge (setGraphHeight picks it)\n    const T_MAX = 35;            \/\/ warmest temperature on the bottom edge\n    const SKEW = 0.8;            \/\/ how much the temperature lines lean to the right\n    const DAY_NAMES = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];\n\n    \/* ---- Graph size (in drawing units, it scales to the card) ---- *\/\n    const SKEW_W = 440;\n    let SKEW_H = 412;            \/\/ graph height, chosen by setGraphHeight() below\n    const ML = 34;               \/\/ left margin (pressure numbers)\n    const MR = 50;               \/\/ right margin (wind barbs)\n    const MT = 44;               \/\/ top margin (empty band where hPa \/ kt sit)\n    const MB = 26;               \/\/ bottom margin (temperature numbers)\n    const PW = SKEW_W - ML - MR;\n    const BARB_X = PW + 26;      \/\/ where the wind barbs and the \"kt\" label are centered\n    let PH = SKEW_H - MT - MB;\n    let PX_PER_DEG = PW \/ (T_MAX - T_MIN);\n        const LN_RANGE = Math.log(P_BOTTOM \/ P_TOP);\n\n    \/\/ Picks the graph height: taller on phones, and filled to the screen in full screen\n    function setGraphHeight() {\n        const phone = window.matchMedia('(max-width: 600px)').matches;\n        let h = phone ? 600 : 412;           \/\/ <- the two heights to tweak by hand\n        const box = document.getElementById('sounding-chart-container');\n        if (box.classList.contains('snd-full')) {\n            const reserve = (window.innerWidth > 600) ? 215 : 300;\n            const availH = Math.max(320, window.innerHeight - reserve);\n            const availW = Math.min(window.innerWidth - 12, 640);\n            h = Math.max(412, Math.min(760, Math.round(SKEW_W * availH \/ availW)));\n        }\n        SKEW_H = h;\n        PH = SKEW_H - MT - MB;\n        T_MIN = (h > 500) ? -10 : -20;   \/\/ tall graph = -10, standard = -20\n        PX_PER_DEG = PW \/ (T_MAX - T_MIN);\n    }\n\n    \/* ============================================================\n       SHARED STATE \u2014 what the widget is showing right now\n       ============================================================ *\/\n    let soundingData = null;     \/\/ the downloaded forecast\n    let startIndex = 0;          \/\/ which hour counts as \"now\"\n    let stepNow = 0;             \/\/ slider position (0 = now)\n    let viewMode = 'graph';      \/\/ 'graph' or 'table'\n    let probeP = null;           \/\/ pressure where the finger last touched the graph\n    let currentPoints = [];      \/\/ the levels for the hour on screen\n    let stationLabel = '';\n\n    const IDLE_HINT = '<div class=\"snd-readout-hint\">Touch the graph to read values<br><span class=\"snd-dot snd-dot-t\"><\/span>Temperature<span class=\"snd-dot snd-dot-d\"><\/span>Dew point<span class=\"snd-dot snd-dot-h\"><\/span>Humidity<\/div>';\n\n    \/\/ Turn a wind direction in degrees into a compass label, e.g. 114 -> \"ESE\"\n    function toCardinal(deg) {\n        const pts = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'];\n        return pts[Math.round(deg \/ 22.5) % 16];\n    }\n\n       function pad(n) {\n        return String(n).padStart(2, '0');\n    }\n\n    \/\/ Relative humidity (%) from temperature and dew point (Magnus formula)\n    function humidity(t, td) {\n        const a = 17.625;\n        const b = 243.04;\n        const rh = 100 * Math.exp(a * td \/ (b + td)) \/ Math.exp(a * t \/ (b + t));\n        return Math.max(0, Math.min(100, rh));\n    }\n\n    \/\/ \"2026-11-04T14:00\" -> \"Wed 04\/11 14:00 UTC\"\n    function formatStamp(iso) {\n        const d0 = new Date(iso + 'Z');\n        return DAY_NAMES[d0.getUTCDay()] + ' ' + pad(d0.getUTCDate()) + '\/' + pad(d0.getUTCMonth() + 1) + ' ' + pad(d0.getUTCHours()) + ':' + pad(d0.getUTCMinutes()) + ' UTC';\n    }\n\n    \/* ============================================================\n       DATA \u2014 gather the levels for one hour (ground first, then up)\n       ============================================================ *\/\n    function getPoints(d, i) {\n        const h = d.hourly;\n        const pts = [];\n        const sp = h.surface_pressure[i];\n\n        pts.push({\n            p: sp,\n            h: d.elevation,\n            t: h.temperature_2m[i],\n            td: h.dew_point_2m[i],\n            ws: h.wind_speed_10m[i] || 0,\n            wd: h.wind_direction_10m[i] || 0,\n            ground: true\n        });\n\n        LEVELS.forEach(l => {\n            \/\/ CRUCIAL: nested ifs instead of '&&' and '<' so WordPress live view stays happy\n            if (sp > l) {\n                const t = h['temperature_' + l + 'hPa'][i];\n                const td = h['dew_point_' + l + 'hPa'][i];\n                const gh = h['geopotential_height_' + l + 'hPa'][i];\n                if ([t, td, gh].every(v => v !== null)) {\n                    pts.push({\n                        p: l,\n                        h: gh,\n                        t: t,\n                        td: td,\n                        ws: h['wind_speed_' + l + 'hPa'][i] || 0,\n                        wd: h['wind_direction_' + l + 'hPa'][i] || 0,\n                        ground: false\n                    });\n                }\n            }\n        });\n        return pts;\n    }\n\n    \/* ============================================================\n       TABLE \u2014 same columns as before\n       ============================================================ *\/\n    function buildTable(pts) {\n        const rows = pts.map(q => {\n            const cls = q.ground ? ' class=\"sounding-ground\"' : '';\n            return `<tr${cls}><td>${Math.round(q.p)}<\/td><td>${Math.round(q.h)}<\/td><td>${q.t.toFixed(1)}<\/td><td>${q.td.toFixed(1)}<\/td><td>${Math.round(q.ws)}\/${Math.round(q.wd)}\u00b0 (${toCardinal(q.wd)})<\/td><\/tr>`;\n        }).join('');\n        return `<table><thead><tr><th>hPa<\/th><th>Height m<\/th><th>Temp \u00b0C<\/th><th>Dew \u00b0C<\/th><th>Wind km\/h<\/th><\/tr><\/thead><tbody>${rows}<\/tbody><\/table>`;\n    }\n\n    \/* ============================================================\n       SKEW-T \u2014 position helpers\n       y = how far down from the top of the plot (0 = top, PH = bottom)\n       ============================================================ *\/\n    function yOf(p) {\n        return PH * (1 - Math.log(P_BOTTOM \/ p) \/ LN_RANGE);\n    }\n    function xOf(t, y) {\n        return (t - T_MIN) * PX_PER_DEG + (PH - y) * SKEW;\n    }\n\n    \/\/ One wind barb, drawn pointing the way the wind comes FROM. Speed in km\/h -> knots.\n    function windBarb(x, y, kmh, dir) {\n        const kt = Math.round(kmh \/ 1.852 \/ 5) * 5;\n        if (kt === 0) {\n            return `<circle class=\"snd-barb\" cx=\"${x}\" cy=\"${y}\" r=\"3.2\" fill=\"none\"\/>`;\n        }\n        const L = 22;\n        let rest = kt;\n        const flags = Math.floor(rest \/ 50);\n        rest = rest - flags * 50;\n        const fulls = Math.floor(rest \/ 10);\n        rest = rest - fulls * 10;\n        const half = rest > 4 ? 1 : 0;\n\n        let shapes = `<line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"${-L}\"\/><circle cx=\"0\" cy=\"0\" r=\"1.8\"\/>`;\n        let pos = -L;\n        for (let n = 0; flags > n; n++) {\n            shapes += `<polygon points=\"0,${pos} 9,${pos} 0,${pos + 5}\"\/>`;\n            pos += 6;\n        }\n        for (let n = 0; fulls > n; n++) {\n            shapes += `<line x1=\"0\" y1=\"${pos}\" x2=\"9\" y2=\"${pos - 3}\"\/>`;\n            pos += 4;\n        }\n        if (half === 1) {\n            if (pos === -L) { pos += 4; }\n            shapes += `<line x1=\"0\" y1=\"${pos}\" x2=\"4.5\" y2=\"${pos - 1.5}\"\/>`;\n        }\n        return `<g class=\"snd-barb\" transform=\"translate(${x},${y}) rotate(${dir})\">${shapes}<\/g>`;\n    }\n\n    \/* ============================================================\n       SKEW-T \u2014 draw the whole graph as one SVG picture\n       ============================================================ *\/\n    function buildSkewT(pts) {\n        \/\/ Ground shading (only if the ground sits above the bottom line)\n        const yG = yOf(pts[0].p);\n        let ground = '';\n        if (PH > yG) {\n            ground = `<rect class=\"snd-ground\" x=\"0\" y=\"${yG.toFixed(1)}\" width=\"${PW}\" height=\"${(PH - yG).toFixed(1)}\"\/>` +\n                     `<line class=\"snd-ground-edge\" x1=\"0\" y1=\"${yG.toFixed(1)}\" x2=\"${PW}\" y2=\"${yG.toFixed(1)}\"\/>`;\n        }\n\n        \/\/ Grid: horizontal pressure lines\n        const pLines = [1000,900,800,700,600,500,400,300];\n        let isobars = '';\n        let pLabels = '';\n        pLines.forEach(p => {\n            if (p >= P_TOP) {\n                const y = yOf(p);\n                isobars += `<line class=\"snd-isobar\" x1=\"0\" y1=\"${y.toFixed(1)}\" x2=\"${PW}\" y2=\"${y.toFixed(1)}\"\/>`;\n                pLabels += `<text class=\"snd-axis-text\" x=\"-6\" y=\"${(y + 4).toFixed(1)}\" text-anchor=\"end\">${p}<\/text>`;\n            }\n        });\n\n        \/\/ Grid: leaning temperature lines (every 10 degrees)\n        let isotherms = '';\n        Array.from({ length: 18 }, (_, n) => -120 + n * 10).forEach(t => {\n            const cls = (t === 0) ? 'snd-isotherm-zero' : 'snd-isotherm';\n            isotherms += `<line class=\"${cls}\" x1=\"${xOf(t, PH).toFixed(1)}\" y1=\"${PH}\" x2=\"${xOf(t, 0).toFixed(1)}\" y2=\"0\"\/>`;\n        });\n\n        \/\/ Temperature numbers along the bottom edge\n        let tLabels = '';\n        Array.from({ length: 6 }, (_, n) => -20 + n * 10).forEach(t => {\n            tLabels += `<text class=\"snd-axis-text\" x=\"${xOf(t, PH).toFixed(1)}\" y=\"${PH + 15}\" text-anchor=\"middle\">${t}\u00b0<\/text>`;\n        });\n\n         tLabels += `<text class=\"snd-axis-text\" x=\"-6\" y=\"${14 - MT}\" text-anchor=\"end\">hPa<\/text>`;\n        tLabels += `<text class=\"snd-axis-text\" x=\"${BARB_X}\" y=\"${14 - MT}\" text-anchor=\"middle\">kt<\/text>`;\n\n        \/\/ The two curves\n        const tPts = pts.map(q => xOf(q.t, yOf(q.p)).toFixed(1) + ',' + yOf(q.p).toFixed(1)).join(' ');\n        const dPts = pts.map(q => xOf(q.td, yOf(q.p)).toFixed(1) + ',' + yOf(q.p).toFixed(1)).join(' ');\n\n        \/\/ Wind barbs on the right, spaced so they never crowd each other\n        let barbs = '';\n        let lastY = PH + 100;\n        pts.forEach(q => {\n            const y = yOf(q.p);\n                        if (y > -1) {\n                if (lastY - y > 15) {\n        barbs += windBarb(BARB_X, y.toFixed(1), q.ws, Math.round(q.wd));\n                    lastY = y;\n                }\n            }\n        });\n\n        return `<svg id=\"snd-svg\" class=\"snd-svg\" viewBox=\"0 0 ${SKEW_W} ${SKEW_H}\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n  <defs>\n    <clipPath id=\"snd-clip\"><rect x=\"0\" y=\"0\" width=\"${PW}\" height=\"${PH}\"\/><\/clipPath>\n  <\/defs>\n  <g transform=\"translate(${ML},${MT})\">\n    <rect class=\"snd-plot-bg\" x=\"0\" y=\"0\" width=\"${PW}\" height=\"${PH}\" rx=\"6\"\/>\n    <g clip-path=\"url(#snd-clip)\">\n      ${ground}\n      ${isobars}\n      ${isotherms}\n      <polyline class=\"snd-line-d\" points=\"${dPts}\"\/>\n      <polyline class=\"snd-line-t\" points=\"${tPts}\"\/>\n      <g id=\"snd-probe\"><\/g>\n    <\/g>\n    ${pLabels}\n    ${tLabels}\n    ${barbs}\n    <g id=\"snd-probe-tip\"><\/g>\n    <rect id=\"snd-touch\" x=\"${-ML}\" y=\"0\" width=\"${SKEW_W}\" height=\"${PH}\" fill=\"transparent\"\/>\n  <\/g>\n<\/svg>`;\n    }\n\n    \/* ============================================================\n       TOUCH READOUT \u2014 values at any height, blended between levels\n       ============================================================ *\/\n    function sampleAt(pts, p) {\n        let a = pts[0];\n        let b = pts[0];\n        for (let n = 0; pts.length - 1 > n; n++) {\n            if (pts[n].p >= p) {\n                a = pts[n];\n                b = pts[n + 1];\n            }\n        }\n        if (a === b) { return a; }\n\n        let f = Math.log(a.p \/ p) \/ Math.log(a.p \/ b.p);\n        f = Math.max(0, Math.min(1, f));\n\n        \/\/ Wind is blended as east\/north parts so 350\u00b0 and 10\u00b0 meet in the middle correctly\n        const rad = Math.PI \/ 180;\n        const ua = -a.ws * Math.sin(a.wd * rad);\n        const va = -a.ws * Math.cos(a.wd * rad);\n        const ub = -b.ws * Math.sin(b.wd * rad);\n        const vb = -b.ws * Math.cos(b.wd * rad);\n        const u = ua + (ub - ua) * f;\n        const v = va + (vb - va) * f;\n\n        return {\n            p: p,\n            h: a.h + (b.h - a.h) * f,\n            t: a.t + (b.t - a.t) * f,\n            td: a.td + (b.td - a.td) * f,\n            ws: Math.sqrt(u * u + v * v),\n            wd: (Math.atan2(-u, -v) \/ rad + 360) % 360\n        };\n    }\n\n    function drawProbe() {\n        const g = document.getElementById('snd-probe');\n        const tip = document.getElementById('snd-probe-tip');\n        const out = document.getElementById('snd-readout');\n        if (!g) { return; }\n        if (probeP === null) {\n            g.innerHTML = '';\n            tip.innerHTML = '';\n            out.innerHTML = IDLE_HINT;\n            return;\n        }\n        \/\/ Below the ground? Show the ground values instead.\n        const onGround = probeP >= currentPoints[0].p;\n        const p = onGround ? currentPoints[0].p : probeP;\n        const s = onGround ? currentPoints[0] : sampleAt(currentPoints, p);\n        const y = yOf(p);\n\n        g.innerHTML = `<line class=\"snd-probe-line\" x1=\"0\" y1=\"${y.toFixed(1)}\" x2=\"${PW}\" y2=\"${y.toFixed(1)}\"\/>` +\n                      `<circle class=\"snd-probe-t\" cx=\"${xOf(s.t, y).toFixed(1)}\" cy=\"${y.toFixed(1)}\" r=\"4\"\/>` +\n                     `<circle class=\"snd-probe-d\" cx=\"${xOf(s.td, y).toFixed(1)}\" cy=\"${y.toFixed(1)}\" r=\"4\"\/>`;\n\n        const ly = Math.max(12, y - 10).toFixed(1);\n        tip.innerHTML =\n            `<text class=\"snd-tip snd-tip-h\" x=\"6\" y=\"${ly}\">${Math.round(p)} hPa \u00b7 ${Math.round(s.h)} m<\/text>` +\n            `<text class=\"snd-tip snd-tip-w\" x=\"${PW - 6}\" y=\"${ly}\" text-anchor=\"end\">${Math.round(s.ws)} km\/h ${Math.round(s.wd)}\u00b0<\/text>` +\n            `<text class=\"snd-tip snd-tip-t\" x=\"${(xOf(s.t, y) + 8).toFixed(1)}\" y=\"${(y + 4).toFixed(1)}\">${s.t.toFixed(1)}\u00b0<\/text>` +\n            `<text class=\"snd-tip snd-tip-d\" x=\"${(xOf(s.td, y) - 8).toFixed(1)}\" y=\"${(y + 4).toFixed(1)}\" text-anchor=\"end\">${s.td.toFixed(1)}\u00b0<\/text>`;\n\n        out.innerHTML = `<div class=\"snd-readout-top\">${onGround ? 'Ground \u00b7 ' : ''}${Math.round(p)} hPa \u00b7 ${Math.round(s.h)} m<\/div>` +\n                        `<div><span class=\"snd-dot snd-dot-t\"><\/span>Temp ${s.t.toFixed(1)}\u00b0` +\n                         `<span class=\"snd-dot snd-dot-d\"><\/span>Dew ${s.td.toFixed(1)}\u00b0` +\n                        `<span class=\"snd-dot snd-dot-h\"><\/span>Hum ${Math.round(humidity(s.t, s.td))}%` +\n                        `<\/div>` +\n                        `<div><span class=\"snd-dot\" style=\"background:#5c6f82\"><\/span>Wind ${Math.round(s.ws)} km\/h ${Math.round(s.wd)}\u00b0 (${toCardinal(s.wd)})<\/div>`;\n    }\n\n    \/\/ Turn a finger \/ mouse position on the graph into a pressure level\n    function probeFromEvent(e) {\n        const svg = document.getElementById('snd-svg');\n        const r = svg.getBoundingClientRect();\n        const yView = (e.clientY - r.top) * (SKEW_H \/ r.height) - MT;\n        const y = Math.max(0, Math.min(PH, yView));\n        probeP = P_BOTTOM * Math.exp(-(PH - y) \/ PH * LN_RANGE);\n    }\n\n    function wireTouch() {\n        const overlay = document.getElementById('snd-touch');\n        overlay.addEventListener('pointerdown', e => {\n            overlay.setPointerCapture(e.pointerId);\n            probeFromEvent(e);\n            drawProbe();\n        });\n        overlay.addEventListener('pointermove', e => {\n            probeFromEvent(e);\n            drawProbe();\n        });\n    }\n\n    \/* ============================================================\n       SCREEN \u2014 build the layout once, then refresh as things change\n       ============================================================ *\/\n    function buildLayout(maxStep) {\n        const container = document.getElementById('sounding-chart-container');\n                container.innerHTML = `<button type=\"button\" class=\"snd-fs-btn\" id=\"snd-fs-btn\" aria-label=\"Full screen\">\n  <svg class=\"snd-fs-enter\" viewBox=\"0 0 24 24\"><path d=\"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5\"\/><\/svg>\n  <svg class=\"snd-fs-exit\" viewBox=\"0 0 24 24\"><path d=\"M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5\"\/><\/svg>\n<\/button>\n<div class=\"sounding-tag\">Sounding<\/div>\n<h3>${stationLabel}<\/h3>\n\n<div class=\"snd-toggle\">\n  <button type=\"button\" class=\"snd-toggle-btn\" id=\"snd-btn-graph\">Skew-T<\/button>\n  <button type=\"button\" class=\"snd-toggle-btn\" id=\"snd-btn-table\">Table<\/button>\n<\/div>\n\n<div id=\"snd-svg-holder\"><\/div>\n<div class=\"snd-time-block\" id=\"snd-time-block\">\n  <p class=\"sounding-meta\" id=\"snd-meta\"><\/p>\n  <div class=\"snd-slider-row\">\n    <span class=\"snd-slider-label\" id=\"snd-slider-label\">Now<\/span>\n    <input type=\"range\" id=\"snd-slider\" min=\"0\" max=\"${maxStep}\" step=\"1\" value=\"${stepNow}\">\n    <span class=\"snd-slider-end\">+${maxStep} h<\/span>\n  <\/div>\n<\/div>\n<div class=\"snd-readout\" id=\"snd-readout\"><\/div>\n\n<div id=\"snd-table-view\"><\/div>`;\n\n        document.getElementById('snd-slider').addEventListener('input', e => {\n            stepNow = Number(e.target.value);\n            renderAll();\n        });\n        document.getElementById('snd-btn-graph').onclick = () => { viewMode = 'graph'; applyViewMode(); };\n                document.getElementById('snd-btn-table').onclick = () => { viewMode = 'table'; applyViewMode(); };\n        document.getElementById('snd-fs-btn').onclick = toggleFullscreen;\n    }\n\n    \/\/ Full screen on\/off: overlay for every device, real browser full screen where allowed\n    function toggleFullscreen() {\n        const box = document.getElementById('sounding-chart-container');\n        const goFull = !box.classList.contains('snd-full');\n        box.classList.toggle('snd-full', goFull);\n        document.documentElement.style.overflow = goFull ? 'hidden' : '';\n        if (goFull) {\n            if (box.requestFullscreen) { box.requestFullscreen().catch(() => {}); }\n        } else if (document.fullscreenElement) {\n            document.exitFullscreen().catch(() => {});\n        }\n        renderAll();\n        box.scrollTop = 0;\n    }\n\n    \/\/ Show only the chosen view and light up its pill\n    function applyViewMode() {\n        const showGraph = (viewMode === 'graph');\n        document.getElementById('snd-svg-holder').style.display = showGraph ? 'block' : 'none';\n        document.getElementById('snd-readout').style.display = showGraph ? 'block' : 'none';\n        document.getElementById('snd-table-view').style.display = showGraph ? 'none' : 'block';\n        document.getElementById('snd-time-block').classList.toggle('table-mode', !showGraph);\n        document.getElementById('snd-btn-graph').classList.toggle('active', showGraph);\n        document.getElementById('snd-btn-table').classList.toggle('active', !showGraph);\n    }\n\n    \/\/ Everything that depends on the chosen hour is refreshed here, together\n    function renderAll() {\n        setGraphHeight();\n        const i = startIndex + stepNow;\n        const d = soundingData;\n        currentPoints = getPoints(d, i);\n\n        document.getElementById('snd-meta').textContent = formatStamp(d.hourly.time[i]) + ' \u00b7 model elevation ' + d.elevation + ' m';\n        document.getElementById('snd-slider-label').textContent = (stepNow === 0) ? 'Now' : '+' + stepNow + ' h';\n        document.getElementById('snd-svg-holder').innerHTML = buildSkewT(currentPoints);\n        document.getElementById('snd-table-view').innerHTML = buildTable(currentPoints);\n\n        wireTouch();\n        drawProbe();\n        applyViewMode();\n    }\n\n    async function fetchOpenMeteoSounding(lat, lon, stationName) {\n        const MODEL = 'icon_eu';\n        const container = document.getElementById('sounding-chart-container');\n        const vars = ['temperature','dew_point','wind_speed','wind_direction','geopotential_height'];\n        const hourly = vars.flatMap(v => LEVELS.map(l => `${v}_${l}hPa`)).join(',') + ',temperature_2m,dew_point_2m,surface_pressure,wind_speed_10m,wind_direction_10m';\n        container.innerHTML = `<p>Reading sounding data for <strong>${stationName}<\/strong>...<\/p>`;\n        try {\n            const url = 'https:\/\/api.open-meteo.com\/v1\/forecast?' + new URLSearchParams({ latitude: lat, longitude: lon, hourly: hourly, models: MODEL, forecast_days: FORECAST_DAYS });\n            const r = await fetch(url);\n            if (!r.ok) throw new Error(`Status ${r.status}`);\n            const d = await r.json();\n            const times = d.hourly.time;\n\n            let i = times.findIndex(t => new Date(t + 'Z') >= Date.now());\n            if (0 > i) i = 0;\n\n            soundingData = d;\n            startIndex = i;\n            stationLabel = stationName;\n\n            const maxStep = times.length - 1 - i;\n            if (stepNow > maxStep) stepNow = maxStep;\n\n            buildLayout(maxStep);\n            renderAll();\n        } catch (error) {\n            console.error(error);\n            container.innerHTML = `<p>Could not load sounding data (${error.message}).<\/p>`;\n        }\n    }\n\n    \/* ============================================================\n       MAP + BUTTONS (unchanged)\n       ============================================================ *\/\n        \/\/ Re-draw when the screen changes shape (rotation) or full screen starts\/ends\n    window.addEventListener('resize', () => {\n        if (!soundingData) { return; }\n        const before = SKEW_H;\n        setGraphHeight();\n        if (SKEW_H !== before) { renderAll(); }\n    });\n    document.addEventListener('fullscreenchange', () => {\n        const box = document.getElementById('sounding-chart-container');\n        if (!document.fullscreenElement) {\n            box.classList.remove('snd-full');      \/\/ Esc key exits both modes together\n            document.documentElement.style.overflow = '';\n        }\n        if (soundingData) { renderAll(); }\n    });\n\n        const map = L.map('sounding-map').setView([32.75, -16.95], 9);\n    L.tileLayer('https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png', {\n        maxZoom: 18,\n        attribution: '\\u00a9 OpenStreetMap contributors',\n        referrerPolicy: 'strict-origin-when-cross-origin'\n    }).addTo(map);\n\n    let pin = null;\n    function pick(lat, lon, name) {\n        if (pin) map.removeLayer(pin);\n        pin = L.marker([lat, lon]).addTo(map);\n        fetchOpenMeteoSounding(lat, lon, name);\n    }\n\n    \/\/ Buttons get .spot-btn so styling lives in CSS, not inline\n    const btnBox = document.getElementById('spot-buttons');\n    weatherStations.forEach(s => {\n        const b = document.createElement('button');\n        b.textContent = s.name;\n        b.className = 'spot-btn';\n        b.onclick = () => { map.setView([s.lat, s.lon], 11); pick(s.lat, s.lon, s.name); };\n        btnBox.appendChild(b);\n    });\n\n    map.on('click', e => pick(e.latlng.lat, e.latlng.lng, `Map point (${e.latlng.lat.toFixed(3)}, ${e.latlng.lng.toFixed(3)})`));\n}\n(function waitForLeaflet() {\n    if (window.L) { startSoundingMap(); } else { setTimeout(waitForLeaflet, 200); }\n})();\n<\/script>\n<\/template>\n\n\n\n<!-- Precious custom sounding -->\n<link rel=\"stylesheet\" href=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.css\">\n\n<style>\n\/* ============================================================\n   SOUNDING WIDGET \u2014 \"Cockpit Light\" look\n   Same design language as the Airport Time widget:\n   soft card, rounded corners, airy type, muted colors.\n   All styles live here so tweaks stay in one place.\n   ============================================================ *\/\n\n\/* ---- The whole widget is one soft card ---- *\/\n#sounding-widget {\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n  background: rgba(237,237,237,0.8);\n  border: 1px solid #eef2f5;\n  border-radius: 12px;\n  box-shadow: 0 10px 30px rgba(0,0,0,0.04);\n  max-width: 590px;         \/* a touch wider than the time widget so the table breathes *\/\n  margin: 10px auto;\n  overflow: hidden;          \/* rounds the map's top corners cleanly *\/\n  color: #444;\n}\n\n\/* ---- Map ---- *\/\n#sounding-map {\n  width: 100%;\n  height: 380px;\n  border-bottom: 1px solid #eef2f5;\n}\n\n\/* ---- Spot buttons ---- *\/\n#spot-buttons {\n  padding: 8px 9px 3px;\n  text-align: center;\n}\n.spot-btn {\n  margin: 0 4px 6px;\n  padding: 4px 10px;\n  border-radius: 20px;\n  border: 0px solid #eef2f5;\n  background: #fff;\n  color: #3b5775;\n  font: inherit;\n  font-size: 0.75rem;\n  font-weight: 500;\n  letter-spacing: 0.3px;\n  cursor: pointer;\n  transition: background 0.15s ease, border-color 0.15s ease;\n}\n.spot-btn:hover {\n  background: rgba(59,87,117,0.06);\n  border-color: #3b5775;\n}\n\n\/* ---- Results panel (graph and table live here) ---- *\/\n#sounding-chart-container {\n  padding: 12px 11px 15px;\n  font-variant-numeric: tabular-nums;   \/* keeps numbers aligned in columns *\/\n}\n\n\/* Small uppercase tag above the station name *\/\n.sounding-tag {\n  font-size: 0.7rem;\n  text-transform: uppercase;\n  letter-spacing: 2px;\n  color: #8898aa;\n  text-align: center;\n  font-weight: 600;\n  margin-bottom: 11px;\n}\n\n\/* Station name \u2014 big & delicate *\/\n#sounding-chart-container h3 {\n  font-size: 1.3rem;\n  font-weight: 400;\n  letter-spacing: -0.5px;\n  color: #2d3436;\n  text-align: center;\n  margin: 0 0 4px;\n  padding-bottom: 10px;\n  white-space: nowrap;\n}\n\n\/* Date + model elevation line \u2014 muted, centered *\/\n#sounding-chart-container .sounding-meta {\n  font-size: 0.8rem;\n  font-weight: 600;          \/* keeps the same weight it had before the move *\/\n  color: #8898aa;\n  text-align: center;\n  margin: 6px 0;\n  white-space: nowrap;\n  padding-bottom: 10px;\n}\n\n\/* Holds date + slider together. Graph: date on top. Table: slider on top. *\/\n.snd-time-block {\n  display: flex;\n  flex-direction: column;\n}\n.snd-time-block.table-mode {\n  flex-direction: column-reverse;\n}\n\n\/* Loading \/ error messages \u2014 quiet and centered *\/\n#sounding-chart-container > p {\n  text-align: center;\n  color: #8898aa;\n  font-size: 0.9rem;\n  font-weight: 600;\n}\n\n\/* ---- Graph \/ Table switch (two gentle pills) ---- *\/\n.snd-toggle {\n  display: flex;\n  justify-content: center;\n  gap: 6px;\n  margin: 0 0 12px;\n}\n.snd-toggle-btn {\n  padding: 5px 18px;\n  border-radius: 20px;\n  border: 0;\n  background: #fff;\n  color: #3b5775;\n  font: inherit;\n  font-size: 0.75rem;\n  font-weight: 500;\n  letter-spacing: 0.3px;\n  cursor: pointer;\n  transition: background 0.15s ease, color 0.15s ease;\n}\n.snd-toggle-btn:hover {\n  background: rgba(59,87,117,0.06);\n}\n\/* The pill that is currently showing *\/\n.snd-toggle-btn.active {\n  background: #3b5775;\n  color: #fff;\n}\n\n\/* ---- Time slider row ---- *\/\n.snd-slider-row {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 0 4px;\n  margin: 0 0 6px;\n}\n.snd-slider-row input[type=\"range\"] {\n  flex: 1;\n  margin: 0;\n  accent-color: #3b5775;\n  cursor: pointer;\n}\n.snd-slider-label {\n  min-width: 42px;\n  text-align: right;\n  font-size: 0.78rem;\n  font-weight: 500;\n  color: #3b5775;\n}\n.snd-slider-end {\n  min-width: 42px;\n  font-size: 0.75rem;\n  color: #8898aa;\n}\n\n\/* ---- Skew-T graph ---- *\/\n.snd-svg {\n  display: block;\n  width: 100%;\n  height: auto;\n  touch-action: none;        \/* lets a finger drag along the graph without scrolling the page *\/\n  cursor: crosshair;\n  margin-top: -40px;\n}\n.snd-plot-bg {\n  fill: rgba(255,255,255,0.65);\n}\n.snd-ground {\n  fill: rgba(59,87,117,0.12);\n}\n.snd-ground-edge {\n  stroke: rgba(59,87,117,0.35);\n  stroke-width: 1;\n}\n.snd-isobar {\n  stroke: #d6dde4;\n  stroke-width: 1;\n}\n.snd-isotherm {\n  stroke: #dde4ea;\n  stroke-width: 1;\n}\n.snd-isotherm-zero {\n  stroke: #8fb6d6;\n  stroke-width: 1.4;\n  stroke-dasharray: 4 3;\n}\n.snd-axis-text {\n  fill: #8898aa;\n  font-size: 11px;\n}\n.snd-line-t {\n  fill: none;\n  stroke: #d1604d;\n  stroke-width: 2.4;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n}\n.snd-line-d {\n  fill: none;\n  stroke: #3f87a6;\n  stroke-width: 2.4;\n  stroke-linejoin: round;\n  stroke-linecap: round;\n}\n.snd-barb {\n  stroke: #5c6f82;\n  stroke-width: 1.3;\n  stroke-linecap: round;\n  fill: #5c6f82;\n}\n.snd-probe-line {\n  stroke: #3b5775;\n  stroke-width: 1;\n  stroke-dasharray: 3 3;\n  opacity: 0.6;\n}\n.snd-probe-t {\n  fill: #fff;\n  stroke: #d1604d;\n  stroke-width: 2;\n}\n.snd-probe-d {\n  fill: #fff;\n  stroke: #3f87a6;\n  stroke-width: 2;\n}\n\/* Gentle tooltip labels on the probe line *\/\n.snd-tip {\n  font-size: 12px;\n  font-weight: 500;\n  paint-order: stroke;\n  stroke: rgba(255,255,255,0.9);\n  stroke-width: 3px;\n  stroke-linejoin: round;\n  pointer-events: none;\n}\n.snd-tip-h, .snd-tip-w { \nfill: #5c6f82; \n}\n.snd-tip-t { \nfill: #d1604d; \n}\n.snd-tip-d { \nfill: #3f87a6; \n}\n\n\/* Soft see-through patch behind each tooltip text, so the minus signs stay readable *\/\n.snd-tip-bg {\n  fill: rgba(255,255,255,0.75);\n  pointer-events: none;\n}\n\n\/* ---- Touch readout under the graph ---- *\/\n.snd-readout {\n  min-height: 66px;           \/* keeps the layout steady when the text changes *\/\n  margin-top: 6px;\n  text-align: center;\n  font-size: 0.82rem;\n  color: #444;\n}\n.snd-readout-top {\n  margin-bottom: 3px;\n  font-weight: 500;\n  color: #2d3436;\n}\n.snd-readout-hint {\n  color: #8898aa;\n}\n.snd-dot {\n  display: inline-block;\n  width: 8px;\n  height: 8px;\n  margin: 0 4px 0 8px;\n  border-radius: 50%;\n}\n.snd-dot-t {\n  background: #d1604d;\n}\n.snd-dot-d {\n  background: #3f87a6;\n}\n.snd-dot-h {\n  background: #7d9b76;\n}\n\n\/* ---- Table ---- *\/\n#sounding-chart-container table {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13.5px;\n}\n\n\/* Header row: small caps, muted, thin bottom rule *\/\n#sounding-chart-container th {\n  font-size: 0.65rem;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 1.5px;\n  color: #444;\n  padding: 8px 4px 10px;\n  border-bottom: 1px solid #eef2f5;\n  text-align: center;\n  white-space: nowrap;\n}\n\n\/* Body cells: centered, airy, quiet *\/\n#sounding-chart-container td {\n  padding: 8px 4px;\n  text-align: center;\n  white-space: nowrap;\n  color: #444;\n  font-weight: 410;\n}\n\n\/* Zebra stripes \u2014 whisper-light, every other level row *\/\n#sounding-chart-container tbody tr:nth-child(odd) td {\n  background: rgba(0,0,0,0.025);\n}\n\n\/* Ground row: gentle slate tint so it reads as \"the surface\" *\/\n#sounding-chart-container tr.sounding-ground td {\n  background: rgba(59,87,117,0.08);\n  font-weight: 500;\n  color: #2d3436;\n}\n\n\/* Soft line on the 800 hPa row, roughly the height of Madeira's high peaks *\/\n#sounding-chart-container tr.sounding-mark td {\n  border-bottom: 1.1px solid rgba(59,87,117,0.3);\n}\n\n\/* ---- Full screen button + immersive mode ---- *\/\n#sounding-chart-container { position: relative; }\n\n.snd-fs-btn {\n  position: absolute;\n  top: 8px;\n  right: 10px;\n  z-index: 2;\n  width: 32px;\n  height: 32px;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  background: #fff;\n  color: #3b5775;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n.snd-fs-btn:hover {\n  background: rgba(59,87,117,0.06);\n}\n.snd-fs-btn svg {\n  width: 16px;\n  height: 16px;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 2;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.snd-fs-btn .snd-fs-exit { display: none; }\n.snd-full .snd-fs-btn .snd-fs-enter { display: none; }\n.snd-full .snd-fs-btn .snd-fs-exit { display: block; }\n\n#sounding-chart-container.snd-full {\n  position: fixed;\n  inset: 0;\n  z-index: 999999;           \/* above the WordPress admin bar *\/\n  box-sizing: border-box;\n  background: #ededed;\n  overflow-y: auto;\n  -webkit-overflow-scrolling: touch;\n  padding: max(12px, env(safe-area-inset-top)) 6px 20px;\n}\n.snd-full .snd-fs-btn {\n  top: max(8px, env(safe-area-inset-top));\n}\n\/* Keeps content a comfortable width on wide screens *\/\n#sounding-chart-container.snd-full > *:not(.snd-fs-btn) {\n  max-width: 640px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\/* The 300 must match the 300 in setGraphHeight() *\/\n.snd-full .snd-svg {\n  max-height: max(320px, calc(100vh - 300px));\n  max-height: max(320px, calc(100dvh - 300px));\n}\n\/* Desktop only: less reserved space, so the graph can grow *\/\n@media (min-width: 601px) {\n  .snd-full .snd-svg {\n    max-height: max(320px, calc(100vh - 235px));\n    max-height: max(320px, calc(100dvh - 235px));\n  }\n}\n\n\/* ---- Credit line under the card ---- *\/\n.sounding-credit {\n  font-size: 0.75rem;\n  color: #8898aa;\n  text-align: center;\n  padding: 0 15px 18px;\n}\n.sounding-credit a {\n  color: #8898aa;\n  text-decoration: underline;\n}\n\n\/* ---- Mobile: tighten the table a notch ---- *\/\n@media (max-width: 600px) {\n\/* Less side padding so the graph uses more of the screen *\/\n  #sounding-chart-container { padding: 12px 3px 15px; }\n\n  \/* Bigger touch target for the time slider *\/\n  .snd-slider-row input[type=\"range\"] {\n    -webkit-appearance: none;\n    appearance: none;\n    height: 44px;\n    background: transparent;\n  }\n  .snd-slider-row input[type=\"range\"]::-webkit-slider-runnable-track {\n    height: 4px;\n    background: #cfd8e0;\n    border-radius: 2px;\n  }\n  .snd-slider-row input[type=\"range\"]::-webkit-slider-thumb {\n    -webkit-appearance: none;\n    width: 26px;\n    height: 26px;\n    margin-top: -11px;       \/* centers the thumb on the track *\/\n    border-radius: 50%;\n    background: #3b5775;\n  }\n  .snd-slider-row input[type=\"range\"]::-moz-range-track {\n    height: 4px;\n    background: #cfd8e0;\n    border-radius: 2px;\n  }\n  .snd-slider-row input[type=\"range\"]::-moz-range-thumb {\n    width: 26px;\n    height: 26px;\n    border: 0;\n    border-radius: 50%;\n    background: #3b5775;\n  }\n\n  #sounding-chart-container table { font-size: 12.5px; }\n  #sounding-chart-container th { letter-spacing: 1px; font-size: 0.6rem; }\n}\n\n\/* ---- Mobile: bigger axis + tooltip text for easier reading ---- *\/\n@media (max-width: 600px) {\n  .snd-axis-text {\n    font-size: 14px;\n  }\n  .snd-tip {\n    font-size: 14px;\n    stroke-width: 4px;   \/* thicker white outline so it pops over the curves *\/\n  }\n  .snd-svg {\n    \/* push the SVG a hair higher so the bigger text doesn't clip at the top *\/\n    margin-top: -32px;\n  }\n}\n\n\/* ---- Zoom buttons (same look as the full screen button) ---- *\/\n.snd-zoom-btn {\n  position: absolute;\n  top: 8px;\n  z-index: 2;\n  width: 32px;\n  height: 32px;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  background: #fff;\n  color: #3b5775;\n  font: inherit;\n  font-size: 18px;\n  line-height: 1;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n.snd-zoom-btn:hover {\n  background: rgba(59,87,117,0.06);\n}\n.snd-zoom-btn:disabled {\n  opacity: 0.35;\n  cursor: default;\n}\n#snd-zoom-in {\n  left: 10px;\n}\n#snd-zoom-out {\n  left: 48px;\n}\n.snd-full .snd-zoom-btn {\n  top: max(8px, env(safe-area-inset-top));\n}\n\n\/* ---- Up \/ down arrows sit in the Skew-T \/ Table row ---- *\/\n.snd-pan-btn {\n  padding: 5px 12px;\n}\n.snd-toggle-btn:disabled {\n  opacity: 0.35;\n  cursor: default;\n}\n\n\/* ---- No text selection (and no search suggestions) on graph and table ---- *\/\n#sounding-widget,\n#sounding-widget * {\n  -webkit-user-select: none;\n  user-select: none;\n  -webkit-touch-callout: none;\n  -webkit-tap-highlight-color: transparent;\n}\n\n<\/style>\n\n<div id=\"sounding-widget\">\n  <div id=\"sounding-map\"><\/div>\n  <div id=\"spot-buttons\"><\/div>\n  <div id=\"sounding-chart-container\"><p>Tap the map or buttons to load the sounding<\/p><\/div>\n  <div class=\"sounding-credit\">Weather data by <a href=\"https:\/\/open-meteo.com\" target=\"_blank\">Open-Meteo.com<\/a> (ICON-EU 7km)<\/div>\n<\/div>\n\n<script src=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.js\"><\/script>\n<script>\nfunction startSoundingMap() {\n    const weatherStations = [\n        { name: \"Madalena\", lat: 32.6985, lon: -17.131 },\n        { name: \"Canhas\", lat: 32.70353, lon: -17.12599 },      \n        { name: \"Maiata\", lat: 32.76724, lon: -16.82228 },\n        { name: \"Portela\", lat: 32.74718, lon: -16.82599 },       \n        { name: \"Pico Areeiro\", lat: 32.7355, lon: -16.928 },\n        { name: \"Airport\", lat: 32.6902, lon: -16.783 },\n        { name: \"Porto Santo\", lat: 33.0313, lon: -16.3679 }\n    ];\n\n    \/* ============================================================\n       SETTINGS \u2014 gentle knobs you can adjust by hand\n       ============================================================ *\/\n    const LEVELS = [1000,975,950,925,900,875,850,825,800,775,750,700,600,500,400,300,200,100];\n    const FORECAST_DAYS = 4;     \/\/ how many days of hours the slider can reach\n    const P_BOTTOM = 1030;       \/\/ bottom of the graph (hPa), always the ground end\n    let P_TOP = 300;             \/\/ top of the graph (hPa), changes with the zoom buttons\n    const ZOOM_TOPS = [300, 500, 650, 750];   \/\/ the zoom steps: each one is a top-of-graph pressure\n    let zoomIdx = 0;             \/\/ 0 = full view, higher = more zoomed in\n    let T_MIN = -10;             \/\/ coldest temperature on the bottom edge (setGraphHeight picks it)\n    const T_MAX = 35;            \/\/ warmest temperature on the bottom edge\n    const SKEW = 0.8;            \/\/ how much the temperature lines lean to the right\n    const DAY_NAMES = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];\n\n    \/* ---- Graph size (in drawing units, it scales to the card) ---- *\/\n    const SKEW_W = 440;\n    let SKEW_H = 412;            \/\/ graph height, chosen by setGraphHeight() below\n    const ML = 34;               \/\/ left margin (pressure numbers)\n    const MR = 50;               \/\/ right margin (wind barbs)\n    const MT = 44;               \/\/ top margin (empty band where hPa \/ kt sit)\n    const MB = 26;               \/\/ bottom margin (temperature numbers)\n    const PW = SKEW_W - ML - MR;\n    const BARB_X = PW + 26;      \/\/ where the wind barbs and the \"kt\" label are centered\n    let PH = SKEW_H - MT - MB;\n    let PX_PER_DEG = PW \/ (T_MAX - T_MIN);\n        let LN_RANGE = Math.log(P_BOTTOM \/ P_TOP);\n    const LN_FULL = Math.log(1030 \/ 300);   \/\/ the full view's range; the lean is scaled against it\n\n    \/\/ Picks the graph height: taller on phones, and filled to the screen in full screen\n    function setGraphHeight() {\n        const phone = window.matchMedia('(max-width: 600px)').matches;\n        let h = phone ? 600 : 412;           \/\/ <- the two heights to tweak by hand\n        const box = document.getElementById('sounding-chart-container');\n        if (box.classList.contains('snd-full')) {\n            const reserve = (window.innerWidth > 600) ? 235 : 300;\n            const availH = Math.max(320, window.innerHeight - reserve);\n            const availW = Math.min(window.innerWidth - 12, 640);\n            h = Math.max(412, Math.min(760, Math.round(SKEW_W * availH \/ availW)));\n        }\n        SKEW_H = h;\n        PH = SKEW_H - MT - MB;\n        T_MIN = (h > 500) ? -10 : -20;   \/\/ tall graph = -10, standard = -20\n        PX_PER_DEG = PW \/ (T_MAX - T_MIN);\n    }\n\n    \/* ============================================================\n       SHARED STATE \u2014 what the widget is showing right now\n       ============================================================ *\/\n    let soundingData = null;     \/\/ the downloaded forecast\n    let startIndex = 0;          \/\/ which hour counts as \"now\"\n    let stepNow = 0;             \/\/ slider position (0 = now)\n    let viewMode = 'graph';      \/\/ 'graph' or 'table'\n    let probeP = null;           \/\/ pressure where the finger last touched the graph\n    let currentPoints = [];      \/\/ the levels for the hour on screen\n    let stationLabel = '';\n\n    const IDLE_HINT = '<div class=\"snd-readout-hint\">Touch the graph to read values<br><span class=\"snd-dot snd-dot-t\"><\/span>Temperature<span class=\"snd-dot snd-dot-d\"><\/span>Dew point<span class=\"snd-dot snd-dot-h\"><\/span>Humidity<\/div>';\n\n    \/\/ Turn a wind direction in degrees into a compass label, e.g. 114 -> \"ESE\"\n    function toCardinal(deg) {\n        const pts = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'];\n        return pts[Math.round(deg \/ 22.5) % 16];\n    }\n\n       function pad(n) {\n        return String(n).padStart(2, '0');\n    }\n\n    \/\/ Relative humidity (%) from temperature and dew point (Magnus formula)\n    function humidity(t, td) {\n        const a = 17.625;\n        const b = 243.04;\n        const rh = 100 * Math.exp(a * td \/ (b + td)) \/ Math.exp(a * t \/ (b + t));\n        return Math.max(0, Math.min(100, rh));\n    }\n\n    \/\/ \"2026-11-04T14:00\" -> \"Wed 04\/11 14:00 UTC\"\n    function formatStamp(iso) {\n        const d0 = new Date(iso + 'Z');\n        return DAY_NAMES[d0.getUTCDay()] + ' ' + pad(d0.getUTCDate()) + '\/' + pad(d0.getUTCMonth() + 1) + ' ' + pad(d0.getUTCHours()) + ':' + pad(d0.getUTCMinutes()) + ' UTC';\n    }\n\n    \/* ============================================================\n       DATA \u2014 gather the levels for one hour (ground first, then up)\n       ============================================================ *\/\n    function getPoints(d, i) {\n        const h = d.hourly;\n        const pts = [];\n        const sp = h.surface_pressure[i];\n\n        pts.push({\n            p: sp,\n            h: d.elevation,\n            t: h.temperature_2m[i],\n            td: h.dew_point_2m[i],\n            ws: h.wind_speed_10m[i] || 0,\n            wd: h.wind_direction_10m[i] || 0,\n            ground: true\n        });\n\n        LEVELS.forEach(l => {\n            \/\/ CRUCIAL: nested ifs instead of '&&' and '<' so WordPress live view stays happy\n            if (sp > l) {\n                const t = h['temperature_' + l + 'hPa'][i];\n                const td = h['dew_point_' + l + 'hPa'][i];\n                const gh = h['geopotential_height_' + l + 'hPa'][i];\n                if ([t, td, gh].every(v => v !== null)) {\n                    pts.push({\n                        p: l,\n                        h: gh,\n                        t: t,\n                        td: td,\n                        ws: h['wind_speed_' + l + 'hPa'][i] || 0,\n                        wd: h['wind_direction_' + l + 'hPa'][i] || 0,\n                        ground: false\n                    });\n                }\n            }\n        });\n        return pts;\n    }\n\n    \/* ============================================================\n       TABLE \u2014 same columns as before\n       ============================================================ *\/\n    function buildTable(pts) {\n        const rows = pts.map(q => {\n                        const cls = q.ground ? ' class=\"sounding-ground\"' : (q.p === 800 ? ' class=\"sounding-mark\"' : '');\n            return `<tr${cls}><td>${Math.round(q.p)}<\/td><td>${Math.round(q.h)}<\/td><td>${q.t.toFixed(1)}<\/td><td>${q.td.toFixed(1)}<\/td><td>${Math.round(q.ws)} \/ ${Math.round(q.wd)}\u00b0 (${toCardinal(q.wd)})<\/td><\/tr>`;\n        }).join('');\n        return `<table><thead><tr><th>hPa<\/th><th>Height m<\/th><th>Temp \u00b0C<\/th><th>Dew \u00b0C<\/th><th>Wind km\/h<\/th><\/tr><\/thead><tbody>${rows}<\/tbody><\/table>`;\n    }\n\n    \/* ============================================================\n       SKEW-T \u2014 position helpers\n       y = how far down from the top of the plot (0 = top, PH = bottom)\n       ============================================================ *\/\n    function yOf(p) {\n        return PH * (1 - Math.log(P_BOTTOM \/ p) \/ LN_RANGE);\n    }\n    function xOf(t, y) {\n           return (t - T_MIN) * PX_PER_DEG + (PH - y) * SKEW * LN_RANGE \/ LN_FULL;\n    }\n\n    \/\/ One wind barb, drawn pointing the way the wind comes FROM. Speed in km\/h -> knots.\n    function windBarb(x, y, kmh, dir) {\n        const kt = Math.round(kmh \/ 1.852 \/ 5) * 5;\n        if (kt === 0) {\n            return `<circle class=\"snd-barb\" cx=\"${x}\" cy=\"${y}\" r=\"3.2\" fill=\"none\"\/>`;\n        }\n        const L = 22;\n        let rest = kt;\n        const flags = Math.floor(rest \/ 50);\n        rest = rest - flags * 50;\n        const fulls = Math.floor(rest \/ 10);\n        rest = rest - fulls * 10;\n        const half = rest > 4 ? 1 : 0;\n\n        let shapes = `<line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"${-L}\"\/><circle cx=\"0\" cy=\"0\" r=\"1.8\"\/>`;\n        let pos = -L;\n        for (let n = 0; flags > n; n++) {\n            shapes += `<polygon points=\"0,${pos} 9,${pos} 0,${pos + 5}\"\/>`;\n            pos += 6;\n        }\n        for (let n = 0; fulls > n; n++) {\n            shapes += `<line x1=\"0\" y1=\"${pos}\" x2=\"9\" y2=\"${pos - 3}\"\/>`;\n            pos += 4;\n        }\n        if (half === 1) {\n            if (pos === -L) { pos += 4; }\n            shapes += `<line x1=\"0\" y1=\"${pos}\" x2=\"4.5\" y2=\"${pos - 1.5}\"\/>`;\n        }\n        return `<g class=\"snd-barb\" transform=\"translate(${x},${y}) rotate(${dir})\">${shapes}<\/g>`;\n    }\n\n    \/* ============================================================\n       SKEW-T \u2014 draw the whole graph as one SVG picture\n       ============================================================ *\/\n    function buildSkewT(pts) {\n        \/\/ Ground shading (only if the ground sits above the bottom line)\n        const yG = yOf(pts[0].p);\n        let ground = '';\n        if (PH > yG) {\n            ground = `<rect class=\"snd-ground\" x=\"0\" y=\"${yG.toFixed(1)}\" width=\"${PW}\" height=\"${(PH - yG).toFixed(1)}\"\/>` +\n                     `<line class=\"snd-ground-edge\" x1=\"0\" y1=\"${yG.toFixed(1)}\" x2=\"${PW}\" y2=\"${yG.toFixed(1)}\"\/>`;\n        }\n\n        \/\/ Grid: horizontal pressure lines\n                const pStep = (P_BOTTOM \/ P_TOP > 1.8) ? 100 : 50;\n        const pLines = [];\n        for (let p = 1000; p >= P_TOP; p -= pStep) {\n            if (P_BOTTOM >= p) {\n                pLines.push(p);\n            }\n        }\n        let isobars = '';\n        let pLabels = '';\n        pLines.forEach(p => {\n            if (p >= P_TOP) {\n                const y = yOf(p);\n                isobars += `<line class=\"snd-isobar\" x1=\"0\" y1=\"${y.toFixed(1)}\" x2=\"${PW}\" y2=\"${y.toFixed(1)}\"\/>`;\n                pLabels += `<text class=\"snd-axis-text\" x=\"-6\" y=\"${(y + 4).toFixed(1)}\" text-anchor=\"end\">${p}<\/text>`;\n            }\n        });\n\n        \/\/ Grid: leaning temperature lines (every 10 degrees)\n        let isotherms = '';\n                Array.from({ length: 22 }, (_, n) => -120 + n * 10).forEach(t => {\n            const cls = (t === 0) ? 'snd-isotherm-zero' : 'snd-isotherm';\n            isotherms += `<line class=\"${cls}\" x1=\"${xOf(t, PH).toFixed(1)}\" y1=\"${PH}\" x2=\"${xOf(t, 0).toFixed(1)}\" y2=\"0\"\/>`;\n        });\n\n        \/\/ Temperature numbers along the bottom edge\n        let tLabels = '';\n                Array.from({ length: 16 }, (_, n) => -60 + n * 10).forEach(t => {\n            const lx = xOf(t, PH);\n            if (lx > -1) {\n                if (PW + 1 > lx) {\n                    tLabels += `<text class=\"snd-axis-text\" x=\"${lx.toFixed(1)}\" y=\"${PH + 15}\" text-anchor=\"middle\">${t}\u00b0<\/text>`;\n                }\n            }\n        });\n\n         tLabels += `<text class=\"snd-axis-text\" x=\"-6\" y=\"${14 - MT}\" text-anchor=\"end\">hPa<\/text>`;\n        tLabels += `<text class=\"snd-axis-text\" x=\"${BARB_X}\" y=\"${14 - MT}\" text-anchor=\"middle\">kt<\/text>`;\n\n        \/\/ The two curves\n        const tPts = pts.map(q => xOf(q.t, yOf(q.p)).toFixed(1) + ',' + yOf(q.p).toFixed(1)).join(' ');\n        const dPts = pts.map(q => xOf(q.td, yOf(q.p)).toFixed(1) + ',' + yOf(q.p).toFixed(1)).join(' ');\n\n        \/\/ Wind barbs on the right, spaced so they never crowd each other\n        let barbs = '';\n        let lastY = PH + 100;\n        pts.forEach(q => {\n            const y = yOf(q.p);\n              if (Math.min(y + 1, PH + 1 - y) > 0) {\n                if (lastY - y > 15) {\n        barbs += windBarb(BARB_X, y.toFixed(1), q.ws, Math.round(q.wd));\n                    lastY = y;\n                }\n            }\n        });\n\n        return `<svg id=\"snd-svg\" class=\"snd-svg\" viewBox=\"0 0 ${SKEW_W} ${SKEW_H}\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n  <defs>\n    <clipPath id=\"snd-clip\"><rect x=\"0\" y=\"0\" width=\"${PW}\" height=\"${PH}\"\/><\/clipPath>\n  <\/defs>\n  <g transform=\"translate(${ML},${MT})\">\n    <rect class=\"snd-plot-bg\" x=\"0\" y=\"0\" width=\"${PW}\" height=\"${PH}\" rx=\"6\"\/>\n    <g clip-path=\"url(#snd-clip)\">\n      ${ground}\n      ${isobars}\n      ${isotherms}\n      <polyline class=\"snd-line-d\" points=\"${dPts}\"\/>\n      <polyline class=\"snd-line-t\" points=\"${tPts}\"\/>\n      <g id=\"snd-probe\"><\/g>\n    <\/g>\n    ${pLabels}\n    ${tLabels}\n    ${barbs}\n    <g id=\"snd-probe-tip\"><\/g>\n    <rect id=\"snd-touch\" x=\"${-ML}\" y=\"0\" width=\"${SKEW_W}\" height=\"${PH}\" fill=\"transparent\"\/>\n  <\/g>\n<\/svg>`;\n    }\n\n    \/* ============================================================\n       TOUCH READOUT \u2014 values at any height, blended between levels\n       ============================================================ *\/\n    function sampleAt(pts, p) {\n        let a = pts[0];\n        let b = pts[0];\n        for (let n = 0; pts.length - 1 > n; n++) {\n            if (pts[n].p >= p) {\n                a = pts[n];\n                b = pts[n + 1];\n            }\n        }\n        if (a === b) { return a; }\n\n        let f = Math.log(a.p \/ p) \/ Math.log(a.p \/ b.p);\n        f = Math.max(0, Math.min(1, f));\n\n        \/\/ Wind is blended as east\/north parts so 350\u00b0 and 10\u00b0 meet in the middle correctly\n        const rad = Math.PI \/ 180;\n        const ua = -a.ws * Math.sin(a.wd * rad);\n        const va = -a.ws * Math.cos(a.wd * rad);\n        const ub = -b.ws * Math.sin(b.wd * rad);\n        const vb = -b.ws * Math.cos(b.wd * rad);\n        const u = ua + (ub - ua) * f;\n        const v = va + (vb - va) * f;\n\n        return {\n            p: p,\n            h: a.h + (b.h - a.h) * f,\n            t: a.t + (b.t - a.t) * f,\n            td: a.td + (b.td - a.td) * f,\n            ws: Math.sqrt(u * u + v * v),\n            wd: (Math.atan2(-u, -v) \/ rad + 360) % 360\n        };\n    }\n\n    function drawProbe() {\n        const g = document.getElementById('snd-probe');\n        const tip = document.getElementById('snd-probe-tip');\n        const out = document.getElementById('snd-readout');\n        if (!g) { return; }\n        if (probeP === null) {\n            g.innerHTML = '';\n            tip.innerHTML = '';\n            out.innerHTML = IDLE_HINT;\n            return;\n        }\n        \/\/ Below the ground? Show the ground values instead.\n        const onGround = probeP >= currentPoints[0].p;\n        const p = onGround ? currentPoints[0].p : probeP;\n        const s = onGround ? currentPoints[0] : sampleAt(currentPoints, p);\n        const y = yOf(p);\n\n        g.innerHTML = `<line class=\"snd-probe-line\" x1=\"0\" y1=\"${y.toFixed(1)}\" x2=\"${PW}\" y2=\"${y.toFixed(1)}\"\/>` +\n                      `<circle class=\"snd-probe-t\" cx=\"${xOf(s.t, y).toFixed(1)}\" cy=\"${y.toFixed(1)}\" r=\"4\"\/>` +\n                     `<circle class=\"snd-probe-d\" cx=\"${xOf(s.td, y).toFixed(1)}\" cy=\"${y.toFixed(1)}\" r=\"4\"\/>`;\n\n        const ly = Math.max(12, y - 10).toFixed(1);\n        tip.innerHTML =\n            `<text class=\"snd-tip snd-tip-h\" x=\"6\" y=\"${ly}\">${Math.round(p)} hPa \u00b7 ${Math.round(s.h)} m<\/text>` +\n            `<text class=\"snd-tip snd-tip-w\" x=\"${PW - 6}\" y=\"${ly}\" text-anchor=\"end\">${Math.round(s.ws)} km\/h ${Math.round(s.wd)}\u00b0<\/text>` +\n            `<text class=\"snd-tip snd-tip-t\" x=\"${(xOf(s.t, y) + 8).toFixed(1)}\" y=\"${(y + 4).toFixed(1)}\">${s.t.toFixed(1)}\u00b0<\/text>` +\n            `<text class=\"snd-tip snd-tip-d\" x=\"${(xOf(s.td, y) - 8).toFixed(1)}\" y=\"${(y + 4).toFixed(1)}\" text-anchor=\"end\">${s.td.toFixed(1)}\u00b0<\/text>`;\n\n                \/\/ Put a small soft patch behind each tooltip text (measured after the text is drawn)\n        try {\n            Array.from(tip.querySelectorAll('text')).forEach(tx => {\n                const b = tx.getBBox();\n                const patch = document.createElementNS('http:\/\/www.w3.org\/2000\/svg', 'rect');\n                patch.setAttribute('class', 'snd-tip-bg');\n                patch.setAttribute('x', b.x - 3);\n                patch.setAttribute('y', b.y - 1);\n                patch.setAttribute('width', b.width + 6);\n                patch.setAttribute('height', b.height + 2);\n                patch.setAttribute('rx', 4);\n                tip.insertBefore(patch, tx);\n            });\n        } catch (err) {\n            \/* if the browser can't measure the text, the tooltip just shows without patches *\/\n        }\n\n        out.innerHTML = `<div class=\"snd-readout-top\">${onGround ? 'Ground \u00b7 ' : ''}${Math.round(p)} hPa \u00b7 ${Math.round(s.h)} m<\/div>` +\n                        `<div><span class=\"snd-dot snd-dot-t\"><\/span>Temp ${s.t.toFixed(1)}\u00b0` +\n                         `<span class=\"snd-dot snd-dot-d\"><\/span>Dew ${s.td.toFixed(1)}\u00b0` +\n                        `<span class=\"snd-dot snd-dot-h\"><\/span>Hum ${Math.round(humidity(s.t, s.td))}%` +\n                        `<\/div>` +\n                        `<div><span class=\"snd-dot\" style=\"background:#5c6f82\"><\/span>Wind ${Math.round(s.ws)} km\/h ${Math.round(s.wd)}\u00b0 (${toCardinal(s.wd)})<\/div>`;\n    }\n\n    \/\/ Turn a finger \/ mouse position on the graph into a pressure level\n    function probeFromEvent(e) {\n        const svg = document.getElementById('snd-svg');\n        const r = svg.getBoundingClientRect();\n        const yView = (e.clientY - r.top) * (SKEW_H \/ r.height) - MT;\n        const y = Math.max(0, Math.min(PH, yView));\n        probeP = P_BOTTOM * Math.exp(-(PH - y) \/ PH * LN_RANGE);\n    }\n\n    function wireTouch() {\n        const overlay = document.getElementById('snd-touch');\n        overlay.addEventListener('pointerdown', e => {\n            overlay.setPointerCapture(e.pointerId);\n            probeFromEvent(e);\n            drawProbe();\n        });\n        overlay.addEventListener('pointermove', e => {\n            probeFromEvent(e);\n            drawProbe();\n        });\n    }\n\n    \/* ============================================================\n       SCREEN \u2014 build the layout once, then refresh as things change\n       ============================================================ *\/\n    function buildLayout(maxStep) {\n        const container = document.getElementById('sounding-chart-container');\n                container.innerHTML = `<button type=\"button\" class=\"snd-fs-btn\" id=\"snd-fs-btn\" aria-label=\"Full screen\">\n  <svg class=\"snd-fs-enter\" viewBox=\"0 0 24 24\"><path d=\"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5\"\/><\/svg>\n  <svg class=\"snd-fs-exit\" viewBox=\"0 0 24 24\"><path d=\"M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5\"\/><\/svg>\n<\/button>\n<button type=\"button\" class=\"snd-zoom-btn\" id=\"snd-zoom-in\" aria-label=\"Zoom in\">+<\/button>\n<button type=\"button\" class=\"snd-zoom-btn\" id=\"snd-zoom-out\" aria-label=\"Zoom out\">&minus;<\/button>\n<div class=\"sounding-tag\">Sounding<\/div>\n<h3>${stationLabel}<\/h3>\n\n<div class=\"snd-toggle\">\n  <button type=\"button\" class=\"snd-toggle-btn\" id=\"snd-btn-graph\">Skew-T<\/button>\n    <button type=\"button\" class=\"snd-toggle-btn\" id=\"snd-btn-table\">Table<\/button>\n  \n<\/div>\n\n<div id=\"snd-svg-holder\"><\/div>\n<div class=\"snd-time-block\" id=\"snd-time-block\">\n  <p class=\"sounding-meta\" id=\"snd-meta\"><\/p>\n  <div class=\"snd-slider-row\">\n    <span class=\"snd-slider-label\" id=\"snd-slider-label\">Now<\/span>\n    <input type=\"range\" id=\"snd-slider\" min=\"0\" max=\"${maxStep}\" step=\"1\" value=\"${stepNow}\">\n    <span class=\"snd-slider-end\">+${maxStep} h<\/span>\n  <\/div>\n<\/div>\n<div class=\"snd-readout\" id=\"snd-readout\"><\/div>\n\n<div id=\"snd-table-view\"><\/div>`;\n\n        document.getElementById('snd-slider').addEventListener('input', e => {\n            stepNow = Number(e.target.value);\n            renderAll();\n        });\n        document.getElementById('snd-btn-graph').onclick = () => { viewMode = 'graph'; applyViewMode(); };\n                document.getElementById('snd-btn-table').onclick = () => { viewMode = 'table'; applyViewMode(); };\n                document.getElementById('snd-fs-btn').onclick = toggleFullscreen;\n        document.getElementById('snd-zoom-in').onclick = () => { changeZoom(1); };\n                document.getElementById('snd-zoom-out').onclick = () => { changeZoom(-1); };\n        \n    }\n\n    \/\/ Full screen on\/off: overlay for every device, real browser full screen where allowed\n    function toggleFullscreen() {\n        const box = document.getElementById('sounding-chart-container');\n        const goFull = !box.classList.contains('snd-full');\n        box.classList.toggle('snd-full', goFull);\n        document.documentElement.style.overflow = goFull ? 'hidden' : '';\n        if (goFull) {\n            if (box.requestFullscreen) { box.requestFullscreen().catch(() => {}); }\n        } else if (document.fullscreenElement) {\n            document.exitFullscreen().catch(() => {});\n        }\n        renderAll();\n        box.scrollTop = 0;\n    }\n\n            \/\/ Zoom one step in (+1) or out (-1); the ground always stays at the bottom\n    function changeZoom(step) {\n        zoomIdx = Math.max(0, Math.min(ZOOM_TOPS.length - 1, zoomIdx + step));\n        probeP = null;\n        renderAll();\n    }\n\n    \n\n    \/\/ When zoomed in, slide the temperature scale sideways so the curves stay in the middle\n    function centerTemperatures(pts) {\n        if (zoomIdx === 0) { return; }\n        const list = pts.concat([sampleAt(pts, P_TOP), sampleAt(pts, P_BOTTOM)]);\n        let lo = 9999;\n        let hi = -9999;\n        list.forEach(q => {\n            const y = yOf(q.p);\n            if (y > -1) {\n                if (PH + 1 > y) {\n                                        const shift = (PH - y) * SKEW * LN_RANGE \/ LN_FULL;\n                    lo = Math.min(lo, q.t * PX_PER_DEG + shift, q.td * PX_PER_DEG + shift);\n                    hi = Math.max(hi, q.t * PX_PER_DEG + shift, q.td * PX_PER_DEG + shift);\n                }\n            }\n        });\n        if (9999 > lo) {\n            T_MIN = ((lo + hi) \/ 2 - PW \/ 2) \/ PX_PER_DEG;\n        }\n    }\n\n    \/\/ Show only the chosen view and light up its pill\n    function applyViewMode() {\n        const showGraph = (viewMode === 'graph');\n        document.getElementById('snd-svg-holder').style.display = showGraph ? 'block' : 'none';\n        document.getElementById('snd-readout').style.display = showGraph ? 'block' : 'none';\n        document.getElementById('snd-zoom-in').style.display = showGraph ? 'flex' : 'none';\n                document.getElementById('snd-zoom-out').style.display = showGraph ? 'flex' : 'none';\n        \n        document.getElementById('snd-table-view').style.display = showGraph ? 'none' : 'block';\n        document.getElementById('snd-time-block').classList.toggle('table-mode', !showGraph);\n        document.getElementById('snd-btn-graph').classList.toggle('active', showGraph);\n        document.getElementById('snd-btn-table').classList.toggle('active', !showGraph);\n    }\n\n    \/\/ Everything that depends on the chosen hour is refreshed here, together\n        function renderAll() {\n        setGraphHeight();\n                 P_TOP = ZOOM_TOPS[zoomIdx];\n        LN_RANGE = Math.log(P_BOTTOM \/ P_TOP);\n        document.getElementById('snd-zoom-in').disabled = (zoomIdx === ZOOM_TOPS.length - 1);\n        document.getElementById('snd-zoom-out').disabled = (zoomIdx === 0);\n        const i = startIndex + stepNow;\n        const d = soundingData;\n                currentPoints = getPoints(d, i);\n        centerTemperatures(currentPoints);\n\n        document.getElementById('snd-meta').textContent = formatStamp(d.hourly.time[i]) + ' \u00b7 model elevation ' + d.elevation + ' m';\n        document.getElementById('snd-slider-label').textContent = (stepNow === 0) ? 'Now' : '+' + stepNow + ' h';\n        document.getElementById('snd-svg-holder').innerHTML = buildSkewT(currentPoints);\n        document.getElementById('snd-table-view').innerHTML = buildTable(currentPoints);\n\n        wireTouch();\n        drawProbe();\n        applyViewMode();\n    }\n\n    async function fetchOpenMeteoSounding(lat, lon, stationName) {\n        const MODEL = 'icon_eu';\n        const container = document.getElementById('sounding-chart-container');\n        const vars = ['temperature','dew_point','wind_speed','wind_direction','geopotential_height'];\n        const hourly = vars.flatMap(v => LEVELS.map(l => `${v}_${l}hPa`)).join(',') + ',temperature_2m,dew_point_2m,surface_pressure,wind_speed_10m,wind_direction_10m';\n        container.innerHTML = `<p>Reading sounding data for <strong>${stationName}<\/strong>...<\/p>`;\n        try {\n            const url = 'https:\/\/api.open-meteo.com\/v1\/forecast?' + new URLSearchParams({ latitude: lat, longitude: lon, hourly: hourly, models: MODEL, forecast_days: FORECAST_DAYS });\n            const r = await fetch(url);\n            if (!r.ok) throw new Error(`Status ${r.status}`);\n            const d = await r.json();\n            const times = d.hourly.time;\n\n            let i = times.findIndex(t => new Date(t + 'Z') >= Date.now());\n            if (0 > i) i = 0;\n\n            soundingData = d;\n            startIndex = i;\n            stationLabel = stationName;\n\n            const maxStep = times.length - 1 - i;\n            if (stepNow > maxStep) stepNow = maxStep;\n\n            buildLayout(maxStep);\n            renderAll();\n        } catch (error) {\n            console.error(error);\n            container.innerHTML = `<p>Could not load sounding data (${error.message}).<\/p>`;\n        }\n    }\n\n    \/* ============================================================\n       MAP + BUTTONS (unchanged)\n       ============================================================ *\/\n        \/\/ Re-draw when the screen changes shape (rotation) or full screen starts\/ends\n    window.addEventListener('resize', () => {\n        if (!soundingData) { return; }\n        const before = SKEW_H;\n        setGraphHeight();\n        if (SKEW_H !== before) { renderAll(); }\n    });\n    document.addEventListener('fullscreenchange', () => {\n        const box = document.getElementById('sounding-chart-container');\n        if (!document.fullscreenElement) {\n            box.classList.remove('snd-full');      \/\/ Esc key exits both modes together\n            document.documentElement.style.overflow = '';\n        }\n        if (soundingData) { renderAll(); }\n    });\n\n        const map = L.map('sounding-map').setView([32.75, -16.95], 9);\n    L.tileLayer('https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png', {\n        maxZoom: 18,\n        attribution: '\\u00a9 OpenStreetMap contributors',\n        referrerPolicy: 'strict-origin-when-cross-origin'\n    }).addTo(map);\n\n    let pin = null;\n    function pick(lat, lon, name) {\n        if (pin) map.removeLayer(pin);\n        pin = L.marker([lat, lon]).addTo(map);\n        fetchOpenMeteoSounding(lat, lon, name);\n    }\n\n    \/\/ Buttons get .spot-btn so styling lives in CSS, not inline\n    const btnBox = document.getElementById('spot-buttons');\n    weatherStations.forEach(s => {\n        const b = document.createElement('button');\n        b.textContent = s.name;\n        b.className = 'spot-btn';\n        b.onclick = () => { map.setView([s.lat, s.lon], 11); pick(s.lat, s.lon, s.name); };\n        btnBox.appendChild(b);\n    });\n\n    map.on('click', e => pick(e.latlng.lat, e.latlng.lng, `Map point (${e.latlng.lat.toFixed(3)}, ${e.latlng.lng.toFixed(3)})`));\n}\n(function waitForLeaflet() {\n    if (window.L) { startSoundingMap(); } else { setTimeout(waitForLeaflet, 200); }\n})();\n<\/script>\n\n\n\n<div style=\"height:11px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Windy model Sounding profile using the most reliable European model today Shows the evolution of temperature and wind on different altitude layers Tap the map or buttons to load the sounding Weather data by Open-Meteo.com (ICON-EU) Tap the map or buttons to load the sounding Weather data by Open-Meteo.com (ICON-EU) Tap the map or buttons [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"slim_seo":{"title":"Sounding for Madeira Island","description":"Icon-Eu Sounding profile, the most reliable European model today. Shows the evolution of temperature and wind on different altitude layers"},"footnotes":""},"class_list":["post-12555","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/pages\/12555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/comments?post=12555"}],"version-history":[{"count":59,"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/pages\/12555\/revisions"}],"predecessor-version":[{"id":12723,"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/pages\/12555\/revisions\/12723"}],"wp:attachment":[{"href":"https:\/\/paragliding-in-madeira.com\/weather\/wp-json\/wp\/v2\/media?parent=12555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}