/* ==========================================================================
   parkscomputing.com site theme and site-specific styles, loaded after
   pudl.css (and pudl-windows.css where the page uses windows). This file
   replaces the Bootstrap-era site.css. It sets the palette tokens PUDL
   invites a theme to set, and it styles the things PUDL has no component
   for: article prose, the nav menus, the image lightbox, the comment
   thread, and the desktop shell.
   ========================================================================== */

/* === Theme ================================================================
   The accent carries the site's long-standing link blue. Everything else
   stays PUDL's neutral graphite. */
:root {
  --accent: #0d47a1;
  --accent-hover: #08306e;
}

[data-theme="dark"] {
  --accent: #4da3ff;
  --accent-hover: #7bd3ff;
  --on-accent: #0d1117;
}

/* Topbar link hover comes from PUDL's own --tb-link-hover since 0.11.0. */


/* === Page shell =========================================================== */
/* Classic pages fill the viewport with the main area elastic, so the
   footer hugs the bottom even when the content is short. */
body:not(.desktop) {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body:not(.desktop) .site-main { flex: 1; width: 100%; }

.site-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header { position: sticky; top: 0; z-index: 90; }
body.desktop .site-header { position: static; flex: none; }
.brand img { display: block; width: 24px; height: 24px; }

/* === Primary nav: a section-tab strip below the topbar ====================
   The classic nav shares PUDL's .app-section-bar band since 0.16.0. The
   content below it sits on the page background, so the current tab opens
   into that. */
.site-nav { --section-current-bg: var(--bg); }

/* === The view switcher ====================================================
   One segmented control, centered in the topbar, switching between the
   window and classic views. Its options are links (each view is a URL),
   which PUDL's seg styles cover natively since 0.16.0 (aria-current);
   only the centering is the site's. */
.topbar { position: relative; }
.view-seg {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
@media (max-width: 560px) {
  .view-seg { position: static; transform: none; margin-left: auto; margin-right: 8px; }
}

/* The classic nav is the same category tab strip as the window view;
   the old details-based dropdowns are gone. */

/* === Footer =============================================================== */
.site-footer {
  margin-top: 48px;
  padding: 18px 20px;
  background: var(--tb-grad);
  border-top: 1px solid var(--tb-border);
  color: var(--tb-fg);
  font-size: 13px;
}
.site-footer a { color: var(--tb-fg); }

/* === Article prose ======================================================== */
.post-content {
  max-width: 860px;
  margin: 0 auto 3rem;
  padding-top: 1rem;
}
.post-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 2.6vw, 2.5rem);
  font-weight: 700; line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 .6rem;
}
.post-meta { font-size: .85rem; color: var(--text-muted); }
.post-body { font-size: 1.04rem; line-height: 1.65; }
.post-body p { margin-bottom: 1.1rem; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  scroll-margin-top: 6.5rem;
}
.post-body h2 { margin-top: 2.4rem; font-size: 1.6rem; }
.post-body h3 { margin-top: 1.9rem; font-size: 1.3rem; }
.post-body h4 { margin-top: 1.6rem; font-size: 1.1rem; }
.post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  font-size: .85rem;
  overflow: auto;
  box-shadow: var(--entry-shadow);
}
.post-body pre code { display: block; padding: 12px 14px; font-family: var(--mono); }
.post-body code:not(pre code) {
  font-family: var(--mono);
  background: var(--surface-alt);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .85em;
}
.post-body blockquote {
  margin: 1.4rem 0;
  padding: .75rem 1rem .75rem 1.1rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.post-body img, .post-body figure { max-width: 100%; height: auto; }
.post-body figure { margin: 1.5rem 0; }
.post-body figcaption {
  text-align: center; margin-top: .4rem;
  font-size: smaller; font-style: italic;
  color: var(--text-muted);
}
.post-body table:not(.kv-table) {
  border-collapse: collapse; font-size: .95rem;
}
.post-body table:not(.kv-table) th,
.post-body table:not(.kv-table) td {
  border: 1px solid var(--border); padding: 6px 10px;
}
.posted-on { font-style: italic; font-size: smaller; color: var(--text-muted); }

/* Article images invite the lightbox. */
.content-body img:not([data-no-lightbox]), .win-body img:not([data-no-lightbox]) { cursor: pointer; }

/* === Post listing ========================================================= */
.post-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin: 1rem 0 2rem;
  padding: 0;
}
.post-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow-card);
}
.post-card-title {
  font-size: 1.1rem; font-weight: 600; line-height: 1.3;
}
.post-card-meta { font-size: .75rem; color: var(--text-muted); margin: .35rem 0; }
.post-card-excerpt { font-size: .9rem; line-height: 1.4; flex-grow: 1; margin-bottom: .75rem; }
.post-card-more { font-size: .78rem; font-weight: 600; }

/* === Audio / video accordions (native details) ============================ */
.media-accordion {
  margin: .75rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.media-accordion > summary {
  padding: 8px 12px;
  font-size: .9rem; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.media-accordion > .media-accordion-body { padding: 4px 12px 12px; }

/* === Comments ============================================================= */
.page-comments h2 {
  font-family: var(--font-display);
  border-top: 1px solid var(--border);
  padding-top: 1.5rem; margin-top: 2.5rem;
}
.page-comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 18px;
  margin: 0 0 14px;
}
.page-comment-title { margin: 0 0 4px; font-size: 1.05rem; }
.page-comment-author { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }
.page-post-comment { max-width: 560px; margin-top: 2rem; }

/* === Image lightbox =======================================================
   A native dialog, styled with PUDL's dialog vocabulary. The shell is
   server-rendered in the layout; lightbox.js swaps the image in and out.
   The image itself is flat content; the controls are raised. */
.lightbox {
  padding: 0; margin: auto;
  max-width: min(94vw, 1400px); max-height: 94vh;
  background: transparent; border: 0;
  overflow: visible;
}
.lightbox::backdrop { background: rgb(0 0 0 / 0.62); }
.lightbox-frame {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
}
.lightbox-img {
  max-width: min(94vw, 1400px); max-height: 84vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.5);
}
.lightbox-caption {
  color: #fff; font-size: .9rem; text-align: center;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.8);
  max-width: 80ch;
}
.lightbox-counter {
  color: #fff; font-size: .8rem; opacity: .85;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.8);
}
.lightbox-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--raise-border);
  background: var(--raise-grad);
  box-shadow: var(--raise-shadow);
  color: var(--text);
  font: 600 16px/1 var(--font);
  cursor: pointer;
}
.lightbox-btn:hover { background: var(--raise-grad-hover); border-color: var(--raise-border-hover); }
.lightbox-btn:focus-visible { outline: none; box-shadow: var(--raise-shadow), 0 0 0 3px var(--focus-ring); }
.lightbox-close { position: absolute; top: -14px; right: -14px; }
.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
}
.lightbox-prev { left: -14px; }
.lightbox-next { right: -14px; }
.lightbox-prev[hidden], .lightbox-next[hidden] { display: none; }

/* === Desktop mode =========================================================
   The desktop is PUDL's master-detail layout with the windows as the
   detail pane, after PUDL's samples/article-reader.html. pudl.css sizes
   the layout itself (body:has(> .md-layout) fills the viewport); what
   follows is only this site's stage styling. */
body.desktop .md-toolbar .md-section-label { padding: 0; }

/* The dock is the toolbar's only elastic element: it grows, shrinks and
   wraps its tabs internally, so the filter on its left holds its place
   however many windows are open. */
body.desktop .md-toolbar { flex-wrap: nowrap; }
body.desktop .md-toolbar .win-dock { flex: 1 1 auto; min-width: 0; }
@container md (max-width: 640px) {
  body.desktop .md-toolbar { flex-wrap: wrap; }
}

/* The settings dialog's fine print. */
.settings-note { font-size: 12px; color: var(--text-muted); margin: 14px 0 0; }

/* The go palette is PUDL's key-summoned menu panel since 0.17.0; its
   look and placement come from pudl.css and pudl-menu.js. */
/* The default width rides the PUDL variable so a dragged width (pudl-md.js
   sets it inline on the layout) wins over it. */
body.desktop .md-layout { --md-sidebar-w: 300px; }
/* The filter's apply button is PUDL's .md-filter-group since 0.11.0. */
.reader-stage { padding: 0; overflow: hidden; }
.reader-col { display: flex; flex-direction: column; height: 100%; }
.reader-col .md-back { margin: 12px 16px 4px; align-self: flex-start; }
.reader-col .win-host { flex: 1; min-height: 0; position: relative; }
.reader-empty {
  height: 100%; overflow-y: auto; padding: 32px;
}
.reader-empty .card { max-width: 560px; margin: 10vh auto 0; }
.welcome-card h1 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.welcome-card p { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); }
.welcome-card p:last-child { margin-bottom: 0; }

/* The category and tag filter menus' checkbox rows. */
.menu-panel .menu-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.menu-panel .menu-check:hover { background: var(--surface-alt); }

/* The close-all and clear-filters controls, and any disabled icon button. */
.close-all svg, .filter-clear svg { width: 15px; height: 15px; }
.md-filter-group .filter-clear { margin-left: 6px; }
.icon-btn.is-disabled { opacity: .45; pointer-events: none; cursor: not-allowed; }

/* Windowed article prose keeps the page's reading measure. */
.win-body .post-content { margin-bottom: 1.5rem; padding-top: 0; }

/* An image opened as a child window. The body is a column: the figure
   takes the room and the prev/next nav sits beneath it. */
.win-body:has(> .win-image) {
  display: flex; flex-direction: column;
}
.win-image {
  margin: 0; flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.win-image img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; }
.win-image figcaption { font-size: .9rem; font-style: italic; color: var(--text-muted); flex: none; }
.win-img-nav {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding-top: 10px;
}
.win-img-nav .icon-btn { text-decoration: none; }
.win-img-nav .is-disabled { opacity: .35; }
.win-img-nav .num { font-size: .8rem; color: var(--text-muted); }

/* An image wrapped as a child-window opener is content, not a link block. */
.win-img-link { display: inline-block; line-height: 0; }

/* A window hosting an app page in a frame gives it the whole body. */
.win-app-frame { display: block; width: 100%; height: 100%; border: 0; }
.win-body:has(> .win-app-frame) { padding: 0; overflow: hidden; }

/* A page rendered bare for a frame keeps a modest gutter. */
.site-main-framed { padding: 0 16px; }

/* The active window title bar's quiet dark treatment became PUDL's own
   default in 0.9.0 (with --win-active-* tokens for tuning), so the
   override that prototyped it here is gone. */

/* === The tab bar's link area ==============================================
   Category tabs sit on the left; bare sitenav links (frequent or
   high-profile destinations) sit on the right, behind a partial-height
   separator, so the two jobs read as different. */
.bar-spacer { flex: 1; }
.bar-sep {
  align-self: center;
  width: 1px; height: 16px;   /* fixed: a % of an auto-height bar is zero */
  background: var(--border);
  margin: 0 6px;
}
/* The link area holds links, not tabs, so they follow the underline rule
   and carry none of the raised tab chrome (0.16.0 raises .section-tab). */
.bar-links { display: flex; align-items: center; }
.bar-links .section-tab {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  background: none; border: 0; box-shadow: none;
  padding-top: 5px; padding-bottom: 5px;
}
.bar-links .section-tab:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
  background: none; box-shadow: none; border: 0;
}

/* === Tag rows and the tag window ========================================== */
/* The tag row at the very top of a page or window: flat chips, each
   opening that tag's article list. */
.page-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-width: 860px; margin: 0 auto;
  padding: 10px 0 0;
}
.win-body > .page-tags { padding: 0 0 4px; }
/* A tag in the row is a link and looks like one (chips are display-only
   metadata in PUDL's grammar, so they are not used for navigation). */
.tag-link {
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.tag-link::before { content: "#"; opacity: .55; margin-right: 1px; }
.tag-link:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

.tag-window { max-width: 68ch; margin: 0 auto; }
.tag-window .card-desc { margin-bottom: 10px; }
.tag-window .md-row { border-right: 0; }
