/* ============ Weather HUD — cinematic glass dashboard ============ */

:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-theme: 1000ms;
  --radius-lg: 28px;
  --radius-md: 20px;
  --ink: rgba(255, 255, 255, .94);
  --ink-2: rgba(255, 255, 255, .62);
  --ink-3: rgba(255, 255, 255, .38);
  --line: rgba(255, 255, 255, .09);
}

/* ---- per-weather theme tokens ---- */
body[data-weather="sunny"] {
  --accent: #ffb454;
  --accent-2: #ff8a2a;
  --accent-soft: rgba(255, 176, 74, .16);
  --accent-glow: rgba(255, 160, 60, .45);
  --chart: #ffab3d;
  --chart-2: #ffd98a;
  --bg-a: #131627;
  --bg-b: #2a2030;
  --halo: rgba(255, 150, 40, .32);
  --halo-x: 78%;
  --halo-y: 12%;
  --panel-tint: rgba(255, 190, 110, .035);
}
body[data-weather="rain"] {
  --accent: #6fa5ff;
  --accent-2: #3f7dff;
  --accent-soft: rgba(100, 155, 255, .15);
  --accent-glow: rgba(90, 145, 255, .45);
  --chart: #5f96ff;
  --chart-2: #9dc0ff;
  --bg-a: #0c1120;
  --bg-b: #10182e;
  --halo: rgba(70, 110, 220, .25);
  --halo-x: 30%;
  --halo-y: 8%;
  --panel-tint: rgba(120, 160, 255, .03);
}
body[data-weather="snow"] {
  --accent: #b9c6ff;
  --accent-2: #a08dff;
  --accent-soft: rgba(170, 160, 255, .14);
  --accent-glow: rgba(160, 150, 255, .4);
  --chart: #a99bff;
  --chart-2: #d4ccff;
  --bg-a: #0e1226;
  --bg-b: #1a1836;
  --halo: rgba(140, 130, 255, .22);
  --halo-x: 55%;
  --halo-y: 5%;
  --panel-tint: rgba(190, 200, 255, .04);
}
body[data-weather="wind"] {
  --accent: #5fe6bd;
  --accent-2: #23c99a;
  --accent-soft: rgba(80, 225, 185, .13);
  --accent-glow: rgba(70, 220, 180, .38);
  --chart: #4fe0b4;
  --chart-2: #a8f2dc;
  --bg-a: #0c1a19;
  --bg-b: #12241f;
  --halo: rgba(50, 180, 140, .22);
  --halo-x: 20%;
  --halo-y: 85%;
  --panel-tint: rgba(120, 230, 195, .03);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-a), var(--bg-b));
  overflow: hidden;
  transition: background var(--t-theme) var(--ease);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---- atmosphere layers ---- */
#bgHalo {
  position: fixed; inset: -20%;
  background: radial-gradient(42% 46% at var(--halo-x) var(--halo-y), var(--halo), transparent 70%);
  transition: background var(--t-theme) var(--ease);
  pointer-events: none;
  animation: haloBreathe 11s ease-in-out infinite;
}
@keyframes haloBreathe {
  0%, 100% { opacity: .85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

#bgHalo2 {
  position: fixed; inset: -10%;
  background: radial-gradient(60% 50% at 15% 95%, var(--accent-soft), transparent 65%);
  opacity: .5; pointer-events: none;
  transition: background var(--t-theme) var(--ease);
}

/* sun rays — sunny only */
#rays {
  position: fixed; inset: 0; pointer-events: none;
  background: conic-gradient(from 210deg at 82% 6%,
    transparent 0deg, rgba(255, 190, 90, .06) 8deg, transparent 16deg,
    rgba(255, 190, 90, .05) 24deg, transparent 32deg,
    rgba(255, 190, 90, .06) 42deg, transparent 52deg);
  opacity: 0; transition: opacity 1200ms var(--ease);
  animation: raysDrift 26s ease-in-out infinite;
  mix-blend-mode: screen;
}
body[data-weather="sunny"] #rays { opacity: 1; }
@keyframes raysDrift {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(2.4deg) scale(1.04); }
}

/* lens flare — sunny only */
#flare { position: fixed; right: 10%; top: 4%; width: 340px; height: 340px; pointer-events: none;
  opacity: 0; transition: opacity 1200ms var(--ease); mix-blend-mode: screen; }
body[data-weather="sunny"] #flare { opacity: 1; }
#flare::before, #flare::after { content: ''; position: absolute; border-radius: 50%; }
#flare::before {
  inset: 0;
  background: radial-gradient(circle, rgba(255, 210, 130, .5), rgba(255, 160, 60, .12) 42%, transparent 68%);
  animation: flarePulse 7s ease-in-out infinite;
}
#flare::after {
  width: 90px; height: 90px; left: -130px; top: 240px;
  background: radial-gradient(circle, rgba(255, 200, 120, .18), transparent 70%);
}
@keyframes flarePulse { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.08); opacity: 1; } }

/* lightning flash — rain */
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: radial-gradient(70% 60% at 50% 0%, rgba(190, 210, 255, .9), rgba(140, 170, 255, .35) 55%, transparent 80%);
  opacity: 0;
}
#flash.zap { animation: zap 900ms ease-out; }
@keyframes zap {
  0% { opacity: 0; } 6% { opacity: .85; } 12% { opacity: .1; }
  18% { opacity: .55; } 30% { opacity: .06; } 100% { opacity: 0; }
}

canvas#fxBack { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
canvas#fxFront { position: fixed; inset: 0; pointer-events: none; z-index: 30; }

/* ============ the glass panel ============ */
.stage {
  position: relative; z-index: 10;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 28px 28px 96px;
}

.panel {
  position: relative;
  width: min(1240px, 100%);
  height: min(820px, 100%);
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .022) 45%, rgba(255, 255, 255, .05));
  backdrop-filter: blur(26px) saturate(1.35);
  -webkit-backdrop-filter: blur(26px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow:
    0 40px 90px -20px rgba(0, 0, 0, .55),
    0 0 120px -30px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, .14),
    inset 0 -1px 0 rgba(255, 255, 255, .04);
  display: grid;
  grid-template-columns: 1.02fr .98fr;
  overflow: hidden;
  transition: box-shadow var(--t-theme) var(--ease);
}
.panel::before {
  /* moving sheen */
  content: ''; position: absolute; inset: -60%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .05) 50%, transparent 58%);
  animation: sheen 13s linear infinite;
  pointer-events: none;
}
@keyframes sheen { 0% { transform: translateX(-28%); } 100% { transform: translateX(28%); } }
.panel::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: var(--panel-tint);
  transition: background var(--t-theme) var(--ease);
  pointer-events: none;
}

/* frost creeping in from edges — snow only */
#frost {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5;
  background:
    radial-gradient(46% 34% at 0% 0%, rgba(215, 225, 255, .16), transparent 70%),
    radial-gradient(42% 30% at 100% 0%, rgba(215, 225, 255, .13), transparent 70%),
    radial-gradient(50% 36% at 0% 100%, rgba(205, 215, 255, .15), transparent 70%),
    radial-gradient(46% 34% at 100% 100%, rgba(215, 225, 255, .14), transparent 70%);
  opacity: 0; transition: opacity 1400ms var(--ease);
  filter: blur(2px);
}
body[data-weather="snow"] #frost { opacity: 1; }

/* wet sheen — rain only */
#wet {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5;
  background:
    radial-gradient(3px 12px at 12% 20%, rgba(190, 215, 255, .25), transparent),
    radial-gradient(2px 9px at 34% 55%, rgba(190, 215, 255, .2), transparent),
    radial-gradient(3px 14px at 58% 30%, rgba(190, 215, 255, .22), transparent),
    radial-gradient(2px 8px at 76% 70%, rgba(190, 215, 255, .2), transparent),
    radial-gradient(3px 11px at 90% 42%, rgba(190, 215, 255, .22), transparent),
    linear-gradient(180deg, rgba(140, 175, 255, .05), transparent 30%);
  opacity: 0; transition: opacity 1400ms var(--ease);
}
body[data-weather="rain"] #wet { opacity: 1; }

.col {
  position: relative; z-index: 6;
  padding: 30px 34px;
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.col-left { border-right: 1px solid var(--line); }
.col-right { padding-top: 26px; }

/* ---- left column ---- */
.sync {
  display: flex; align-items: center; gap: 9px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase;
  color: var(--ink-3);
}
.sync .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 10px 2px rgba(61, 220, 132, .55);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.78); } }

.head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-top: 14px;
}
.city h1 { font-size: 27px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; }
.city h1 svg { opacity: .45; }
.city .sub { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); }
.clock { text-align: right; }
.clock .time { font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock .date { margin-top: 4px; font-size: 12px; color: var(--ink-2); }

/* hero */
.hero { display: flex; align-items: center; gap: 26px; margin: 20px 0 4px; }
.hero-icon {
  width: 128px; height: 128px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 8px 28px var(--accent-glow));
  transition: filter var(--t-theme) var(--ease);
}
.hero-icon svg { width: 116px; height: 116px; overflow: visible; }
.hero-main { min-width: 0; }
.temp-row { display: flex; align-items: flex-start; line-height: 1; }
.temp-value {
  font-size: 108px; font-weight: 700; letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff 30%, rgba(255, 255, 255, .55));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px var(--accent-glow);
}
.temp-unit { font-size: 30px; font-weight: 600; margin-top: 14px; color: var(--ink-2); }
.hero-title { font-size: 21px; font-weight: 650; margin-top: 8px; letter-spacing: -.01em; }
.hero-stats { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); line-height: 1.85; }
.hero-stats b { color: var(--ink); font-weight: 600; }
.hero-stats .hi { color: var(--accent); }
.hero-stats .lo { color: var(--ink-2); }
.hero-stats .sep { margin: 0 7px; opacity: .4; }

/* insight card */
.insight {
  margin-top: 18px;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(140deg, var(--accent-soft), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 0 40px -12px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .07);
  transition: background var(--t-theme) var(--ease), box-shadow var(--t-theme) var(--ease);
  animation: insightIn 800ms var(--ease);
}
@keyframes insightIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.insight.rein { animation: insightIn 800ms var(--ease); }
.insight-icon {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  transition: background var(--t-theme) var(--ease), color var(--t-theme) var(--ease);
}
.insight p { font-size: 12.5px; line-height: 1.7; color: var(--ink-2); }
.insight p b { color: var(--ink); font-weight: 600; }

/* metric grid */
.metrics {
  margin-top: 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  flex: 1; min-height: 0;
}
.metric {
  border-radius: 16px;
  padding: 13px 15px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
  border: 1px solid rgba(255, 255, 255, .07);
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 300ms var(--ease), border-color 300ms var(--ease), box-shadow 300ms var(--ease);
  min-height: 0;
}
.metric:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, .16);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5), 0 0 30px -10px var(--accent-glow);
}
.metric-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-3);
}
.metric-label svg { color: var(--accent); transition: color var(--t-theme) var(--ease); flex: 0 0 auto; }
.metric-value { font-size: 23px; font-weight: 700; margin-top: 7px; font-variant-numeric: tabular-nums; }
.metric-value small { font-size: 11px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.metric-bar {
  margin-top: 8px; height: 3px; border-radius: 2px; overflow: hidden;
  background: rgba(255, 255, 255, .08);
}
.metric-bar i {
  display: block; height: 100%; border-radius: 2px; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 8px var(--accent-glow);
  transition: width 1100ms var(--ease), background var(--t-theme) var(--ease);
}
.metric-sub { margin-top: 7px; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- right column ---- */
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10.5px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-3);
}
.section-head .meta { letter-spacing: .02em; text-transform: none; font-weight: 500; font-size: 11.5px; color: var(--ink-3); }
.section-head .meta b { color: var(--ink-2); font-weight: 600; }

.suntrack { position: relative; }
.suntrack svg { width: 100%; height: auto; display: block; margin-top: 2px; overflow: visible; }
.sun-times { display: flex; justify-content: space-between; margin-top: -6px; }
.sun-times div { text-align: center; }
.sun-times .k { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.sun-times .v { font-size: 15px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.sun-times div:first-child { text-align: left; }
.sun-times div:last-child { text-align: right; }

.trend { margin-top: 22px; position: relative; }
.chart-wrap { position: relative; margin-top: 10px; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
#tooltip {
  position: absolute; pointer-events: none; z-index: 8;
  padding: 7px 11px; border-radius: 10px;
  background: rgba(12, 16, 30, .85);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45), 0 0 18px -6px var(--accent-glow);
  opacity: 0; transform: translate(-50%, 6px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), left 120ms var(--ease), top 120ms var(--ease);
}
#tooltip.on { opacity: 1; transform: translate(-50%, 0); }
#tooltip .tt-sub { font-size: 10px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }

.week { margin-top: 20px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.week-rows { margin-top: 8px; display: flex; flex-direction: column; flex: 1; min-height: 0; justify-content: space-around; }
.wrow {
  display: grid;
  grid-template-columns: 64px 26px 36px 1fr 36px 84px;
  align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 12px;
  font-size: 12.5px;
  transition: background 300ms var(--ease), transform 300ms var(--ease);
}
.wrow:hover { background: rgba(255, 255, 255, .05); transform: translateX(4px); }
.wrow .day { font-weight: 600; }
.wrow .day.today { color: var(--accent); transition: color var(--t-theme) var(--ease); }
.wrow svg { color: var(--accent); transition: color var(--t-theme) var(--ease); }
.wrow .min { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.wrow .max { font-weight: 650; font-variant-numeric: tabular-nums; }
.wrow .cond { text-align: right; color: var(--ink-2); font-size: 11px; line-height: 1.3; }
.wbar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); position: relative; overflow: hidden; }
.wbar i {
  position: absolute; top: 0; bottom: 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--chart-2), var(--accent-2));
  box-shadow: 0 0 8px var(--accent-glow);
  transition: left 900ms var(--ease), width 900ms var(--ease), background var(--t-theme) var(--ease);
}

/* ============ toolbar ============ */
.toolbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(14, 18, 32, .55);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .09);
}
.mode-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid transparent;
  background: transparent; color: var(--ink-2);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 350ms var(--ease);
}
.mode-btn:hover { color: var(--ink); background: rgba(255, 255, 255, .06); transform: translateY(-1px); }
.mode-btn:active { transform: scale(.95); }
.mode-btn.active {
  color: #10131f;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: rgba(255, 255, 255, .25);
  box-shadow: 0 6px 24px -4px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.mode-btn .num {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, .12);
}
.mode-btn.active .num { background: rgba(0, 0, 0, .18); }

.tool-sep { width: 1px; height: 26px; background: rgba(255, 255, 255, .12); margin: 0 2px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .06);
  color: var(--ink-2); cursor: pointer;
  transition: all 300ms var(--ease);
}
.icon-btn:hover {
  color: var(--ink); background: var(--accent-soft);
  border-color: rgba(255, 255, 255, .2);
  box-shadow: 0 0 20px -4px var(--accent-glow);
  transform: translateY(-1px);
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.spinning svg { animation: spin 900ms var(--ease); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn.muted { opacity: .55; }

/* settings popover */
#settingsPop {
  position: fixed; right: 50%; bottom: 86px; transform: translateX(50%) translateY(8px);
  z-index: 60;
  width: 250px; padding: 16px;
  border-radius: 18px;
  background: rgba(14, 18, 32, .8);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .65);
  opacity: 0; pointer-events: none;
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
}
#settingsPop.open { opacity: 1; pointer-events: auto; transform: translateX(50%) translateY(0); }
#settingsPop h3 { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; color: var(--ink-2); }
.set-row input[type="range"] { width: 110px; accent-color: var(--accent); }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: rgba(255, 255, 255, .14); cursor: pointer; transition: background 250ms; border: none; }
.switch::after { content: ''; position: absolute; top: 2.5px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform 250ms var(--ease); }
.switch.on { background: var(--accent-2); }
.switch.on::after { transform: translateX(15px); }

/* toast */
#toast {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%) translateY(-18px);
  z-index: 70;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-radius: 999px;
  background: rgba(14, 18, 32, .78);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 16px 44px -10px rgba(0, 0, 0, .6), 0 0 30px -8px var(--accent-glow);
  font-size: 13px; font-weight: 550;
  opacity: 0; pointer-events: none;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .check {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  transition: background var(--t-theme) var(--ease), color var(--t-theme) var(--ease);
}

/* hero icon animations */
.anim-sun #sunCore { animation: sunPulse 4s ease-in-out infinite; transform-origin: center; }
.anim-sun #sunRays { animation: sunSpin 36s linear infinite; transform-origin: center; }
@keyframes sunPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes sunSpin { to { transform: rotate(360deg); } }
.drop-line { animation: dropFall 1.3s ease-in infinite; }
.drop-line:nth-child(2) { animation-delay: .45s; }
.drop-line:nth-child(3) { animation-delay: .85s; }
@keyframes dropFall {
  0% { transform: translateY(0); opacity: 0; }
  25% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(16px); opacity: 0; }
}
.flake { animation: flakeFall 2.6s ease-in-out infinite; }
.flake:nth-child(2) { animation-delay: .9s; }
.flake:nth-child(3) { animation-delay: 1.7s; }
@keyframes flakeFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(15px) rotate(120deg); opacity: 0; }
}
.gust { stroke-dasharray: 60; animation: gustFlow 2.1s ease-in-out infinite; }
.gust:nth-child(2) { animation-delay: .35s; }
.gust:nth-child(3) { animation-delay: .7s; }
@keyframes gustFlow {
  0% { stroke-dashoffset: 60; opacity: 0; }
  30% { opacity: 1; }
  75% { opacity: 1; }
  100% { stroke-dashoffset: -60; opacity: 0; }
}
body[data-weather="wind"] .hero-icon { animation: sway 3.4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
body[data-weather="rain"] .hero-icon { animation: ripple 3s ease-in-out infinite; }
@keyframes ripple { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* chart bits */
.grid-line { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.chart-area { transition: fill var(--t-theme) var(--ease); }
.chart-line {
  fill: none; stroke: var(--chart); stroke-width: 2; stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--accent-glow));
  transition: stroke var(--t-theme) var(--ease);
}
.chart-dot { fill: var(--chart); transition: fill var(--t-theme) var(--ease); filter: drop-shadow(0 0 5px var(--accent-glow)); }
.chart-dot-halo { fill: var(--accent-glow); opacity: .35; transition: fill var(--t-theme) var(--ease); }
.chart-label { fill: rgba(255, 255, 255, .78); font-size: 10px; font-weight: 600; font-family: inherit; }
.chart-xlabel { fill: rgba(255, 255, 255, .32); font-size: 9px; font-family: inherit; }
.precip-bar { fill: var(--chart); opacity: .3; transition: fill var(--t-theme) var(--ease); rx: 2; }
.precip-label { fill: rgba(255, 255, 255, .3); font-size: 8.5px; font-family: inherit; }

/* sun arc */
.arc-base { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 1.6; stroke-dasharray: 3 6; }
.arc-fill { fill: none; stroke: url(#arcGrad); stroke-width: 2.4; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--accent-glow)); }
#sunDisc { filter: drop-shadow(0 0 14px rgba(255, 200, 100, .9)); }
.horizon { stroke: rgba(255, 255, 255, .1); stroke-width: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
}

/* responsive fallback */
@media (max-width: 1100px) {
  body { overflow: auto; }
  .stage { height: auto; min-height: 100%; }
  .panel { grid-template-columns: 1fr; height: auto; }
  .col-left { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ============ SyriaMeteo v2 additions ============ */

html[dir="rtl"] body { font-family: 'IBM Plex Sans Arabic', 'Inter', -apple-system, sans-serif; }
html[dir="rtl"] .sync { letter-spacing: 0; font-size: 12px; }
html[dir="rtl"] .metric-label, html[dir="rtl"] .section-head > span:first-child,
html[dir="rtl"] .sun-times .k { letter-spacing: 0; }
html[dir="rtl"] .clock { text-align: left; }

/* keep time-based visuals LTR so they align with the SVGs */
.sun-times, .chart-wrap, .clock .time { direction: ltr; }
html[dir="rtl"] .sun-times { direction: ltr; }
html[dir="rtl"] .wrow:hover { transform: translateX(-4px); }

/* city dropdown */
.city-wrap { position: relative; }
.city h1 { cursor: pointer; }
.city h1:hover svg { opacity: .9; }
#cityMenu {
  position: absolute; top: calc(100% + 46px); inset-inline-start: 0; z-index: 90;
  display: none; grid-template-columns: 1fr 1fr; gap: 3px;
  width: 300px; max-height: 320px; overflow: auto;
  padding: 10px; border-radius: 18px;
  background: rgba(14, 18, 32, .88);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .65);
}
#cityMenu.open { display: grid; }
#cityMenu button {
  padding: 9px 12px; border-radius: 11px;
  background: none; border: none; cursor: pointer;
  color: var(--ink-2); font: inherit; font-size: 13.5px; font-weight: 500;
  text-align: start;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
#cityMenu button:hover { background: rgba(255, 255, 255, .07); color: var(--ink); }
#cityMenu button.sel { color: var(--accent); background: var(--accent-soft); font-weight: 700; }

/* language pills in settings */
.lang-opts { display: flex; gap: 6px; }
.lang-opt {
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid transparent;
  color: var(--ink-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 250ms var(--ease);
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.sel {
  color: #10131f;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: rgba(255, 255, 255, .25);
}

/* ============ mobile ============ */
@media (max-width: 1100px) {
  .stage { padding-bottom: 110px; }
  .col-right { padding-top: 30px; }
  .metrics { min-height: 300px; }
  .week-rows { gap: 4px; }
}

@media (max-width: 640px) {
  .stage { padding: 12px 10px 96px; }
  .panel { border-radius: 22px; }
  .col { padding: 20px 18px; }
  .sync { font-size: 9px; letter-spacing: .2em; }
  html[dir="rtl"] .sync { font-size: 11px; }
  .head { margin-top: 12px; gap: 10px; }
  .city h1 { font-size: 21px; }
  .city .sub { font-size: 11.5px; }
  .clock .time { font-size: 18px; }
  .clock .date { font-size: 11px; }
  .hero { gap: 14px; margin: 14px 0 2px; }
  .hero-icon { width: 86px; height: 86px; }
  .hero-icon svg { width: 82px; height: 82px; }
  .temp-value { font-size: 68px; }
  .temp-unit { font-size: 22px; margin-top: 8px; }
  .hero-title { font-size: 17px; }
  .hero-stats { font-size: 11.5px; line-height: 1.7; }
  .insight { padding: 12px 13px; margin-top: 14px; }
  .insight p { font-size: 11.5px; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 14px; min-height: 0; }
  .metric { padding: 11px 12px; border-radius: 14px; }
  .metric-value { font-size: 19px; }
  .section-head { flex-wrap: wrap; gap: 2px 10px; }
  .section-head .meta { font-size: 10.5px; }
  .sun-times .v { font-size: 13px; }
  .wrow { grid-template-columns: 56px 22px 30px 1fr 30px 70px; gap: 7px; padding: 6px 6px; font-size: 11.5px; }
  .wrow .cond { font-size: 9.5px; }
  .toolbar { bottom: 14px; padding: 7px; }
  .icon-btn { width: 44px; height: 44px; }
  #settingsPop { width: min(86vw, 280px); bottom: 76px; }
  #cityMenu { width: min(84vw, 300px); }
  #toast { top: 14px; width: max-content; max-width: 92vw; font-size: 12px; padding: 10px 15px; }
  #flare { width: 200px; height: 200px; }
}

/* very small phones */
@media (max-width: 380px) {
  .temp-value { font-size: 56px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .wrow { grid-template-columns: 50px 20px 26px 1fr 26px 58px; }
}

/* bidi fixes: numeric runs stay LTR inside RTL text */
.temp-row { direction: ltr; }
html[dir="rtl"] .hero-stats b, html[dir="rtl"] .section-head .meta b,
html[dir="rtl"] .metric-sub, html[dir="rtl"] .wrow .min, html[dir="rtl"] .wrow .max {
  unicode-bidi: plaintext;
}

/* ============ Telegram Mini App ============ */
/* No navbar above the panel here, so the stage keeps its own breathing room. */
.stage { padding-top: 18px; }
#refreshBtn.spin svg { animation: spinBtn 600ms var(--ease); }
@keyframes spinBtn { to { transform: rotate(360deg); } }
/* Telegram's own close button sits top-end: keep the toolbar reachable above the home bar. */
@media (max-width: 640px) {
  .toolbar { bottom: max(14px, env(safe-area-inset-bottom)); }
}
