/**
 * info-hint.css — bohatá vysvětlující karta pro meteorologické termíny
 * Vyrenderuje ji `ui_info_hint($key, $opts)` z includes/ui/info_hint.php.
 *
 * KLÍČOVÉ:
 *   - .info-card používá `position: fixed`, takže ho neořezává overflow:hidden
 *     na žádném parent kontejneru
 *   - Pozici počítá JS (info-card.js) ze souřadnic triggeru
 *   - Karta má hover-bridge ::before pseudo-element, takže přechod
 *     trigger → karta nezavírá popover
 *   - Karta má max-height + overflow-y: auto pro scroll u dlouhých textů
 *   - Typografie je explicitně resetována, aby nedědila uppercase/letter-spacing
 *     z parent labelů (.card-label, .lbl, …)
 */

/* ============================================================================
   TRIGGER — kompaktní „i" ikonka (12–14 px, neruší layout)
   ============================================================================ */
.info-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: baseline;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
}
.info-hint__trigger {
  --ih-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ih-size);
  height: var(--ih-size);
  margin: 0 0 0 3px;       /* kompaktní — pravý prostor řeší layout sám */
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--blue-50, #EEF1FA);
  color: var(--blue, #002072);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
  font-family: inherit;
  font-size: 0;
  line-height: 0;
  flex-shrink: 0;
  /* relativní zarovnání s textem */
  vertical-align: -1px;
  position: relative;
  top: -1px;
}
.info-hint__trigger > svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  stroke: currentColor;
  fill: none;
}
.info-hint--md .info-hint__trigger { --ih-size: 16px; }
.info-hint--lg .info-hint__trigger { --ih-size: 18px; }

.info-hint__trigger:hover,
.info-hint__trigger:focus-visible {
  background: var(--blue, #002072);
  color: #fff;
  transform: scale(1.15);
  outline: none;
}
.info-hint.is-pinned .info-hint__trigger {
  background: var(--blue, #002072);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(0, 32, 114, .2);
}

/* ============================================================================
   CARD — bohatý popover (position: absolute v body, JS pozicuje, plynulé scroll)
   ============================================================================ */
.info-card {
  /* ABSOLUTE pozicování v <body> (portalled JS-em).
     Document-relative souřadnice → karta scrolluje s dokumentem nativně,
     žádný JS reposition na scroll, žádné trhání. */
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 32px);

  background: var(--surface, #FFFFFF);
  border: 1px solid var(--line, #ECEEF4);
  border-radius: 18px;
  box-shadow:
    0 1px 2px rgba(15, 25, 51, .04),
    0 8px 28px rgba(15, 25, 51, .10),
    0 24px 60px rgba(15, 25, 51, .06);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity .16s ease,
    transform .2s cubic-bezier(.16, .8, .24, 1),
    visibility 0s linear .25s;

  /* Flexbox pro scrollovatelný body mezi sticky head a foot */
  display: flex;
  flex-direction: column;

  /* === TYPOGRAFIE — explicitní reset, aby nedědil z parent .card-label === */
  text-align: left;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;          /* zruší nowrap z parent labelu (např. .feels-label) */
  word-break: normal;
  color: var(--ink, #0F1933);
}

/* Reset typography pro VŠECHNY potomky — zruší kaskádu z .card-label / .feels-label */
.info-card *,
.info-card *::before,
.info-card *::after {
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  word-break: normal;
  font-style: normal;
  font-feature-settings: normal;
}
.info-card .info-card__subtitle,
.info-card .info-card__scale-title,
.info-card .info-card__current-label {
  text-transform: uppercase;
  letter-spacing: .06em;
}
/* Zachovat italic tam kde má být */
.info-card .info-card__title em,
.info-card .info-card__current-value .verdict {
  font-style: italic;
}
/* Range na stupnici musí zůstat na jednom řádku */
.info-card .info-card__scale-labels .range {
  white-space: nowrap;
}

/* ── Hover-bridge — neviditelná 16px „lávka" mezi triggerem a kartou.
   Karta sedí 12 px nad/pod triggerem, takže mouse-cursor by jinak po cestě
   přešel přes prázdný gap a mouseout by ji zavřel. ::before tu mezeru
   překrývá a chytá pointer-events. */
.info-card::before {
  content: '';
  position: absolute;
  left: -8px;
  right: -8px;
  height: 18px;
  pointer-events: auto;
  z-index: 0;
}
.info-card:not(.is-flipped)::before { bottom: -18px; }
.info-card.is-flipped::before { top: -18px; }

/* Karta je portalled do <body> přes JS, takže CSS targeting jde přímo na ni
   pomocí is-open / is-pinned tříd — ne přes parent host. */
.info-card.is-open,
.info-card.is-pinned {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity .16s ease, transform .2s cubic-bezier(.16, .8, .24, 1), visibility 0s linear 0s;
}
.info-card.is-pinned {
  box-shadow:
    0 1px 2px rgba(15, 25, 51, .05),
    0 12px 36px rgba(15, 25, 51, .16),
    0 32px 80px rgba(15, 25, 51, .10);
  border-color: var(--line-strong, #DDE1EB);
}

/* Šipka — JS nastavuje --arrow-x */
.info-card__arrow {
  position: absolute;
  left: var(--arrow-x, 50%);
  width: 12px;
  height: 12px;
  background: var(--surface, #FFFFFF);
  transform: translateX(-50%) rotate(45deg);
  z-index: 1;
}
.info-card:not(.is-flipped) .info-card__arrow {
  bottom: -7px;
  border-right: 1px solid var(--line, #ECEEF4);
  border-bottom: 1px solid var(--line, #ECEEF4);
}
.info-card.is-flipped .info-card__arrow {
  top: -7px;
  border-top: 1px solid var(--line, #ECEEF4);
  border-left: 1px solid var(--line, #ECEEF4);
}

/* ============================================================================
   HEAD — ikona + nadpis + close (sticky)
   ============================================================================ */
.info-card__head {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--cream, #FAF8F2) 0%, var(--surface, #FFFFFF) 100%);
  border-bottom: 1px solid var(--line, #ECEEF4);
  position: relative;
  z-index: 2;
  border-radius: 17px 17px 0 0;
  flex-shrink: 0;
}
.info-card__icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--line, #ECEEF4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--blue, #002072);
  box-shadow: 0 1px 3px rgba(15, 25, 51, .05);
}
.info-card__icon > svg {
  width: 22px; height: 22px;
  display: block;
  stroke: currentColor;
  fill: none;
}
.info-card__head-text { flex: 1; min-width: 0; }
.info-card__title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: 20px;
  line-height: 1.15;
  margin: 0 0 2px;
  color: var(--ink, #0F1933);
  letter-spacing: -.005em;
  text-transform: none;
}
.info-card__title em {
  font-style: italic;
  color: var(--blue, #002072);
}
.info-card__subtitle {
  font-size: 11px;
  color: var(--ink-muted, #727A92);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.info-card__close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--ink-muted, #727A92);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  padding: 0;
  z-index: 3;
}
.info-card__close > svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.info-card__close:hover {
  background: var(--bg, #FBFBFD);
  color: var(--ink, #0F1933);
}
.info-card.is-pinned .info-card__close {
  display: inline-flex;
}

/* ============================================================================
   BODY — scrollovatelný kontejner pro lead, desc, scale, current, tip
   ============================================================================ */
.info-card__body {
  padding: 14px 20px 6px;
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  /* DEFAULT (hover stav): overflow hidden — wheel events propadají na stránku.
     Karta nezachycuje scroll, takže stránka jde scrollovat i přes kartu. */
  overflow: hidden;
}
/* PINNED stav (klik): povolíme scroll uvnitř karty pro dlouhý obsah. */
.info-card.is-pinned .info-card__body {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong, #DDE1EB) transparent;
}
.info-card.is-pinned .info-card__body::-webkit-scrollbar {
  width: 6px;
}
.info-card.is-pinned .info-card__body::-webkit-scrollbar-track {
  background: transparent;
}
.info-card.is-pinned .info-card__body::-webkit-scrollbar-thumb {
  background: var(--line-strong, #DDE1EB);
  border-radius: 3px;
}
.info-card.is-pinned .info-card__body::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint, #A5ACBF);
}

.info-card__body::-webkit-scrollbar {
  width: 6px;
}
.info-card__body::-webkit-scrollbar-track {
  background: transparent;
}
.info-card__body::-webkit-scrollbar-thumb {
  background: var(--line-strong, #DDE1EB);
  border-radius: 3px;
}
.info-card__body::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint, #A5ACBF);
}

.info-card__lead {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink, #0F1933);
  margin: 0 0 10px;
  font-weight: 500;
  text-transform: none;
}
.info-card__desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft, #3D4869);
  margin: 0 0 14px;
  text-transform: none;
}
.info-card__desc strong { color: var(--ink, #0F1933); font-weight: 600; }

/* Stupnice */
.info-card__scale { margin: 0 0 14px; }
.info-card__scale-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted, #727A92);
  font-weight: 600;
  margin-bottom: 6px;
}
.info-card__scale-bar {
  display: flex;
  height: 9px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(15, 25, 51, .06);
  margin-bottom: 8px;
}
.info-card__scale-bar > span {
  flex: 1;
  height: 100%;
  transition: opacity .2s, transform .2s;
}
.info-card__scale-bar > span.is-active {
  position: relative;
  z-index: 1;
  transform: scaleY(1.5);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--surface, #fff);
}
.info-card__scale-bar:has(.is-active) > span:not(.is-active) {
  opacity: .6;
}
.info-card__scale-labels {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}
.info-card__scale-labels li {
  display: grid;
  /* range column: nikdy víc než 50% šířky karty, přibližně 110px max */
  grid-template-columns: 8px minmax(0, max-content) minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.4;
  padding: 3px 4px;
  border-radius: 6px;
  position: relative;
  transition: background .15s;
  min-width: 0;
}
.info-card__scale-labels li::before {
  content: '';
  display: block;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--c, var(--ink-faint, #A5ACBF));
  margin-top: 5px;
  flex-shrink: 0;
}
.info-card__scale-labels li.is-active {
  background: var(--blue-50, #EEF1FA);
}
.info-card__scale-labels .range {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink, #0F1933);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  text-transform: none;
  /* Pokud by range byl extrémně dlouhý (málo pravděpodobné), zalom */
  overflow-wrap: break-word;
  min-width: 0;
}
.info-card__scale-labels .desc {
  color: var(--ink-soft, #3D4869);
  text-transform: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
.info-card__scale-labels li.is-active .desc {
  color: var(--ink, #0F1933);
  font-weight: 500;
}

/* Aktuálně u vás */
.info-card__current {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--blue-50, #EEF1FA) 0%, #F5F8FF 100%);
  border-radius: 10px;
  border-left: 3px solid var(--blue, #002072);
}
.info-card__current-label {
  font-size: 10px;
  color: var(--blue, #002072);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.info-card__current-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.info-card__current-value .num {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink, #0F1933);
  font-variant-numeric: tabular-nums;
  text-transform: none;
}
.info-card__current-value .verdict {
  font-size: 12.5px;
  color: var(--ink-soft, #3D4869);
  font-style: italic;
  text-transform: none;
}
.info-card__current-value .verdict::before { content: '— '; }

/* Tip */
.info-card__tip {
  margin: 0 0 14px;
  padding: 10px 12px 10px 36px;
  background: #FCFAF1;
  border: 1px solid #F0E9D2;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #5C4F1F;
  position: relative;
  text-transform: none;
}
.info-card__tip::before {
  content: '';
  position: absolute;
  left: 12px; top: 11px;
  width: 14px; height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M9 21h6v-1H9v1zm3-19a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2z'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M9 21h6v-1H9v1zm3-19a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2z'/></svg>") no-repeat center / contain;
}
.info-card__tip strong { color: #3F3416; font-weight: 600; }

/* ============================================================================
   FOOT — sticky patička (Číst více + zdroj)
   ============================================================================ */
.info-card__foot {
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line, #ECEEF4);
  background: var(--bg, #FBFBFD);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  border-radius: 0 0 17px 17px;
}
.info-card__more {
  font-size: 12.5px;
  color: var(--blue, #002072);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: gap .15s;
  text-transform: none;
}
.info-card__more::after { content: '→'; }
.info-card__more:hover { gap: 8px; }
.info-card__source {
  font-size: 10.5px;
  color: var(--ink-faint, #A5ACBF);
  text-transform: none;
}

/* Simple variant (legacy fallback) */
.info-card.info-card--simple {
  width: 280px;
}
.info-card.info-card--simple .info-card__body {
  padding: 14px 18px;
}
.info-card.info-card--simple .info-card__lead {
  margin: 0;
  font-weight: 400;
  font-size: 13.5px;
  color: var(--ink-soft, #3D4869);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 520px) {
  .info-card { width: calc(100vw - 16px); }
}

/* Print */
@media print {
  .info-hint__trigger { display: none; }
  .info-card { display: none !important; }
}
