/* Dark theme for the interface around the map. It is switched by data-scheme="dark" on <html>
   (see layout.blade.php and js/accessibility.js). The map itself is not touched: the tiles, the
   layer the visitor picked and the coloured value markers stay as they are; only the chrome
   around them (header, menu, panels, popups, controls, windows) is dark.

   These rules are written against the utility classes the pages already use and are not part
   of the Tailwind build, so they hold whatever the compiled CSS contains. Unlayered CSS wins
   over Tailwind's layered utilities at equal specificity.

   Palette: page #0a0f18, surface #121a26, raised #1a2434, line #263247, text #e6edf5,
   muted #a3b1c4, link/brand #6cc1de. */

html[data-scheme="dark"] { color-scheme: dark; }

html[data-scheme="dark"] body { background: #0a0f18; color: #e6edf5; }

/* Surfaces */
html[data-scheme="dark"] .bg-white,
html[data-scheme="dark"] .lg\:bg-white { background-color: #121a26; }
html[data-scheme="dark"] .bg-white\/95 { background-color: rgba(18, 26, 38, 0.95); }
html[data-scheme="dark"] .bg-gray-50 { background-color: #161f2d; }
html[data-scheme="dark"] .bg-gray-100 { background-color: #0a0f18; }
html[data-scheme="dark"] .bg-gray-200 { background-color: #202c3e; }
html[data-scheme="dark"] .bg-brand-50 { background-color: rgba(108, 193, 222, 0.14); }
html[data-scheme="dark"] .bg-blue-50 { background-color: rgba(59, 130, 246, 0.16); }
html[data-scheme="dark"] .bg-red-50 { background-color: rgba(239, 68, 68, 0.16); }
html[data-scheme="dark"] .bg-orange-50 { background-color: rgba(249, 115, 22, 0.16); }
html[data-scheme="dark"] .bg-blue-200 { background-color: rgba(59, 130, 246, 0.3); }
html[data-scheme="dark"] .bg-red-200 { background-color: rgba(239, 68, 68, 0.3); }
html[data-scheme="dark"] .bg-orange-200 { background-color: rgba(249, 115, 22, 0.3); }

html[data-scheme="dark"] .hover\:bg-gray-50:hover,
html[data-scheme="dark"] .hover\:bg-gray-100:hover { background-color: #1a2434; }
html[data-scheme="dark"] .hover\:bg-gray-200:hover,
html[data-scheme="dark"] .hover\:bg-gray-300:hover { background-color: #263247; }
html[data-scheme="dark"] .lg\:hover\:bg-transparent:hover { background-color: transparent; }

/* Text */
html[data-scheme="dark"] .text-gray-900,
html[data-scheme="dark"] .text-gray-800,
html[data-scheme="dark"] .hover\:text-gray-900:hover { color: #e6edf5; }
html[data-scheme="dark"] .text-gray-700 { color: #cbd5e3; }
html[data-scheme="dark"] .text-gray-600,
html[data-scheme="dark"] .text-gray-500 { color: #a3b1c4; }
html[data-scheme="dark"] .text-gray-400 { color: #8394ab; }
html[data-scheme="dark"] .text-brand-600,
html[data-scheme="dark"] .lg\:hover\:text-brand-600:hover { color: #6cc1de; }
html[data-scheme="dark"] .text-blue-500,
html[data-scheme="dark"] .text-blue-600 { color: #60a5fa; }
html[data-scheme="dark"] .text-green-600 { color: #4ade80; }
html[data-scheme="dark"] .text-red-500,
html[data-scheme="dark"] .text-red-600 { color: #f87171; }
html[data-scheme="dark"] .text-red-800 { color: #fca5a5; }
html[data-scheme="dark"] .text-orange-800 { color: #fdba74; }
html[data-scheme="dark"] .text-blue-800 { color: #93c5fd; }
html[data-scheme="dark"] .text-pink-700 { color: #f472b6; }

/* Lines */
html[data-scheme="dark"] .border-gray-100,
html[data-scheme="dark"] .border-gray-200,
html[data-scheme="dark"] .border-gray-300 { border-color: #263247; }

html[data-scheme="dark"] .shadow,
html[data-scheme="dark"] .shadow-lg,
html[data-scheme="dark"] .shadow-xl { --tw-shadow-color: rgba(0, 0, 0, 0.5); }

/* Header: the logo is a transparent PNG in dark teal, which sinks into the dark bar, so it is
   lightened here instead of sitting on a chip. */
html[data-scheme="dark"] nav img[alt="Monitora Caí"] { filter: brightness(1.7); }
html[data-scheme="dark"] .a11y-open { color: #6cc1de; }
html[data-scheme="dark"] .a11y-open:hover { background: #1a2434; }
html[data-scheme="dark"] .a11y-bar { border-left-color: #263247; }

/* The reading panel */
html[data-scheme="dark"] .a11y-panel { background: #121a26; color: #e6edf5; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6); }
html[data-scheme="dark"] .a11y-head,
html[data-scheme="dark"] .a11y-foot { border-color: #263247; }
html[data-scheme="dark"] .a11y-head p,
html[data-scheme="dark"] .a11y-note,
html[data-scheme="dark"] .a11y-switch small,
html[data-scheme="dark"] .a11y-foot p,
html[data-scheme="dark"] .a11y-close { color: #a3b1c4; }
html[data-scheme="dark"] .a11y-close:hover { background: #1a2434; color: #e6edf5; }
html[data-scheme="dark"] .a11y-choice { background: #161f2d; border-color: #263247; color: #cbd5e3; }
html[data-scheme="dark"] .a11y-choice:hover { background: #1a2434; }
html[data-scheme="dark"] .a11y-choice[aria-pressed="true"] { background: rgba(108, 193, 222, 0.14); border-color: #6cc1de; color: #6cc1de; box-shadow: inset 0 0 0 1px #6cc1de; }
html[data-scheme="dark"] .a11y-switch { background: #161f2d; border-color: #263247; }
html[data-scheme="dark"] .a11y-track { background: #3b4a62; }
html[data-scheme="dark"] .a11y-switch[aria-checked="true"] .a11y-track { background: #0b86ab; }
html[data-scheme="dark"] .a11y-reset { background: #161f2d; border-color: #263247; color: #e6edf5; }
html[data-scheme="dark"] .a11y-reset:hover { background: #1a2434; }

/* Map controls and popups: the card, not the map underneath. */
html[data-scheme="dark"] .leaflet-popup-content-wrapper,
html[data-scheme="dark"] .leaflet-popup-tip { background: #121a26; color: #e6edf5; }
html[data-scheme="dark"] .leaflet-container a.leaflet-popup-close-button { color: #a3b1c4; }
html[data-scheme="dark"] .leaflet-bar a { background-color: #121a26; border-color: #263247; color: #e6edf5; }
html[data-scheme="dark"] .leaflet-bar a:hover { background-color: #1a2434; }
html[data-scheme="dark"] .leaflet-control-attribution { background: rgba(18, 26, 38, 0.8); color: #a3b1c4; }
html[data-scheme="dark"] .leaflet-control-attribution a { color: #6cc1de; }

/* Charts inside the popups (Highcharts writes its colours inline). */
html[data-scheme="dark"] .leaflet-popup .highcharts-axis-labels text,
html[data-scheme="dark"] .leaflet-popup .highcharts-data-label text { fill: #cbd5e3 !important; color: #cbd5e3 !important; }
html[data-scheme="dark"] .leaflet-popup .highcharts-axis-line,
html[data-scheme="dark"] .leaflet-popup .highcharts-grid-line { stroke: #3b4a62; }
html[data-scheme="dark"] .leaflet-popup .highcharts-background { fill: transparent; }

/* The automatic alerts that float over the map: the see-through tint of the lists above lets the
   map show through and the text gets lost, so these ones are solid (the same tints, over the card). */
html[data-scheme="dark"] #auto-alerts-container .bg-blue-200 { background-color: #1e3964; }
html[data-scheme="dark"] #auto-alerts-container .bg-red-200 { background-color: #54272f; }
html[data-scheme="dark"] #auto-alerts-container .bg-orange-200 { background-color: #573521; }
html[data-scheme="dark"] #auto-alerts-container [role="alert"] { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); }

/* Windows (news, brand on the map, alerts) and the map settings drawer */
html[data-scheme="dark"] #newsModal .bg-white,
html[data-scheme="dark"] #brandOnMapModal .bg-white { background-color: #121a26; }
html[data-scheme="dark"] #filterDrawer { background-color: #121a26; color: #e6edf5; }
html[data-scheme="dark"] input[type="text"],
html[data-scheme="dark"] input[type="search"],
html[data-scheme="dark"] input[type="email"],
html[data-scheme="dark"] select,
html[data-scheme="dark"] textarea { background-color: #161f2d; border-color: #263247; color: #e6edf5; }

/* The "Mapa" button that opens the map settings. */
html[data-scheme="dark"] .leaflet-control.filter-button button { background-color: #121a26; color: #6cc1de; }
html[data-scheme="dark"] .leaflet-control.filter-button button i,
html[data-scheme="dark"] .leaflet-control.filter-button .filter-button-label { color: #6cc1de; }

/* Options inside the settings drawer (the ones drawn by script keep their selected colour). */
html[data-scheme="dark"] .filter-item:not(.filter-selected) { color: #cbd5e3; }
html[data-scheme="dark"] .filter-item.filter-selected { background-color: #026582; color: #fff; }
html[data-scheme="dark"] .leaflet-popup-content a.bt { color: #7dd3f0; }
html[data-scheme="dark"] .leaflet-popup-content a.bt:hover { color: #fff; }

/* Detail pages */
html[data-scheme="dark"] .text-black { color: #e6edf5; }
html[data-scheme="dark"] .divide-gray-100 > :not(:last-child) { border-color: #263247; }
html[data-scheme="dark"] .leaflet-container a.leaflet-popup-close-button { background: transparent; }

/* Charts (Highcharts): only the frame and the text; the series keep their colours. */
html[data-scheme="dark"] .highcharts-background { fill: transparent; }
html[data-scheme="dark"] .highcharts-container .highcharts-title,
html[data-scheme="dark"] .highcharts-container .highcharts-subtitle,
html[data-scheme="dark"] .highcharts-container .highcharts-axis-labels text,
html[data-scheme="dark"] .highcharts-container .highcharts-axis-title,
html[data-scheme="dark"] .highcharts-container .highcharts-legend-item text,
html[data-scheme="dark"] .highcharts-container .highcharts-legend-item span,
html[data-scheme="dark"] .highcharts-container .highcharts-yaxis-labels text,
html[data-scheme="dark"] .highcharts-container .highcharts-xaxis-labels text { fill: #cbd5e3 !important; color: #cbd5e3 !important; }
html[data-scheme="dark"] .highcharts-container .highcharts-grid-line { stroke: #263247; }
html[data-scheme="dark"] .highcharts-container .highcharts-axis-line,
html[data-scheme="dark"] .highcharts-container .highcharts-tick { stroke: #3b4a62; }
html[data-scheme="dark"] .highcharts-container .highcharts-legend-item-hidden text { fill: #6b7a90 !important; }
html[data-scheme="dark"] .highcharts-tooltip-box { fill: #121a26; stroke: #3b4a62; }
html[data-scheme="dark"] .highcharts-tooltip text,
html[data-scheme="dark"] .highcharts-tooltip span { fill: #e6edf5 !important; color: #e6edf5 !important; }
html[data-scheme="dark"] .highcharts-container [stroke="#333333"],
html[data-scheme="dark"] .highcharts-container [stroke="#333"] { stroke: #9aa8bb; }
html[data-scheme="dark"] .highcharts-container [fill="#333333"],
html[data-scheme="dark"] .highcharts-container [fill="#333"] { fill: #9aa8bb; }

/* Wind direction lane under the wind chart: the arrows and rings are drawn in a dark slate
   that vanishes on the dark background. */
html[data-scheme="dark"] .highcharts-container [stroke="#334155"] { stroke: #cbd5e3; }

/* Wind compass: a dark dial. */
html[data-scheme="dark"] .compass { color: #cbd5e3; text-shadow: none; box-shadow: 0 0 5px rgba(0, 0, 0, 0.6); }
html[data-scheme="dark"] .compass .direction { background: linear-gradient(to bottom, #202c3e 0%, #161f2d 100%); }

/* Map markers keep their own colours (white or value-coloured pills with dark text). The page
   text colour must not leak into them, nor the lightened greens and reds used on the dark page. */
html[data-scheme="dark"] .icone { color: #000; }
html[data-scheme="dark"] .icone .text-green-600 { color: #16a34a; }
html[data-scheme="dark"] .icone .text-red-500 { color: #ef4444; }
html[data-scheme="dark"] .icone .text-blue-500 { color: #3b82f6; }

/* On/off switches in the map settings: the track is a grey utility that would also cover the
   checked colour, so both states are set here. */
html[data-scheme="dark"] input.peer + div.bg-gray-200 { background-color: #3b4a62; }
html[data-scheme="dark"] input.peer:checked + div.bg-gray-200 { background-color: #0b86ab; }
