/* The article list and article pages. Phone first: one column, a comfortable 18px reading size, and
   anything wide (tables, code) scrolls sideways inside itself rather than widening the page. */

.articles-head { max-width: 42rem; margin: 0 auto; }
.articles-head .subtitle { margin-bottom: 1.5rem; }
.article-list { list-style: none; padding: 0; margin: 0 auto; max-width: 42rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.article-card { display: block; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--text); }
.article-card:hover { text-decoration: none; }
.article-card:hover h2 { color: var(--accent); }
.article-card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--fill); }
.article-card .text { padding: 1.1rem 1.25rem 1.25rem; }
.article-card h2 { margin: 0 0 .35rem; font-size: 1.2rem; line-height: 1.25; }
.article-card p { margin: 0 0 .6rem; color: var(--text-muted); font-size: .97rem; }
.article-meta { color: var(--text-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.article-meta .sep { margin: 0 .35em; opacity: .6; }
.feed-link { display: block; max-width: 42rem; margin: 1.5rem auto 0; font-size: .88rem; color: var(--text-muted); }

/* An article: a readable measure, centred. */
.article { max-width: 42rem; margin: 0 auto; }
.article-back { display: inline-block; font-size: .94rem; margin-bottom: 1rem; }
.article h1 { margin-bottom: .6rem; }
.article .lede { font-size: 1.15rem; line-height: 1.45; color: var(--text-muted); margin: 0 0 .9rem; }
.article-hero { margin: 1.5rem 0 0; }
.article-hero img { display: block; width: 100%; height: auto; border-radius: var(--radius); }
.article-hero figcaption { color: var(--text-muted); font-size: .88rem; margin-top: .5rem; }

.article-contents { background: var(--panel); border-radius: var(--radius-small); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin: 1.75rem 0 0; font-size: .95rem; }
.article-contents h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 .5rem; }
.article-contents ol { margin: 0; padding-left: 1.25rem; }
.article-contents ol ol { margin-top: .2rem; }
.article-contents li { margin: .25rem 0; }

.article-body { font-size: 18px; line-height: 1.65; margin-top: 2rem; overflow-wrap: break-word; }
.article-body > :first-child { margin-top: 0; }
.article-body p, .article-body ul, .article-body ol, .article-body dl { margin: 0 0 1.15rem; }
.article-body li { margin: .3rem 0; }
.article-body h2 { font-size: 1.5rem; line-height: 1.2; margin: 2.5rem 0 .8rem; }
.article-body h3 { font-size: 1.2rem; line-height: 1.3; margin: 2rem 0 .6rem; }
.article-body h4 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.article-body h2, .article-body h3 { scroll-margin-top: var(--header-clearance); }
.article-body a { text-decoration: underline; text-underline-offset: 2px; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-small); }
.article-body figure { margin: 1.75rem 0; }
.article-body figure img { display: block; width: 100%; }
.article-body figcaption { color: var(--text-muted); font-size: .88rem; line-height: 1.45; margin-top: .5rem; }
.article-body blockquote { margin: 1.5rem 0; padding: .1rem 0 .1rem 1.1rem; border-left: 3px solid var(--accent); color: #3b4450; }
.article-body hr { border: 0; border-top: 1px solid var(--hairline); margin: 2.5rem 0; }
.article-body strong { font-weight: 650; }

/* Wide tables scroll sideways in their own box. */
.article-body .table-scroll { overflow-x: auto; margin: 1.5rem 0; background: var(--panel); border-radius: var(--radius-small); box-shadow: var(--shadow); }
.article-body table { font-size: .9rem; min-width: 100%; width: auto; }
.article-body th, .article-body td { padding: .6rem .75rem; white-space: nowrap; }
.article-body td { white-space: normal; min-width: 6rem; }
.article-body th.num, .article-body td.num { text-align: right; font-variant-numeric: tabular-nums; }
.article-body caption { caption-side: bottom; text-align: left; color: var(--text-muted); font-size: .85rem; padding: .6rem .75rem; }

/* Code: inline, and blocks that scroll sideways rather than wrap. */
.article-body code { font-size: .85em; }
.article-body pre { margin: 1.5rem 0; padding: 1rem 1.1rem; border-radius: var(--radius-small); background: #f1f3f6; overflow-x: auto; font-size: .85rem; line-height: 1.5; -webkit-overflow-scrolling: touch; }
.article-body pre code { background: none; padding: 0; font-size: inherit; }
.article-body .highlight { background: none; }
.article-body .highlight pre { background: #f1f3f6; }

/* Tip and warning boxes */
.article-body .admonition { border-radius: var(--radius-small); padding: .9rem 1.1rem; margin: 1.5rem 0; background: var(--accent-soft); color: #15405f; font-size: .97rem; }
.article-body .admonition > :last-child { margin-bottom: 0; }
.article-body .admonition-title { font-weight: 700; margin: 0 0 .35rem; }
.article-body .admonition.warning { background: var(--warn-soft); color: #6b3d0f; }
.article-body .admonition p:last-child { margin-bottom: 0; }

/* Interactive charts (blocks.InteractiveBlock): a white card the reader changes with sliders. Until the
   script runs - or without it - the block's picture shows instead. */
.article-body .interactive-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem 1.25rem; }
.hx { font-size: .95rem; line-height: 1.4; }
.hx-controls { display: grid; gap: .9rem; }
.hx-row { display: grid; gap: .3rem; }
.hx-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.hx-label { font-weight: 650; }
.hx-value { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.hx-select { font: inherit; padding: .45rem .6rem; border-radius: var(--radius-small); border: 0; background: var(--fill); color: var(--text); }
.hx input[type="range"] { width: 100%; accent-color: var(--accent); margin: .15rem 0; height: 1.6rem; }
.hx input[type="range"]:disabled { opacity: .35; }
.hx-toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--text-muted); cursor: pointer; }
.hx-toggle input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; margin: 0; }
.hx-seg { display: inline-flex; background: var(--track); border-radius: 999px; padding: 3px; margin: 1.1rem 0 .2rem; }
.hx-seg button { font: inherit; font-size: .88rem; border: 0; background: none; color: var(--text); padding: .35rem .9rem; border-radius: 999px; cursor: pointer; }
.hx-seg button[aria-pressed="true"] { background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 650; }
.hx-summary { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; line-height: 1.3; margin: .8rem 0 0; min-height: 1.5em; }
.article-body .hx-h { font-size: 1rem; margin: 1.3rem 0 .15rem; }
.hx-note { color: var(--text-muted); font-size: .85rem; margin: 0 0 .6rem !important; }
.hx-bars { display: grid; gap: .55rem; }
.hx-bar { display: grid; grid-template-columns: 6.6rem minmax(0, 1fr) 4.6rem; align-items: center; column-gap: .6rem; }
.hx-bar-name { font-size: .9rem; }
.hx-bar-track { height: 1.05rem; background: var(--fill); border-radius: 4px; overflow: hidden; }
.hx-bar-fill { height: 100%; border-radius: 4px; transition: width .15s ease, margin-left .15s ease; }
.hx-bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: .92rem; }
.hx-bar-detail { grid-column: 2 / 4; color: var(--text-muted); font-size: .8rem; line-height: 1.35; margin-top: .1rem; }
.hx-neg .hx-bar-fill { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .45) 0 3px, transparent 3px 7px); }
.hx-total .hx-bar-name { font-weight: 650; }
.hx-waterfall .hx-bar-track { background: none; }
/* One colour for each change, kept the same in the static charts (Okabe-Ito, colour-blind safe, with the site's blue). */
.hx-c-switch { background: #1f6aa5; }
.hx-c-car { background: #009e73; }
.hx-c-heating { background: #d55e00; }
.hx-c-solar { background: #e69f00; }
.hx-c-battery { background: #56b4e9; }
.hx-c-now, .hx-c-after { background: #8a929e; }
.hx-stack { display: flex; }
.hx-stack .hx-bar-fill { border-radius: 0; flex: none; }
.hx-stack .hx-bar-fill:first-child { border-radius: 4px 0 0 4px; }
.hx-stack .hx-bar-fill:last-child { border-radius: 0 4px 4px 0; }
.hx-c-together { background: #8a929e; }
.hx-c-extra { background: #1c2129; }
.hx-c-overlap { background: none; box-shadow: inset 0 0 0 1.5px #8a929e; }
.hx-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin: .1rem 0 .7rem; }
.hx-pill { font: inherit; font-size: .86rem; border: 0; border-radius: 999px; padding: .4rem .8rem; background: var(--fill); color: var(--text); cursor: pointer; }
.hx-pill[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 650; }
.hx-pill:disabled { opacity: .4; cursor: default; }
.hx-map { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: .9rem; align-items: center; margin-top: .9rem; }
.hx-map svg { width: 100%; height: auto; display: block; }
.hx-map path { stroke: var(--panel); stroke-width: 1.2; stroke-linejoin: round; cursor: pointer; transition: fill .15s ease; }
.hx-map path:hover, .hx-map path:focus-visible { stroke: var(--text); stroke-width: 1.6; outline: none; }
.hx-map path.hx-map-on { stroke: var(--text); stroke-width: 2.4; }
.hx-map path.hx-map-none { fill: #dcdad4; cursor: default; }
.hx-map-box { fill: none; stroke: var(--hairline); stroke-width: 1.5; }
.hx-map-label { font-size: 22px; fill: var(--text-muted); text-anchor: middle; }
.hx-map-key { color: var(--text-muted); font-size: .85rem; margin: 0 !important; }
@media (prefers-reduced-motion: reduce) { .hx-bar-fill, .hx-map path { transition: none; } }

.article-foot { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--hairline); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .94rem; }

@media (max-width: 640px) {
  .article-body { font-size: 17px; line-height: 1.6; }
  .article-body h2 { font-size: 1.3rem; }
  .article .lede { font-size: 1.06rem; }
  /* Full-bleed pictures and code on a phone - every pixel of width counts. */
  .article-hero, .article-body figure, .article-body pre, .article-body .highlight pre, .article-body .table-scroll { margin-left: -1rem; margin-right: -1rem; border-radius: 0; }
  .article-hero img, .article-body figure img { border-radius: 0; }
  .article-body figcaption, .article-hero figcaption { padding: 0 1rem; }
  .article-card .text { padding: 1rem 1.1rem 1.1rem; }
  .article-body .interactive-card { border-radius: 0; padding: 1rem; }
  .hx-bar { grid-template-columns: 5.8rem minmax(0, 1fr) 4.2rem; column-gap: .45rem; }
}
