/* © 2026 Andy217Ace */
/* Tabela Gara de Nord — ceasul din antet + widgetul meteo (web/weather.js).
   Culori doar din tokenii temei (style.css: --text, --surface…), deci urmează Auto/Luminoasă/
   Întunecată. Fără stiluri inline (CSP). */

/* ---------- ceas în antet ---------- */

/* telefon/tabletă: rândul 2, înaintea indicatorului „actualizat" (rândul 1 rămâne sigla +
   tema); desktop: lângă siglă */
.hdr-clockwx {
  order: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

/* Panoul are ceasul și vremea lui în bara de titlu: în antet nu le dublăm */
html[data-view="panou"] body:has(#view-tabela:not([hidden])) .hdr-clockwx { display: none; }

.hdr-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.hdr-clock-time {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.hdr-clock-date {
  display: none;
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- widget ---------- */

.wx-slot { display: flex; flex: none; max-width: 100%; }
.wx-slot[hidden] { display: none; }

.wx { position: relative; display: flex; max-width: 100%; }

.wx-btn {
  appearance: none;
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 5px;
  min-height: 44px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.wx-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.wx-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wx-btn:disabled { cursor: default; }

.wx-ico { grid-row: 1 / span 2; display: grid; place-items: center; color: var(--accent); }
.wx[data-daynight="night"] .wx-ico,
.wx[data-daynight="night"] .wx-svg-lg { color: var(--info); }
.wx-svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wx-temp {
  font-family: var(--mono);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.wx-sub {
  grid-column: 2;
  display: flex;
  gap: 6px;
  font-size: var(--fs-xs);
  line-height: 1.2;
  color: var(--text-2);
  white-space: nowrap;
}
.wx-feels { display: none; }
.wx-wind { display: inline-flex; align-items: center; gap: 3px; }
.wx-arrow {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wx-old {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.wx-na { font-size: 0.75rem; color: var(--text-2); white-space: nowrap; }

/* stări */
.wx[data-state="stale"] .wx-btn { border-style: dashed; background: var(--surface-2); }
.wx[data-state="stale"] .wx-ico,
.wx[data-state="stale"] .wx-temp { color: var(--text-2); }
.wx[data-state="unavailable"] .wx-btn { min-height: 32px; border-style: dashed; }
.wx[data-state="loading"] .wx-btn { border-color: transparent; background: transparent; }
.wx-sk {
  display: block;
  width: 64px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: wx-pulse 1.4s var(--ease) infinite;
}
@keyframes wx-pulse { 50% { opacity: 0.45; } }

/* ---------- popover ---------- */

.wx-pop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: min(320px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
  font-family: var(--font);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.wx-pop::before { /* punte peste spațiul de 6 px, ca hover-ul să nu se rupă */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}
.wx.wx-left .wx-pop { right: auto; left: 0; }
.wx.is-open .wx-pop { display: block; }
@media (hover: hover) and (pointer: fine) {
  .wx:hover .wx-pop { display: block; }
}

.wx-pop p { margin: 0; }
.wx-pop-title { font-weight: 700; }
.wx-pop-cond { color: var(--text-2); }
.wx-hero { display: flex; align-items: center; gap: 12px; margin: 10px 0 12px; }
.wx-svg-lg { width: 44px; height: 44px; flex: none; color: var(--accent); stroke-width: 1.5; }
.wx-hero-t { min-width: 0; }
.wx-hero-temp {
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* plăcuțe cu detalii (dl cu grupuri div > dt + dd) */
.wx-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
}
.wx-tile {
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.wx-tile-wide { grid-column: 1 / -1; }
.wx-tile-l { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.2; }
.wx-tile-v { margin: 0; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.wx-tile-h { display: block; color: var(--text-2); font-size: var(--fs-xs); font-weight: 400; }
.wx-tile-v .wx-arrow { width: 14px; height: 14px; flex: none; }

/* grafic 24 h */
.wx-chart { margin: 0 0 8px; }
.wx-chart[hidden] { display: none; }
.wx-chart-cap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 8px;
  margin-bottom: 2px;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.wx-chart-t { font-weight: 600; color: var(--text); }
.wx-spark { display: block; width: 100%; height: auto; overflow: visible; }
.wx-sp-base { stroke: var(--border-strong); stroke-width: 1; }
.wx-sp-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wx-sp-area { fill: var(--accent); fill-opacity: 0.14; stroke: none; }
.wx-sp-dot { fill: var(--accent); }
.wx-sp-pt { stroke: var(--surface); stroke-width: 1.5; }
.wx-sp-pt.wx-sp-max { fill: var(--accent); }
.wx-sp-pt.wx-sp-min { fill: var(--info); }
.wx-sp-val { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.wx-sp-val.wx-sp-max { fill: var(--accent); }
.wx-sp-val.wx-sp-min { fill: var(--info); }
.wx-sp-ax { fill: var(--text-2); font-family: var(--mono); font-size: 10px; }
.wx-sp-now { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.wx-sp-nowpt { fill: var(--text); stroke: var(--surface); stroke-width: 1.5; }
.wx-sp-nowl { fill: var(--text); font-size: 10px; font-weight: 700; }

/* date vechi: seria desenată în gri (textele își păstrează contrastul) */
.wx-chart.is-stale .wx-sp-line { stroke: var(--text-2); stroke-dasharray: 4 3; }
.wx-chart.is-stale .wx-sp-area { fill: var(--text-2); }
.wx-chart.is-stale .wx-sp-pt.wx-sp-max, .wx-chart.is-stale .wx-sp-pt.wx-sp-min { fill: var(--text-2); }
.wx-chart.is-stale .wx-sp-val { fill: var(--text-2); }

.wx-pop-when { color: var(--text-2); font-size: var(--fs-xs); }
.wx-pop-warn {
  margin: 0 0 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 600;
}
.wx-pop-note { margin-top: 4px; color: var(--text-2); font-size: 0.75rem; }
.wx-pop-src { margin-top: 6px; font-size: 0.75rem; color: var(--text-2); }
.wx-pop-src a { color: var(--text); text-underline-offset: 2px; }
.wx-pop-src a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- atribuire (footer + credit Panou) ---------- */

.footer-meteo { color: var(--text-2); }
.footer-meteo[hidden], .wx-credit[hidden] { display: none; }

/* ---------- Panou: vremea lângă ceasul mare ---------- */

.pnl-clockwx { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0; }
.wx[data-place="panel"] .wx-btn { padding: 4px 10px; }
.wx[data-place="panel"] .wx-svg { width: 30px; height: 30px; }
.wx[data-place="panel"] .wx-temp { font-family: var(--mono); font-size: clamp(1.1rem, 0.75rem + 1.2vw, 1.9rem); }
.wx[data-place="panel"] .wx-feels { display: inline; }
.pnl.is-fs .wx[data-place="panel"] .wx-svg { width: 40px; height: 40px; }

/* ---------- telefon: compact (pictogramă + temperatură + vânt mic) ---------- */

@media (max-width: 599px) {
  /* popover pe toată lățimea, sub widget, fără scroll orizontal. `top: auto` = poziția
     statică, adică sub buton: de aceea .wx e bloc (într-un container flex ar începe în
     colțul de sus și ar acoperi butonul) */
  .wx { display: block; }
  .wx-btn { vertical-align: top; }
  .wx-pop,
  .wx.wx-left .wx-pop {
    position: fixed;
    top: auto;
    left: 16px;
    right: 16px;
    width: auto;
    margin-top: 6px;
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 430px) {
  .wx-feels { display: inline; }
}

@media (min-width: 1024px) {
  .hdr-clockwx { order: 1; margin-left: 8px; gap: 10px; }
  .hdr-clock-time { font-size: 1.25rem; }
  .hdr-clock-date { display: block; }
}

/* ---------- mișcare / contrast forțat ---------- */

@media (prefers-reduced-motion: reduce) {
  .wx-sk { animation: none; }
}

@media (forced-colors: active) {
  .wx-btn, .wx-pop { border: 1px solid CanvasText; }
}

/* telefoane înguste: în antet doar iconița + temperatura (detaliile în popover), ca ceasul,
   vremea și indicatorul „actualizat" să încapă pe un rând */
@media (max-width: 429px) {
  .hdr-clockwx .wx-sub { display: none; }
  .hdr-clockwx .wx-btn { padding: 3px 10px 3px 8px; grid-template-rows: auto; }
  .hdr-clockwx .wx-ico { grid-row: 1; }
}
