/* =========================================================================
   AEI — site stylesheet (Bootstrap 5 theme layer)
   ========================================================================= */
:root {
  --aei-navy: #0d2438;
  --aei-navy-2: #16364f;
  --aei-ink: #1d2b36;
  --aei-muted: #5b6b78;
  --aei-line: #dde4ea;
  --aei-paper: #f5f7f9;
  --aei-accent: #1a73c8;      /* AEI blue */
  --aei-accent-dark: #135ca3;
  --aei-amber: #f2a900;       /* peak / alert */
  --aei-hot: #d9480f;
  --bs-body-font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--aei-ink);
  --bs-link-color: var(--aei-accent-dark);
  --bs-link-hover-color: var(--aei-navy);
  --bs-link-color-rgb: 19, 92, 163;
  --bs-link-hover-color-rgb: 13, 36, 56;
  --nav-h: 72px;
}

body { font-size: 1.0625rem; background: #fff; }
h1, h2, h3, h4, h5 { color: var(--aei-navy); font-weight: 700; letter-spacing: -0.01em; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.skip-link { position: absolute; left: 1rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; }

/* ---------- Top bar & navigation ---------- */
.topbar { background: var(--aei-navy); font-size: .875rem; padding: .35rem 0; }
.topbar a { color: #b9c9d6; text-decoration: none; }
.topbar a:hover { color: #fff; }

/* The nav must sit above every page element (charts, tables, carousels) so the dropdown is never covered. */
.site-nav { background: #fff; border-bottom: 1px solid var(--aei-line); min-height: var(--nav-h); z-index: 1040; }
.navbar-brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, var(--aei-navy) 0%, var(--aei-accent) 100%);
  color: #fff; font-weight: 700; letter-spacing: .04em; font-size: 1.05rem;
}
.brand-text { font-size: .8rem; line-height: 1.1; text-transform: uppercase; letter-spacing: .08em; color: var(--aei-navy); font-weight: 600; }
.site-nav .nav-link { color: var(--aei-ink); font-weight: 600; padding: .5rem .9rem !important; border-radius: 6px; }
.site-nav .nav-link:hover, .site-nav .nav-link:focus { color: var(--aei-accent-dark); background: var(--aei-paper); }
.site-nav .nav-link.active { color: var(--aei-accent-dark); box-shadow: inset 0 -3px 0 var(--aei-accent); border-radius: 6px 6px 0 0; }

/* Mega menu */
.mega-menu { border: 1px solid var(--aei-line); border-radius: 10px; box-shadow: 0 18px 40px rgba(13, 36, 56, .14); padding: 0; overflow: hidden; z-index: 1050; }
.mega-col { padding: 1rem .75rem; }
.mega-maps { background: var(--aei-paper); }
.mega-menu .dropdown-header { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--aei-muted); font-weight: 700; }
.mega-menu .dropdown-item { border-radius: 6px; padding: .4rem .75rem; white-space: normal; font-size: .95rem; }
.mega-menu .dropdown-item.sub { padding-left: 1.6rem; font-size: .875rem; color: var(--aei-muted); }
.mega-menu .dropdown-item:hover, .mega-menu .dropdown-item:focus { background: #e6f0fa; color: var(--aei-navy); }
.mega-menu .dropdown-item.active, .mega-menu .dropdown-item:active { background: var(--aei-accent); color: #fff; }
.mega-menu .bi.small { font-size: .7rem; opacity: .6; }
.mega-overview { display: block; font-weight: 700; padding: .4rem .75rem .75rem; text-decoration: none; color: var(--aei-accent-dark); }
.mega-overview:hover { color: var(--aei-navy); }
.mega-map-grid { display: grid; grid-template-columns: 1fr; }

@media (min-width: 992px) {
  .site-nav .dropdown.mega { position: static; }
  .site-nav .mega-menu { width: min(860px, calc(100vw - 2rem)); left: auto; right: 0; margin-top: .5rem; }
  .site-nav .container { position: relative; }
  .mega-map-grid { grid-template-columns: 1fr 1fr; column-gap: .25rem; }
}
@media (max-width: 991.98px) {
  .navbar-collapse { max-height: calc(100vh - var(--nav-h)); overflow-y: auto; padding-bottom: 1rem; }
  .mega-menu { box-shadow: none; border: 0; }
  .site-nav .nav-link.active { box-shadow: inset 3px 0 0 var(--aei-accent); border-radius: 0 6px 6px 0; }
}

/* ---------- Page hero ---------- */
.page-hero { background: radial-gradient(1200px 400px at 85% -10%, rgba(26,115,200,.35), transparent 60%), var(--aei-navy); color: #dbe6ee; padding: 2.5rem 0 2.75rem; }
.page-hero h1 { color: #fff; font-size: clamp(1.9rem, 3.4vw, 2.75rem); margin-bottom: .75rem; }
.page-hero .lead { max-width: 60rem; font-size: 1.2rem; color: #c7d6e1; margin-bottom: 0; }
.page-hero .breadcrumb { font-size: .85rem; margin-bottom: 1rem; --bs-breadcrumb-divider-color: #7f97a9; }
.page-hero .breadcrumb a { color: #9fc0d4; text-decoration: none; }
.page-hero .breadcrumb .active { color: #e6eef4; }
.hero-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: #8cc4f2; font-weight: 700; margin-bottom: .4rem; }

.section { padding-top: 3rem; padding-bottom: 3rem; } /* never touch side padding: it's also used on .container */
.section-alt { background: var(--aei-paper); }

/* ---------- Content ---------- */
.prose { line-height: 1.65; }
.prose h2 { font-size: 1.6rem; margin-top: 2.25rem; }
.prose h3 { font-size: 1.3rem; margin-top: 2rem; }
.prose h4 { font-size: 1.1rem; margin-top: 1.5rem; }
.prose > :first-child { margin-top: 0; }
.prose ul li, .prose ol li { margin-bottom: .45rem; }
.prose .callout { border-left: 4px solid var(--aei-accent); background: #eef4fb; padding: 1rem 1.25rem; border-radius: 0 8px 8px 0; margin: 1.5rem 0; }
.prose .callout.warn { border-color: var(--aei-amber); background: #fff7e0; }
.footnotes { font-size: .9rem; color: var(--aei-muted); border-top: 1px solid var(--aei-line); padding-top: 1rem; margin-top: 2rem; }
.check-list { list-style: none; padding-left: 0; }
.check-list li { position: relative; padding-left: 1.75rem; }
.check-list li::before { content: "\F26E"; font-family: "bootstrap-icons"; position: absolute; left: 0; top: 0; color: var(--aei-accent); font-weight: 700; }
.pill-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.pill-list li { background: var(--aei-paper); border: 1px solid var(--aei-line); border-radius: 99px; padding: .3rem .85rem; font-size: .92rem; margin: 0; }

.btn-accent { --bs-btn-bg: var(--aei-accent); --bs-btn-border-color: var(--aei-accent); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--aei-accent-dark); --bs-btn-hover-border-color: var(--aei-accent-dark); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--aei-navy); --bs-btn-active-border-color: var(--aei-navy); font-weight: 600; }
.btn-outline-accent { --bs-btn-color: var(--aei-accent-dark); --bs-btn-border-color: var(--aei-accent);
  --bs-btn-hover-bg: var(--aei-accent); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--aei-accent); font-weight: 600; }

.aei-figure { margin: 1.5rem 0; }
.aei-figure img { width: 100%; height: auto; border: 1px solid var(--aei-line); border-radius: 8px; background: #fff; }
.aei-figure figcaption { font-size: .92rem; color: var(--aei-muted); margin-top: .5rem; }

/* Stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 1.75rem 0; }
.stat { border: 1px solid var(--aei-line); border-radius: 10px; padding: 1rem 1.1rem; background: #fff; }
.stat-value { font-family: "IBM Plex Mono", monospace; font-size: 1.6rem; color: var(--aei-navy); }
.stat-label { font-size: .85rem; color: var(--aei-muted); }

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: calc(var(--nav-h) + 1rem); display: grid; gap: 1rem; }
.side-card { border: 1px solid var(--aei-line); border-radius: 10px; padding: 1.1rem; background: #fff; }
.side-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--aei-muted); margin-bottom: .75rem; }
.side-nav, .side-nav ul { list-style: none; padding: 0; margin: 0; }
.side-nav ul { padding-left: .85rem; border-left: 2px solid var(--aei-line); margin: .25rem 0 .5rem .5rem; }
.side-nav a { display: block; padding: .3rem .5rem; border-radius: 6px; text-decoration: none; color: var(--aei-ink); font-size: .95rem; }
.side-nav ul a { font-size: .875rem; color: var(--aei-muted); }
.side-nav a:hover { background: var(--aei-paper); color: var(--aei-accent-dark); }
.side-nav a.active { background: #e6f0fa; color: var(--aei-accent-dark); font-weight: 700; }
.side-nav .bi { font-size: .7rem; }
.side-cta { background: var(--aei-navy); color: #c7d6e1; border: 0; }
.side-cta .side-title { color: #8cc4f2; }
.flyer-card { display: grid; gap: .6rem; text-decoration: none; color: var(--aei-ink); font-weight: 600; font-size: .95rem; }
.flyer-card img { width: 100%; max-width: 220px; height: auto; margin: 0 auto; }
.flyer-card:hover { color: var(--aei-accent-dark); }
@media (max-width: 991.98px) { .sidebar { position: static; } }

/* ---------- Cards / listings ---------- */
.aei-card { border: 1px solid var(--aei-line); border-radius: 12px; background: #fff; height: 100%; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s; }
.aei-card:hover { box-shadow: 0 12px 28px rgba(13,36,56,.10); transform: translateY(-2px); }
.aei-card .card-img { aspect-ratio: 16 / 10; object-fit: cover; object-position: top; width: 100%; border-bottom: 1px solid var(--aei-line); background: var(--aei-paper); }
.aei-card .card-img.contain { object-fit: contain; padding: 1rem; }
.aei-card .body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.aei-card h3 { font-size: 1.15rem; }
.aei-card p { color: var(--aei-muted); font-size: .97rem; }
.aei-card .more { margin-top: auto; font-weight: 600; text-decoration: none; }

.product-row { display: grid; grid-template-columns: 200px 1fr; gap: 1.75rem; padding: 2rem 0; border-bottom: 1px solid var(--aei-line); }
.product-row:last-of-type { border-bottom: 0; }
.product-row img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--aei-line); }
.product-row h2 { font-size: 1.45rem; margin-top: 0; }
.product-row h2 a { text-decoration: none; color: inherit; }
.product-row h2 a:hover { color: var(--aei-accent-dark); }
@media (max-width: 575.98px) { .product-row { grid-template-columns: 1fr; } .product-row img { max-width: 200px; } }

.map-tile { position: relative; display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--aei-line); text-decoration: none; background: var(--aei-navy); }
.map-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; transition: transform .3s, opacity .3s; }
.map-tile span { position: absolute; left: 0; right: 0; bottom: 0; padding: .6rem .8rem; color: #fff; font-weight: 600; font-size: .95rem;
  background: linear-gradient(transparent, rgba(13,36,56,.92)); }
.map-tile:hover img { transform: scale(1.04); opacity: .85; }
.map-preview { position: relative; display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--aei-line); margin-top: 1.5rem; }
.map-preview img { width: 100%; display: block; }
.map-preview-cta { position: absolute; right: 1rem; bottom: 1rem; background: rgba(13,36,56,.88); color: #fff; padding: .5rem .9rem; border-radius: 8px; font-weight: 600; }

/* ---------- Home ---------- */
.home-hero { background: var(--aei-navy); color: #dbe6ee; position: relative; overflow: hidden; }
.home-hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(900px 500px at 90% 10%, rgba(26,115,200,.45), transparent 60%), radial-gradient(700px 400px at 0% 100%, rgba(242,169,0,.15), transparent 60%); }
.home-hero .container { position: relative; padding: 4rem .75rem; }
.home-hero h1 { color: #fff; font-size: clamp(2.1rem, 4.4vw, 3.4rem); line-height: 1.08; }
.home-hero .lead { color: #c7d6e1; font-size: 1.25rem; }
.load-ribbon { height: 10px; border-radius: 99px; margin: 1.75rem 0 1.25rem; max-width: 520px; }
.hero-carousel { border-radius: 14px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,.35); background: #0a1c2c; }
.hero-carousel .carousel-item img { width: 100%; xxxaspect-ratio: 16 / 10; object-fit: cover; object-position: top left; }
.hero-carousel .slide-panel { aspect-ratio: 16 / 10; display: flex; flex-direction: column; justify-content: flex-end; padding: 2rem; color: #fff; }
.hero-carousel .slide-panel h3 { color: #fff; font-size: 1.6rem; }
.hero-carousel .carousel-caption { left: 0; right: 0; bottom: 0; padding: 1rem 1.25rem; text-align: left; background: linear-gradient(transparent, rgba(10,28,44,.95)); }
.process-steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.process-steps li { list-style: none; border-top: 3px solid var(--aei-accent); padding-top: .9rem; }
.process-steps li::before { counter-increment: step; content: "0" counter(step); font-family: "IBM Plex Mono", monospace; color: var(--aei-accent-dark); display: block; font-size: .85rem; font-size: 3rem; margin-bottom: .25rem; }

/* ---------- News & case studies ---------- */
.article { padding: 2.25rem 0; border-bottom: 1px solid var(--aei-line); }
.article:first-child { padding-top: 0; }
.article h2 { font-size: 1.6rem; }
.article-meta { color: var(--aei-muted); font-size: .9rem; margin-bottom: 1rem; }
.article-meta .rel { color: var(--aei-accent-dark); }
.article img { max-width: 100%; height: auto; border-radius: 8px; }
.article .float-img { float: right; max-width: 260px; margin: 0 0 1rem 1.5rem; }
@media (max-width: 575.98px) { .article .float-img { float: none; display: block; margin: 0 0 1rem; } }
.toc { font-size: .93rem; }
.toc a { display: block; padding: .35rem 0; text-decoration: none; border-bottom: 1px dashed var(--aei-line); }
.ranked { counter-reset: r; padding-left: 0; }
.ranked li { list-style: none; display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; align-items: center; padding: .3rem .5rem; border-radius: 6px; margin-bottom: .25rem; }
.ranked li::before { counter-increment: r; content: counter(r); font-family: "IBM Plex Mono", monospace; color: var(--aei-muted); }
.ranked .val { font-family: "IBM Plex Mono", monospace; font-size: .9rem; }

/* ---------- ISO alerts ---------- */
.season-banner { border-radius: 10px; padding: 1rem 1.25rem; display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.season-banner .bi { font-size: 1.6rem; }
.iso-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
/* No z-index or transforms here — chart cards must never stack above the nav dropdown. */
.iso-card { border: 1px solid var(--aei-line); border-radius: 12px; overflow: hidden; background: #fff; }
.iso-card header { display: flex; justify-content: space-between; align-items: baseline; padding: .75rem 1rem; border-bottom: 1px solid var(--aei-line); }
.iso-card header h3 { font-size: 1.05rem; margin: 0; }
.iso-card header small { color: var(--aei-muted); }
.iso-card img { width: 100%; height: auto; display: block; background: var(--aei-paper); min-height: 120px; }
.iso-card .chart-fallback { padding: 2.5rem 1rem; text-align: center; color: var(--aei-muted); font-size: .9rem; }
.iso-card footer { padding: .5rem 1rem; font-size: .8rem; color: var(--aei-muted); border-top: 1px solid var(--aei-line); }

/* Fit peak tables to the card instead of scrolling */
.iso-card .table-responsive {
  overflow-x: visible;          /* or remove the .table-responsive wrapper */
}

.iso-card .table {
  table-layout: fixed;          /* columns follow the widths below, not the content */
  width: 100%;
  margin-bottom: 0;
  font-size: .875rem;
}

.iso-card .table th,
.iso-card .table td {
  padding: .4rem .35rem;        /* Bootstrap default is .5rem; this saves ~10px per row */
  white-space: normal;          /* undo any nowrap */
  overflow-wrap: anywhere;      /* lets "Date/Time & Weather (BOS)" break */
  vertical-align: middle;
}

/* Column widths: Year | Peak, MW | Date/Time & Weather */
.iso-card .table th:nth-child(1),
.iso-card .table td:nth-child(1) { width: 22%; }
.iso-card .table th:nth-child(2),
.iso-card .table td:nth-child(2) { width: 22%; text-align: right; white-space: nowrap; }
.iso-card .table th:nth-child(3),
.iso-card .table td:nth-child(3) { width: 56%; }

/* Keep the year badge from setting a minimum width */
.iso-card .table td:nth-child(1) .badge {
  padding: .35em .5em;
}


.risk-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: .75rem 0 .25rem; }
.risk-scale div { border-radius: 6px; padding: .55rem .25rem; text-align: center; color: #fff; font-weight: 700; font-size: .85rem; }
.risk-labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--aei-muted); }

/* Real-time widget */
.rt-widget { background: var(--aei-navy); color: #dbe6ee; border-radius: 12px; padding: 1.25rem; }
.rt-widget h3 { color: #fff; font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; }
.rt-site { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: .75rem 0; border-bottom: 1px solid rgba(255,255,255,.12); align-items: center; line-height: 1.3em; }
.rt-site:last-of-type { border-bottom: 0; }
.rt-kw { font-family: "IBM Plex Mono", monospace; font-size: 1.6rem; color: #fff; }
.rt-bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 5px; }
.rt-bar span { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .6s, background-color .6s; }
.rt-scale { height: 8px; border-radius: 99px; margin-top: 1rem; }
.rt-meta { font-size: .8rem; color: #8fa8ba; margin-top: .5rem; }
/* Odometer digits for the kW readings (js/realtime-widget.js) */
.odo { display: inline-flex; line-height: 1; vertical-align: -.1em; }
.odo-char { display: inline-block; height: 1em; line-height: 1em; overflow: hidden; }
.odo-strip { display: block; transition: transform 1.4s cubic-bezier(.2, .8, .2, 1); }
.odo-strip span { display: block; height: 1em; }
@media (prefers-reduced-motion: reduce) { .odo-strip { transition: none; } }

/* Forms */
.form-section { border: 1px solid var(--aei-line); border-radius: 12px; padding: 1.5rem; background: #fff; }
.form-text { color: var(--aei-muted); }
.terms-box { max-height: 220px; overflow-y: auto; font-size: .88rem; background: var(--aei-paper); border-radius: 8px; padding: 1rem; border: 1px solid var(--aei-line); }

/* Lightbox */
#lightbox .modal-content { background: #0a1c2c; border: 0; }
#lightbox img { width: 100%; height: auto; }
#lightbox .modal-footer { color: #c7d6e1; border: 0; justify-content: flex-start; font-size: .92rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--aei-navy); color: #9fb4c4; padding: 3rem 0 1.5rem; margin-top: 4rem; font-size: .95rem; }
.site-footer h6 { color: #fff; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; margin-bottom: .9rem; }
.site-footer a { color: #c7d6e1; text-decoration: none; }
.site-footer a:hover { color: #8cc4f2; }
.site-footer li { margin-bottom: .35rem; }
.footer-brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.footer-brand .brand-mark { width: 38px; height: 38px; font-size: .85rem; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 2rem; padding-top: 1.25rem; display: flex; justify-content: space-between; font-size: .875rem; }
main + .site-footer { margin-top: 0; }
main { padding-bottom: 4rem; }

/* Large gutters overflow the container on phones; tighten them below md. */
@media (max-width: 767.98px) {
    .row.g-5 { --bs-gutter-x: 1.5rem; }
    .rt-site {
        display: inline-block;
    }
    .rt-kw {
        font-size: 1rem;
    }
    .rt-kw small {
        font-size: 0.8rem;
        vertical-align: bottom;
    }

}

/* ---------------------------- CP Overrides -------------- */
a.cp-position {
    position: absolute;
    left: 20px;
    bottom: 20px;
    font-size: 1.2em;
}

button.carousel-control-prev, button.carousel-control-next {
    bottom: 70px;
}

a.btn.btn-accent {
    border-radius: 8px;
}

a {
    font-weight: calc(var(--bs-body-font-weight) * 1.5);
}

div.side-card a.flyer-card img,
img.img-fluid,
article.article.prose img {
    border-radius: 0;
    filter: drop-shadow(5px -5px 0.75rem #aaa);
}
