/* ============================================================
   LEC ENERsim — Use Case article pages (e.g. pages/resilience-demo.html)
   Restyles the print-oriented article export onto the landing-page
   design tokens (see css/styles.css :root). Loaded after styles.css.
   ============================================================ */

/* Wider than the site's default 1200px container — the embedded Plotly
   charts need ~1000px to keep their right-hand node labels from clipping. */
.article-page .container { max-width: 1440px; }
/* Nav clearance now lives on .article-hero itself (so its dark band starts
   flush under the nav, full-bleed, with no light gap above it). */
.article-page { padding-top: 0; }

.article-flex {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-gap);
}

#article-content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1000px;
  font-size: 0.94rem;
  line-height: 1.56;
}

/* ---------- Article hero (dark band: back-link, h1, subtitle, banner, intro box) ----------
   A plain full-width section (not part of the flex row below) — simplest way
   to get an edge-to-edge dark band without fighting the asymmetric TOC layout.
   The floating TOC covers it visually via position:fixed (see #toc-column). */
/* padding-top matches main.js's ANCHOR_OFFSET (90px) exactly, so the page's
   resting scroll position (top) lines up pixel-for-pixel with where the
   TOC's "Article Top" link scrolls you to. */
/* Banner uses the same pale "Why ENERsim" surface as the main-page pillars
   section (--soft, dark text) rather than a dark fill — lighter, friendlier. */
.article-hero { background: var(--soft); color: var(--tx-dark); padding: 90px 0 40px; }
.article-hero .container { max-width: 1440px; }
.article-hero__inner { max-width: 1000px; }
.article-hero hr { display: none; }
.article-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: clamp(1.7rem, 3.6vw, 2.35rem);
  line-height: 1.14;
  color: var(--tx-dark);
  border-bottom: 3px solid var(--brand);
  padding-bottom: 0.4rem;
  margin: 0 0 0.35rem;
}
.article-hero h1 + p:has(em:only-child) {
  margin: 0 0 1.2rem;
}
.article-hero h1 + p em:only-child {
  display: block;
  font-size: 1rem;
  font-style: italic;
  color: var(--tx-dark-dim);
}
.article-hero ul { list-style: disc; padding-left: 1.3rem; margin: 0.35rem 0 0.8rem; }
.article-hero ol { list-style: decimal; padding-left: 1.3rem; margin: 0.35rem 0 0.8rem; }
.article-hero li { margin-bottom: 0.25rem; }

/* ---------- Article typography ---------- */
/* Tighter type scale + vertical rhythm than the source export: a dense,
   chart/table-heavy technical article reads better compact than editorial-loose. */
#article-content h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--brand);
  border-left: 4px solid var(--brand);
  padding-left: 0.6rem;
  line-height: 1.3;
  margin: 1.8rem 0 0.55rem;
}
#article-content h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.03rem;
  color: var(--tx-dark);
  margin: 1.3rem 0 0.4rem;
}
#article-content p { margin: 0 0 0.7rem; color: var(--tx-dark); }
#article-content ul { list-style: disc; padding-left: 1.3rem; margin: 0.35rem 0 0.8rem; }
#article-content ol { list-style: decimal; padding-left: 1.3rem; margin: 0.35rem 0 0.8rem; }
#article-content ul ul, #article-content ol ul { list-style: circle; }
#article-content li { margin-bottom: 0.25rem; }
#article-content strong { font-weight: 700; color: var(--tx-dark); }
#article-content a:not(.toc-link) { color: var(--brand); text-decoration: underline; }
#article-content code {
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: var(--light-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--brand-deep);
}
#article-content hr { border: none; border-top: 1px solid var(--line); margin: 1.6rem 0; }
#article-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* Figure captions, tagged by generate_article_html.py as <em class="fig-caption"> */
#article-content em.fig-caption {
  display: block;
  font-size: 0.8rem;
  color: var(--tx-dark-dim);
  font-style: italic;
  text-align: left;
  margin: 0.15rem 0 1.1rem;
}

/* Callout / info boxes carry inline styles from the source export — override
   the spacing (border/bg colors already recolored at copy-time). */
#article-content div[style*="padding: 10px 20px"],
.article-hero div[style*="padding: 10px 20px"] { margin: 14px 0 !important; }
#article-content div[style*="position: relative; margin: 24px"] { margin: 16px 0 20px 0 !important; }

/* Replace the pastel print-style tints with a clean white card + shadow
   (matching .card elsewhere on the site) — keep only the colored left
   border as an accent, on white so it reads as "site UI" not "highlighter". */
#article-content div[style*="background: #E7F0F3"],
#article-content div[style*="background: #E9F5F0"],
#article-content div[style*="background: #F7F1E6"],
.article-hero div[style*="background: #E7F0F3"],
.article-hero div[style*="background: #E9F5F0"],
.article-hero div[style*="background: #F7F1E6"] {
  background: #fff !important;
  border-top: 1px solid var(--line) !important;
  border-right: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: var(--shadow);
}
.article-hero div[style*="background: #E7F0F3"],
.article-hero div[style*="background: #E9F5F0"],
.article-hero div[style*="background: #F7F1E6"] {
  color: var(--tx-dark);
}

/* ---------- Tables ---------- */
#article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0 1.1rem;
  font-size: 0.88rem;
}
#article-content thead tr { background: var(--brand); color: #fff; }
#article-content th { padding: 7px 12px; text-align: left; font-weight: 600; }
#article-content td { padding: 6px 12px; border-bottom: 1px solid var(--line); }
#article-content tbody tr:nth-child(even) { background: var(--brand-soft); }
/* Narrow screens: let wide data tables scroll horizontally on their own instead
   of forcing the whole page to overflow (cell text — especially in German — can
   exceed the mobile viewport). */
@media (max-width: 760px) {
  #article-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- Interactive Plotly charts ---------- */
#article-content .plotly-chart { width: 100%; margin: 0.9rem 0 0.2rem; overflow-x: auto; }
#article-content .img-placeholder {
  width: 100%; padding: 40px 0; text-align: center;
  background: var(--light-2); border: 2px dashed var(--line);
  color: var(--tx-dark-dim); font-size: 0.9rem; font-style: italic;
  border-radius: var(--radius-sm); margin: 1rem 0 0.4rem;
}

/* ---------- Table of contents + CTA (floating column beside the article) ----------
   position:fixed (not sticky) so it stays visible over the dark hero band too —
   sticky's containing block would only span the light body section below the
   hero. The right offset replicates where a flex sibling would sit alongside
   the 1000px-max article column inside the page's 1440px-max container.
   Hidden once the shared footer/CTA scrolls into view (see toc_js) so it
   doesn't float over that section's own content. */
#toc-column {
  position: fixed;
  top: 96px;
  right: calc(50vw - 720px + var(--pad));
  width: 270px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  opacity: 1;
  transition: opacity 0.2s;
}
#toc-column.toc-hidden { opacity: 0; pointer-events: none; }
#toc-sidebar {
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 18px 16px 14px;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.toc-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--brand);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 0; padding: 0; }
.toc-link {
  display: block;
  color: var(--tx-dark-dim);
  text-decoration: none;
  padding: 5px 7px;
  border-radius: 6px;
  line-height: 1.4;
  transition: color 0.15s, background 0.15s;
  font-size: 0.86rem;
  margin-bottom: 2px;
}
.toc-link.toc-link-top {
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.toc-link:hover { color: var(--brand); background: var(--brand-soft); }
.toc-link.toc-active {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
  padding-left: 9px;
}
#toc-cta {
  flex-shrink: 0;
  background: var(--brand-soft);
  border: 1px solid #BBD8E1;
  border-left: 5px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 18px;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--tx-dark);
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.toc-cta-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--brand-deep);
  margin-bottom: 8px;
  line-height: 1.3;
}
#toc-cta strong { color: var(--brand-deep); font-weight: 700; }
.toc-cta-actions {
  margin-top: 12px;
}
.toc-cta-actions .btn {
  padding: 9px 16px;
  font-size: 0.82rem;
}

@media (max-width: 1440px) {
  #toc-column { display: none; }
}
