/* ==========================================================================
   LINY Weather - comfort settings (Batch 4c)
   - Light theme: html[data-theme="light"] (follows the device unless the
     visitor picks Light or Dark; see the script at the top of header.php)
   - Reduce motion
   - Homepage alert line, display switches
   Selectors use [class~="..."] so Tailwind class names need no escaping.
   ========================================================================== */

.sr-only-live { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Homepage "Now" alert line ---------- */
.now-alert .ic-ok, .now-alert .ic-alert, .now-alert .ic-none { display: none; }
.now-alert[data-state="ok"] { color: #34d399; }
.now-alert[data-state="ok"] .ic-ok { display: inline-block; }
.now-alert[data-state="alert"] { color: #fbbf24; }
.now-alert[data-state="alert"] .ic-alert { display: inline-block; }
.now-alert[data-state="none"] { color: #94a3b8; }
.now-alert[data-state="none"] .ic-none { display: inline-block; }

/* ---------- Display switches (theme, °F/°C) ---------- */
.pref-btn { border: 1px solid #334155; color: #cbd5e1; background: transparent; }
.pref-btn:hover { border-color: #38bdf8; color: #fff; }
.pref-btn[aria-pressed="true"] { background: #0ea5e9; border-color: #0ea5e9; color: #020617; }
.theme-ic-light, .theme-ic-dark { display: none; }
html[data-theme="dark"] .theme-ic-dark, html:not([data-theme]) .theme-ic-dark { display: inline-block; }
html[data-theme="light"] .theme-ic-light { display: inline-block; }

/* ---------- Keyboard focus ---------- */
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #38bdf8; outline-offset: 2px;
}

/* ---------- Reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .animate-ping { display: none !important; }
  .animate-marquee { transform: none !important; white-space: normal !important; }
}

/* ==========================================================================
   LIGHT THEME
   ========================================================================== */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

html[data-theme="light"] body {
  background: radial-gradient(circle at 50% 0%, #ffffff 0%, #eef2f7 85%);
  color: #0f172a;
}
html[data-theme="light"] .glass-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.10);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] ::-webkit-scrollbar-track { background: rgba(226, 232, 240, 0.7); }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(2, 132, 199, 0.35); }

/* Header and bars */
html[data-theme="light"] #main-site-header { box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08); }
html[data-theme="light"] [class~="shadow-2xl"], html[data-theme="light"] [class~="shadow-lg"] { --tw-shadow-color: rgba(15, 23, 42, 0.12); }
html[data-theme="light"] #header-temp { filter: none; --tw-drop-shadow: none; }
html[data-theme="light"] .bg-clip-text { background-image: linear-gradient(to right, #0284c7, #0e7490, #1d4ed8) !important; }

/* Grey backgrounds (dark slate → light slate). Opacity variants keep their transparency. */
html[data-theme="light"] [class~="bg-slate-950"] { background-color: #f8fafc; }
html[data-theme="light"] [class~="bg-slate-950/95"], html[data-theme="light"] [class~="bg-slate-950/90"] { background-color: rgb(255 255 255 / 0.94); }
html[data-theme="light"] [class~="bg-slate-950/85"], html[data-theme="light"] [class~="bg-slate-950/80"] { background-color: rgb(248 250 252 / 0.9); }
html[data-theme="light"] [class~="bg-slate-950/70"], html[data-theme="light"] [class~="bg-slate-950/60"], html[data-theme="light"] [class~="bg-slate-950/40"] { background-color: rgb(241 245 249 / 0.85); }
html[data-theme="light"] [class~="bg-slate-900"] { background-color: #f1f5f9; }
html[data-theme="light"] [class~="bg-slate-900/95"], html[data-theme="light"] [class~="bg-slate-900/90"], html[data-theme="light"] [class~="bg-slate-900/85"], html[data-theme="light"] [class~="bg-slate-900/80"] { background-color: rgb(241 245 249 / 0.95); }
html[data-theme="light"] [class~="bg-slate-900/70"], html[data-theme="light"] [class~="bg-slate-900/60"], html[data-theme="light"] [class~="bg-slate-900/50"], html[data-theme="light"] [class~="bg-slate-900/40"] { background-color: rgb(241 245 249 / 0.8); }
html[data-theme="light"] [class~="bg-slate-800"] { background-color: #e2e8f0; }
html[data-theme="light"] [class~="bg-slate-800/50"], html[data-theme="light"] [class~="bg-slate-800/60"] { background-color: rgb(226 232 240 / 0.7); }
html[data-theme="light"] [class~="bg-slate-700"] { background-color: #cbd5e1; }
html[data-theme="light"] [class~="hover:bg-slate-900"]:hover, html[data-theme="light"] [class~="hover:bg-slate-800"]:hover,
html[data-theme="light"] [class~="hover:bg-slate-800/60"]:hover, html[data-theme="light"] [class~="hover:bg-slate-800/50"]:hover,
html[data-theme="light"] [class~="hover:bg-slate-800/40"]:hover { background-color: #e2e8f0; }
html[data-theme="light"] [class~="hover:bg-slate-700"]:hover { background-color: #cbd5e1; }

/* Dark gradients on page banners → plain light panel */
html[data-theme="light"] [class*="from-slate-9"], html[data-theme="light"] [class*="via-slate-9"] { background-image: none !important; }

/* Dark colour tints → light tints */
html[data-theme="light"] [class*="bg-sky-950"] { background-color: #f0f9ff; }
html[data-theme="light"] [class*="bg-cyan-950"] { background-color: #ecfeff; }
html[data-theme="light"] [class*="bg-blue-950"], html[data-theme="light"] [class*="bg-blue-900/"] { background-color: #eff6ff; }
html[data-theme="light"] [class*="bg-emerald-950"] { background-color: #ecfdf5; }
html[data-theme="light"] [class*="bg-rose-950"] { background-color: #fff1f2; }
html[data-theme="light"] [class*="bg-amber-950"] { background-color: #fffbeb; }
html[data-theme="light"] [class*="bg-purple-950"] { background-color: #faf5ff; }
html[data-theme="light"] [class*="bg-indigo-950"] { background-color: #eef2ff; }

/* Borders */
html[data-theme="light"] [class~="border-slate-800"], html[data-theme="light"] [class~="border-slate-800/80"], html[data-theme="light"] [class~="border-slate-800/60"],
html[data-theme="light"] [class~="border-white/5"], html[data-theme="light"] [class~="divide-slate-800"] > *, html[data-theme="light"] [class~="divide-slate-800/80"] > * { border-color: #e2e8f0; }
html[data-theme="light"] [class~="border-slate-700"], html[data-theme="light"] [class~="border-slate-700/80"], html[data-theme="light"] [class~="border-slate-600"] { border-color: #cbd5e1; }
html[data-theme="light"] [class~="hover:border-slate-700"]:hover { border-color: #94a3b8; }
html[data-theme="light"] [class~="ring-slate-800"] { --tw-ring-color: #e2e8f0; }

/* Grey text (light text on dark → dark text on light) */
html[data-theme="light"] [class~="text-white"] { color: #0f172a; }
html[data-theme="light"] [class~="text-slate-200"] { color: #1e293b; }
html[data-theme="light"] [class~="text-slate-300"] { color: #334155; }
html[data-theme="light"] [class~="text-slate-400"] { color: #475569; }
html[data-theme="light"] [class~="text-slate-700"], html[data-theme="light"] [class~="text-slate-800/80"] { color: #94a3b8; }
html[data-theme="light"] [class~="hover:text-white"]:hover, html[data-theme="light"] [class~="hover:text-slate-200"]:hover,
html[data-theme="light"] [class~="hover:text-slate-300"]:hover { color: #020617; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { color: #0f172a; }
html[data-theme="light"] input::placeholder, html[data-theme="light"] textarea::placeholder { color: #64748b; }
html[data-theme="light"] input[type=range]::-webkit-slider-runnable-track { background: #e2e8f0; border-color: #cbd5e1; }

/* White text stays white on solid coloured buttons and badges */
html[data-theme="light"] :is(.bg-blue-600, .bg-blue-500, .bg-sky-600, .bg-indigo-500, .bg-indigo-600, .bg-emerald-500, .bg-emerald-600, .bg-rose-500, .bg-rose-600, .bg-red-500, .bg-red-600, .bg-purple-600, .from-sky-500, .from-emerald-500, .from-blue-500)[class~="text-white"],
html[data-theme="light"] :is(.bg-blue-600, .bg-blue-500, .bg-sky-600, .bg-indigo-500, .bg-indigo-600, .bg-emerald-500, .bg-emerald-600, .bg-rose-500, .bg-rose-600, .bg-red-500, .bg-red-600, .bg-purple-600, .from-sky-500, .from-emerald-500, .from-blue-500) [class~="text-white"] { color: #ffffff; }
html[data-theme="light"] .bg-sky-500[class~="text-white"] { color: #020617; }

/* Coloured text: deeper shades so it stays readable on white (icons keep their colours) */
html[data-theme="light"] :is([class~="text-sky-200"], [class~="text-sky-300"], [class~="text-sky-400"], [class~="text-sky-500"]):not(svg) { color: #0369a1; }
html[data-theme="light"] :is([class~="text-cyan-200"], [class~="text-cyan-300"], [class~="text-cyan-400"], [class~="text-cyan-500"]):not(svg) { color: #0e7490; }
html[data-theme="light"] :is([class~="text-blue-200"], [class~="text-blue-300"], [class~="text-blue-400"], [class~="text-blue-500"]):not(svg) { color: #1d4ed8; }
html[data-theme="light"] :is([class~="text-indigo-200"], [class~="text-indigo-300"], [class~="text-indigo-400"]):not(svg) { color: #4338ca; }
html[data-theme="light"] :is([class~="text-purple-300"], [class~="text-purple-400"]):not(svg) { color: #7e22ce; }
html[data-theme="light"] :is([class~="text-emerald-200"], [class~="text-emerald-300"], [class~="text-emerald-400"], [class~="text-emerald-500"]):not(svg) { color: #047857; }
html[data-theme="light"] :is([class~="text-teal-300"], [class~="text-teal-400"]):not(svg) { color: #0f766e; }
html[data-theme="light"] :is([class~="text-amber-200"], [class~="text-amber-300"], [class~="text-amber-400"], [class~="text-amber-500"]):not(svg) { color: #b45309; }
html[data-theme="light"] :is([class~="text-yellow-300"], [class~="text-yellow-400"]):not(svg) { color: #a16207; }
html[data-theme="light"] :is([class~="text-orange-300"], [class~="text-orange-400"]):not(svg) { color: #c2410c; }
html[data-theme="light"] :is([class~="text-rose-200"], [class~="text-rose-300"], [class~="text-rose-400"], [class~="text-rose-500"]):not(svg) { color: #be123c; }
html[data-theme="light"] :is([class~="text-red-300"], [class~="text-red-400"]):not(svg) { color: #b91c1c; }
html[data-theme="light"] :is([class~="text-pink-300"], [class~="text-pink-400"]):not(svg) { color: #be185d; }
html[data-theme="light"] [class~="text-sky-100"] { color: #075985; }
/* ...but keep the light shades inside the amber alert banner's dark button */
html[data-theme="light"] #nws-alert-banner button { background-color: #020617; color: #fcd34d; }

/* Alert line and switches in light mode */
html[data-theme="light"] .now-alert[data-state="ok"] { color: #047857; }
html[data-theme="light"] .now-alert[data-state="alert"] { color: #b45309; }
html[data-theme="light"] .now-alert[data-state="none"] { color: #475569; }
html[data-theme="light"] .pref-btn { border-color: #cbd5e1; color: #334155; }
html[data-theme="light"] .pref-btn:hover { border-color: #0284c7; color: #020617; }
html[data-theme="light"] .pref-btn[aria-pressed="true"] { background: #0284c7; border-color: #0284c7; color: #ffffff; }
html[data-theme="light"] .nav-btn-active { background-color: #0284c7 !important; color: #ffffff !important; }
html[data-theme="light"] .nav-btn-mobile-active { color: #0369a1 !important; }
html[data-theme="light"] a:focus-visible, html[data-theme="light"] button:focus-visible, html[data-theme="light"] summary:focus-visible { outline-color: #0369a1; }
/* Pale icon colours get a touch deeper on white */
html[data-theme="light"] svg[class~="text-indigo-200"] { color: #6366f1; }
html[data-theme="light"] svg[class~="text-cyan-200"] { color: #06b6d4; }
html[data-theme="light"] svg[class~="text-slate-300"] { color: #64748b; }
html[data-theme="light"] svg[class~="text-amber-300"] { color: #f59e0b; }

/* ---------- Phones: badges and small buttons never squeeze their words onto two lines ----------
   A row that holds badges/buttons may wrap, so a badge moves to the next line whole.
   Sideways-scrolling strips are left alone. */
@media (max-width: 639px) {
  .flex:not([class*="overflow-x"]):not(.flex-col):has(> :is(span, a, button, div)[class*="rounded"][class*="px-"]) { flex-wrap: wrap; row-gap: 0.375rem; }
  .flex:not([class*="overflow-x"]):not(.flex-col) > :is(span, a, button)[class*="rounded"][class*="px-"] { max-width: 100%; }
  .flex:not([class*="overflow-x"]):not(.flex-col) > :is(span, a, button)[class*="rounded"][class*="px-"][class~="shrink-0"] { flex-shrink: 1; }
}
@media (max-width: 639px) {
  /* Small buttons keep their label on one line; their row wraps instead */
  .flex:not([class*="overflow-x"]):not(.flex-col) > :is(button, a)[class*="rounded"][class*="px-"] { white-space: nowrap; }
}
/* The site name in the header fits on the narrowest phones */
@media (max-width: 380px) {
  #main-site-header .truncate { font-size: 16px; }
}
html[data-theme="light"] nav[aria-label="Quick links"] { box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08); }
