/* storyline.css — polymarkets.co.il shortcode components
   Class names align exactly with lib/shortcodes.php output.
   ==================================================================== */

:root {
  --pm-bg:        #0b0f14;
  --pm-card:      #12171f;
  --pm-border:    #1f2a36;
  --pm-text:      #e7eef7;
  --pm-dim:       #8a98ab;
  --pm-accent:    #4C82FB;
  --pm-green:     #2ecc71;
  --pm-red:       #ef4444;
  --pm-amber:     #f59e0b;
  --pm-purple:    #a855f7;
  --pm-shadow:    0 8px 32px rgba(0,0,0,.35);
  --pm-radius:    14px;
}

/* ============================================================= STORYLINE
   <figure class="pm-storyline" data-storyline='...'> containing
   .pm-story-head, .pm-story-chart-wrap, .pm-story-moments, .pm-story-cta
   ==================================================================== */
.pm-storyline {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius);
  margin: 32px 0;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--pm-shadow);
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-areas:
    "head head"
    "chart moments"
    "cta  cta";
}
@media (max-width: 820px) {
  .pm-storyline {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "chart" "moments" "cta";
  }
}

.pm-story-head {
  grid-area: head;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--pm-border);
  background: linear-gradient(180deg, rgba(77,163,255,.04), transparent);
}
.pm-story-eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--pm-accent);
  font-weight: 700;
  margin-bottom: 6px;
}
.pm-story-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--pm-text);
  line-height: 1.25;
  margin: 0 0 4px;
}
.pm-story-sub {
  color: var(--pm-dim);
  font-size: 14px;
  margin: 0 0 10px;
  line-height: 1.5;
}
.pm-story-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.pm-story-stats .pm-stat {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--pm-border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--pm-text);
  font-weight: 600;
}
.pm-story-stats .pm-stat b {
  color: var(--pm-dim);
  font-weight: 700;
  margin-right: 4px;
}

.pm-story-legend {
  grid-area: chart;
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 16px 20px 0;
}
.pm-story-legend:empty { display: none; }
.pm-story-legend .chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--pm-dim);
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--pm-border);
  border-radius: 999px;
}
.pm-story-legend .chart-legend-item strong {
  color: var(--pm-text);
  font-weight: 700;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pm-story-legend .legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.pm-story-chart-wrap {
  grid-area: chart;
  position: relative;
  padding: 44px 20px 14px; /* top padding leaves room for absolute legend above */
  border-right: 1px solid var(--pm-border);
  min-height: 340px;
}
.pm-story-chart {
  width: 100% !important;
  height: 300px !important;
  display: block;
}
.pm-story-annotations {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pm-story-intervals { display: none; } /* reserved for future interval switcher */
@media (max-width: 820px) {
  .pm-story-chart-wrap { border-right: 0; border-bottom: 1px solid var(--pm-border); }
}

.pm-story-moments {
  grid-area: moments;
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 420px;
}
.pm-story-moments-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--pm-dim);
  margin-bottom: 12px;
  font-weight: 700;
}
.pm-moments-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pm-moments-list > .pm-moment {
  display: block;
  border-left: 3px solid var(--pm-border);
  padding: 10px 14px 12px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.02);
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  transition: all .18s;
}
.pm-moments-list > .pm-moment:hover,
.pm-moments-list > .pm-moment.is-active {
  background: rgba(77,163,255,.08);
  border-left-color: var(--pm-accent);
}
.pm-moment-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
}
.pm-moment-date {
  font-size: 11px;
  color: var(--pm-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pm-moment-delta {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
}
.pm-moment-delta.pos { color: var(--pm-green); background: rgba(46,204,113,.1); }
.pm-moment-delta.neg { color: var(--pm-red);   background: rgba(239,68,68,.1);  }
.pm-moment-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--pm-text);
  line-height: 1.35;
  margin-bottom: 4px;
}
.pm-moment-body {
  font-size: 13px;
  color: var(--pm-dim);
  line-height: 1.5;
}
.pm-moment-news {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--pm-accent);
  text-decoration: none;
}
.pm-moment-news:hover { text-decoration: underline; }

.pm-story-cta {
  grid-area: cta;
  padding: 14px 24px;
  border-top: 1px solid var(--pm-border);
  background: rgba(0,0,0,.18);
  text-align: center;
}
.pm-cta-primary {
  display: inline-block;
  padding: 10px 22px;
  background: var(--pm-accent);
  color: #0b0f14;
  text-decoration: none;
  font-weight: 700;
  border-radius: 8px;
  font-size: 14px;
  transition: transform .15s, background .15s;
}
.pm-cta-primary:hover { transform: translateY(-1px); background: #69b4ff; }

/* ================================================================= CASE
   <aside class="pm-case" data-series='...'>
   ==================================================================== */
.pm-case {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius);
  padding: 16px;
  margin: 24px 0;
}
@media (max-width: 640px) { .pm-case { grid-template-columns: 1fr; } }
.pm-case-chart { min-height: 140px; }
.pm-case-canvas { width: 100% !important; height: 140px !important; }
.pm-case-body > *:first-child { margin-top: 0; }
.pm-case-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--pm-dim); margin-bottom: 6px; font-weight: 700;
}
.pm-case-title {
  font-size: 16px; font-weight: 700; color: var(--pm-text);
  margin: 0 0 6px; line-height: 1.3;
}
.pm-case-summary {
  margin: 0 0 8px; color: var(--pm-text); font-size: 14px; line-height: 1.55;
}
.pm-case-link {
  color: var(--pm-accent); text-decoration: none; font-size: 13px; font-weight: 600;
}
.pm-case-link:hover { text-decoration: underline; }

/* =========================================================== COMPARISON
   <figure class="pm-comparison" data-series='[{id,title,series}]'>
   ==================================================================== */
.pm-comparison {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius);
  padding: 20px;
  margin: 24px 0;
}
.pm-cmp-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pm-dim);
  font-weight: 700;
  margin-bottom: 12px;
}
/* Matches the site's .chart-legend / .chart-legend-item / .legend-dot pattern */
.pm-cmp-legend-wrap {
  display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px;
  font-size: 13px;
}
.pm-cmp-legend {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--pm-dim);
}
.pm-cmp-legend i {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.pm-cmp-legend strong {
  color: var(--pm-text);
  font-family: 'Inter', 'Heebo', sans-serif;
  font-weight: 600;
  margin-inline-start: 2px;
}
.pm-cmp-chart-wrap { min-height: 280px; }
.pm-cmp-chart { width: 100% !important; height: 280px !important; }

/* ========================================================== MOMENT CARD
   <aside class="pm-moment-card pos|neg"> (from <pm-moment storyline=...>)
   ==================================================================== */
.pm-moment-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(135deg, rgba(77,163,255,.08), rgba(168,85,247,.04));
  border: 1px solid rgba(77,163,255,.25);
  border-left: 4px solid var(--pm-accent);
  border-radius: var(--pm-radius);
  padding: 14px 18px;
  margin: 20px 0;
}
.pm-moment-card.pos { border-left-color: var(--pm-green); }
.pm-moment-card.neg { border-left-color: var(--pm-red);   }
.pm-moment-card-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.pm-moment-card-date  { color: var(--pm-dim); }
.pm-moment-card-delta {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0,0,0,.35);
}
.pm-moment-card.pos .pm-moment-card-delta { color: var(--pm-green); }
.pm-moment-card.neg .pm-moment-card-delta { color: var(--pm-red);   }
.pm-moment-card-title {
  font-weight: 700; color: var(--pm-text); font-size: 15px; line-height: 1.35;
}
.pm-moment-card-body {
  margin: 0; color: var(--pm-text); font-size: 14px; line-height: 1.55;
}

/* ================================================================ STATS
   Inline <span class="pm-stat-inline"> and pill .pm-stat (from stat-strip)
   ==================================================================== */
.pm-stat-inline {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(76,130,251,.12);
  color: var(--pm-accent);
  border-radius: 4px;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 0.95em;
}

/* ============================================================== GLOSSARY
   <span class="pm-gloss" data-term="..." data-def="...">...</span>
   ==================================================================== */
.pm-gloss {
  position: relative;
  border-bottom: 1.5px dotted var(--pm-accent);
  cursor: help;
  color: inherit;
}
.pm-gloss::after {
  content: attr(data-term) ": " attr(data-def);
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 360px;
  padding: 10px 14px;
  background: #0a0e13;
  border: 1px solid var(--pm-border);
  border-radius: 8px;
  box-shadow: var(--pm-shadow);
  font-size: 13px;
  color: var(--pm-text);
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 100;
  white-space: normal;
  text-align: start;
  font-weight: 400;
}
[dir="rtl"] .pm-gloss::after { transform: translateX(50%); }
.pm-gloss:hover::after,
.pm-gloss:focus::after { opacity: 1; }

/* ------- mobile: replace hover popover with bottom-sheet ------- */
@media (max-width: 768px) {
  .pm-gloss { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .pm-gloss::after,
  .pm-gloss:hover::after,
  .pm-gloss:focus::after { display: none !important; opacity: 0 !important; }
}

/* ------- bottom-sheet (rendered to <body> by storyline.js) ------- */
.pm-gs-sheet { display: none; }
.pm-gs-sheet.open { display: block; position: fixed; inset: 0; z-index: 9999; }
.pm-gs-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  animation: pm-gs-fade .2s ease forwards;
}
.pm-gs-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #0F141A;
  color: #F0F2F5;
  border-top: 1px solid var(--pm-border, #2A2D35);
  border-radius: 18px 18px 0 0;
  padding: 22px 22px max(22px, env(safe-area-inset-bottom));
  box-shadow: 0 -12px 44px rgba(0,0,0,.55);
  animation: pm-gs-up .26s cubic-bezier(.2,.85,.3,1) forwards;
  max-height: 70vh; overflow-y: auto;
}
.pm-gs-panel::before {
  content: ""; display: block; width: 40px; height: 4px;
  background: rgba(255,255,255,.18); border-radius: 999px;
  margin: -8px auto 14px;
}
.pm-gs-close {
  position: absolute; top: 10px; inset-inline-end: 12px;
  background: rgba(255,255,255,.06); border: 0;
  width: 34px; height: 34px; border-radius: 50%;
  color: #9DA2AE; font: 700 20px/1 var(--font-body);
  cursor: pointer; display: grid; place-items: center;
}
.pm-gs-close:active { background: rgba(255,255,255,.12); }
.pm-gs-term {
  font: 800 17px/1.3 var(--font-body);
  color: #fff;
  margin: 0 36px 10px 0;
  letter-spacing: -.005em;
}
[dir="rtl"] .pm-gs-term { margin: 0 0 10px 36px; }
.pm-gs-def {
  font: 14.5px/1.55 var(--font-body);
  color: rgba(255,255,255,.86);
}
@keyframes pm-gs-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pm-gs-fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 769px) {
  .pm-gs-sheet, .pm-gs-sheet.open { display: none !important; }
}

/* ========================================================== TAKEAWAYS  */
.pm-takeaways {
  background: rgba(46,204,113,.06);
  border: 1px solid rgba(46,204,113,.2);
  border-left: 4px solid var(--pm-green);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 24px 0;
}
.pm-takeaways-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pm-green);
  font-weight: 700;
  margin-bottom: 10px;
}
.pm-takeaways-icon { margin-right: 4px; }
.pm-takeaways-list { margin: 0; padding-left: 20px; }
.pm-takeaways-list li { margin: 6px 0; color: var(--pm-text); }

/* ============================================================== CALLOUT */
.pm-callout {
  display: flex;
  gap: 14px;
  border: 1px solid var(--pm-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0;
  background: var(--pm-card);
}
.pm-callout-icon { flex-shrink: 0; font-size: 20px; line-height: 1.3; }
.pm-callout-body { flex: 1; }
.pm-callout-body > *:first-child { margin-top: 0; }
.pm-callout-body > *:last-child  { margin-bottom: 0; }
.pm-callout-tip     { border-left: 4px solid var(--pm-accent); }
.pm-callout-warning { border-left: 4px solid var(--pm-amber);  background: rgba(245,158,11,.05); }
.pm-callout-example { border-left: 4px solid var(--pm-purple); background: rgba(168,85,247,.05); }
.pm-callout-success { border-left: 4px solid var(--pm-green);  background: rgba(46,204,113,.05); }
.pm-callout-info    { border-left: 4px solid var(--pm-dim);    }

/* ========================================================= ERROR CARD  */
.pm-error-card {
  background: rgba(239,68,68,.08);
  border: 1px dashed rgba(239,68,68,.4);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0;
  color: var(--pm-red);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.pm-err-title { font-weight: 700; margin-bottom: 4px; }
.pm-err-hint  { color: var(--pm-dim); font-size: 12px; }

/* ============================================================ RTL ADJ  */
[dir="rtl"] .pm-moments-list > .pm-moment { border-left: 0; border-right: 3px solid var(--pm-border); border-radius: 8px 0 0 8px; }
[dir="rtl"] .pm-moments-list > .pm-moment:hover,
[dir="rtl"] .pm-moments-list > .pm-moment.is-active { border-right-color: var(--pm-accent); }
[dir="rtl"] .pm-moment-card { border-left: 1px solid rgba(77,163,255,.25); border-right: 4px solid var(--pm-accent); }
[dir="rtl"] .pm-moment-card.pos { border-right-color: var(--pm-green); }
[dir="rtl"] .pm-moment-card.neg { border-right-color: var(--pm-red);   }
[dir="rtl"] .pm-takeaways { border-left: 1px solid rgba(46,204,113,.2); border-right: 4px solid var(--pm-green); }
[dir="rtl"] .pm-takeaways-list { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .pm-story-chart-wrap { border-right: 0; border-left: 1px solid var(--pm-border); }
@media (max-width: 820px) {
  [dir="rtl"] .pm-story-chart-wrap { border-left: 0; }
}
[dir="rtl"] .pm-callout { text-align: right; }
[dir="rtl"] .pm-callout-tip,
[dir="rtl"] .pm-callout-warning,
[dir="rtl"] .pm-callout-example,
[dir="rtl"] .pm-callout-success,
[dir="rtl"] .pm-callout-info { border-left: 1px solid var(--pm-border); }
[dir="rtl"] .pm-callout-tip     { border-right: 4px solid var(--pm-accent); }
[dir="rtl"] .pm-callout-warning { border-right: 4px solid var(--pm-amber);  }
[dir="rtl"] .pm-callout-example { border-right: 4px solid var(--pm-purple); }
[dir="rtl"] .pm-callout-success { border-right: 4px solid var(--pm-green);  }
[dir="rtl"] .pm-callout-info    { border-right: 4px solid var(--pm-dim);    }
