/* ======================================================
   TABLE OF CONTENTS:
   1. CSS Variables & Root
   2. Base & Typography Styles
   3. Layout & Containers
   4. Header & Navigation
   5. News View Components
   6. Cards & Detail Views
   7. Footer
   8. Utilities & Helper Classes
   9. Media Queries
====================================================== */

/* 1. CSS Variables & Root */
/* Local aliases onto the design-system tokens ei_core_css() emits. This file
   declares no colors of its own. */
:root {
  /* Colors */
  --primary-color: var(--azure-ink);
  --primary-light: var(--tint-azure);
  --primary-dark: var(--azure-ink-hover);
  --text-color: var(--ink);
  --text-muted: var(--slate);
  --text-light: var(--slate);
  --background-color: var(--paper);
  --card-bg: var(--card);
  --border-color: var(--mist);
  --border-light: var(--mist);

  /* Depth is a 1px mist border against paper, never a shadow. */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;

  /* Border Radius */
  --radius-sm: var(--radius);
  --radius-md: var(--radius);
  --radius-lg: var(--radius);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;

  /* Component background colors */
  --events-bg: var(--card);
  --details-bg: var(--card);
  --sidebar-bg: var(--card);

  /* Font weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Font sizes */
  --font-size-xs: 10px;
  --font-size-sm: 12px;
  --font-size-base: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-xxl: 22px;
  --font-size-h1: 22px;
  --font-size-h2: 18px;
  --font-size-h3: 16px;
  --font-size-h4: 14px;
  
  /* Line heights */
  --line-height-tight: 1.3;
  --line-height-base: 1.6;
  --line-height-loose: 1.8;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* 2. Base & Typography Styles */
body {  color: var(--text-color);
  line-height: var(--line-height-base);
  background-color: var(--background-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  box-sizing: border-box;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

*, *:before, *:after {
  box-sizing: inherit;
  letter-spacing: normal;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--ink);
  margin-top: 0;
  letter-spacing: normal;
}

h1 { 
  font-size: var(--font-size-h1); 
  font-weight: var(--font-weight-bold);
}

h2 { 
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-semibold);
}

h3 { 
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
}

h4 { 
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-semibold);
}

p {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

/* Form elements */
.form-control {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  border: 2px solid var(--mist);
}

.btn {
  padding: 0.6rem 1.2rem;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
  transition: background-color 0.3s ease,
              border-color 0.3s ease,
              color 0.3s ease;
}

.btn-primary {
  background-color: var(--azure-ink);
  border-color: var(--azure-ink);
  color: #ffffff;
  font-weight: 600;
  margin-top: 10px;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--azure-ink-hover);
  border-color: var(--azure-ink-hover);
}

.btn-outline-secondary {
  border-color: var(--mist);
  color: var(--text-muted);
  margin-top: 10px;
}

.btn-outline-secondary:hover {
  background-color: var(--paper);
  color: var(--text-color);
}

/* Styling for the compact tag dropdown */
.tag-select-container {
  margin-bottom: 15px;
}

/* Sort order, drawn as the design system's segmented control. The markup is
   Shiny's radio group (the server sees a plain radio input); the dots are
   hidden and each label's span is drawn as a segment. */
.sort-toggle-container {
  display: flex;
  justify-content: center;
}

.sort-toggle-container .form-group { margin: 0; }

#articles_sort .shiny-options-group {
  display: inline-flex;
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

#articles_sort .radio-inline {
  margin: 0;
  padding: 0;
  display: inline-flex;
  font-weight: 400;
}

#articles_sort .radio-inline + .radio-inline {
  border-left: 1px solid var(--mist);
}

/* Hidden but still focusable, so keyboard arrows switch segments. */
#articles_sort input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

#articles_sort .radio-inline span {
  display: inline-flex;
  align-items: center;
  height: var(--control-h-dense, 28px);
  padding: 0 var(--s-control, 12px);
  font-size: 14px;
  line-height: 1;
  color: var(--slate);
  cursor: pointer;
}

#articles_sort input:checked + span {
  background: var(--azure);
  color: #FFFFFF;
}

#articles_sort input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

/* Make search input width match other form elements */
.search-input,
.search-input .form-control,
#news_search {
  width: 100% !important;
  max-width: 100% !important;
  font-size: var(--font-size-base);
}

.input-group {
  width: 100% !important;
  max-width: 100% !important;
}

/* Make sure all selectize inputs have consistent width */
.selectize-control {
  width: 100% !important;
}

.selectize-input {
  width: 100% !important;
  font-size: var(--font-size-base);
}

/* Ensure all form fields in sidebar have consistent appearance */
.sidebar-section .form-control,
.sidebar-section .selectize-control,
.sidebar-section .input-group {
  width: 100% !important;
  max-width: 100% !important;
}

/* The partner seal is square; the default 200px logo width would oversize it. */
.ei-footer__logo[src*="DCE-seal"] { max-width: 96px; }

/* 3. Layout & Containers */
.container-fluid {
  padding-left: 0 !important;
  padding-right: 0 !important;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.app-view {
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
}

.app-description {
  font-size: var(--font-size-lg);
  color: var(--text-muted);
  margin: 10px auto;
  line-height: var(--line-height-base);
  letter-spacing: 0.2px;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

/* 4. Header & Navigation: the ei_header() masthead needs no local rules. */

/* Empty States */
.empty-detail-panel {
  overflow: hidden;
  height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card);
  border-radius: var(--radius-sm);
  padding: 1rem;
  width: 100%;
}

.empty-details-content {
  text-align: center;
  padding: var(--spacing-xxl);
  color: var(--slate);
  width: 100%;
  max-width: 400px;
}

.empty-details-content i {
  font-size: 3rem;
  color: var(--mist);
  margin-bottom: var(--spacing-xl);
  display: block;
}

.empty-details-content h3 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: var(--spacing-lg);
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.empty-details-content p {
  font-size: 1rem;
  color: var(--slate);
  margin-bottom: 0;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-base);
  color: var(--slate);
}

.meta-item i {
  color: var(--primary-color);
  font-size: var(--font-size-lg);
}

.article-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  box-shadow: none;
  cursor: pointer;
  position: relative;
  border: 1px solid rgba(0,0,0,0.05);
  /* Reserve the selection edge's width so nothing shifts on click. */
  border-left: 3px solid transparent;
  transition: box-shadow var(--transition-fast),
              transform var(--transition-fast),
              border-color var(--transition-fast);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.article-card:hover {
  box-shadow: none;
}

/* The open article carries the suite's selection rust on its edge, on a
   paper surface: a warm tint across a whole card reads as a notice panel,
   not a selection, so the table row's tint is not used here. */
.article-card.active {
  border-left: 3px solid var(--rust);
  background-color: var(--paper);
}

.article-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  line-height: 1.2;
  color: var(--ink);
  word-break: break-word;
  overflow-wrap: break-word;
}

.article-body {
  font-size: var(--font-size-base);
  color: var(--slate);
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  overflow: hidden;
  max-height: 3em;
  word-break: break-word;
}

/* Article tags (detail panel only) */
.article-tag-pill {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  margin: 0.2rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  background-color: var(--tint-azure);
  color: var(--azure-ink);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.01em;
}

/* No hover style on the pills: they are labels, not buttons, and a hover
   tint falsely implies they are clickable. */

/* Article Detail Panel */
.article-detail-wrapper {
  height: 100%;
  overflow-y: auto;
  background-color: var(--card);
  border-radius: var(--radius-sm);
  width: 100%;
  display: flex;
  flex-direction: column;
}

.article-detail-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--card);
}

.article-detail-content {
  padding: 1.5rem;
  flex: 1;
  background-color: var(--card);
}

.article-detail-title {
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

/* 7. Footer: ei_footer() carries the whole thing; nothing to restate here. */

/* News View Components */
/* News Container */
.news-container {
  margin-top: var(--spacing-lg);
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  /* Explicit flex row - this page is Bootstrap 3, whose .row is floats,
     not flexbox. As flex items, the sidebar and the article panel stretch
     to the same height at any content length; below 992px both take a
     100% basis and wrap onto their own lines, stacking the sidebar above
     the panel. */
  display: flex;
  flex-wrap: wrap;
}

/* News Sidebar */
.news-sidebar {
  background-color: var(--card);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: none;
  border: none;
  width: 25%;
  flex: 0 0 25%;
  max-width: 25%;
  /* min-width 0: without it the flex minimum is the widest filter control,
     which forces the rail past its percentage basis on narrow windows and
     wraps the article panel onto its own line. */
  min-width: 0;
  /* No height of its own: the row's default stretch keeps this card
     exactly as tall as the article panel beside it, whatever the list's
     content comes to. Pagination lives outside the row for this reason. */
}

.sidebar-section {
  margin-bottom: var(--spacing-xl);
}

.sidebar-section h4 {
  color: var(--ink);
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--mist);
}

.sidebar-section .filter-actions {
  margin-top: var(--spacing-xl);
  display: flex;
  gap: 0.75rem;
}

/* Articles content area */
.news-content {
  padding-left: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  width: 75%;
  flex: 0 0 75%;
  max-width: 75%;
  min-width: 0;
}

.news-content-container {
  display: flex;
  /* Fill the stretched column so the panel's bottom edge is the row's
     bottom edge, level with the sidebar. */
  flex: 1;
  min-height: 500px;
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--card);
}

/* Articles count */
.articles-count-section {
  padding: 0.75rem 1rem;
  /* Neutral: the warm tint is reserved for selection, and this is a stat,
     not a selected thing. */
  background-color: var(--paper);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.articles-count-wrapper {
  font-size: 1.4rem;
  color: var(--ink);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  /* flex items drop the literal space between the label and the count */
  gap: 6px;
}

.articles-count-wrapper .shiny-text-output {
  font-family: var(--font-mono);
}

/* Articles list column */
.news-list-column {
  flex: 0 0 50%;
  height: 100%;
  overflow-y: auto;
  padding: 0;
  border-right: 1px solid var(--border-light);
  background-color: var(--card);
}

/* News detail column */
.news-detail-column {
  position: relative;
  flex: 1;
  border-left: 1px solid var(--border-light);
  min-width: 0;
  overflow-y: auto;
  padding: 0;
  background-color: var(--card);
  display: flex;
  flex-direction: column;
}

/* 9. Media Queries */
/* Responsive adjustments */
@media (max-width: 1200px) {
  /* News sidebar adjustments for medium screens */
  .news-sidebar {
    width: 30%;
    flex: 0 0 30%;
    max-width: 30%;
  }

  .news-content {
    width: 70%;
    flex: 0 0 70%;
    max-width: 70%;
  }
}

/* Tablets (769-991px): a 30% rail is narrower than the filter controls can
   usefully be, so the sidebar sits full-width above the article panel.
   Phone behavior (the Filters fold, the one-pane article view) starts at
   768px below. */
@media (max-width: 991px) {
  .news-sidebar,
  .news-content {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }

  .news-sidebar { margin-bottom: var(--spacing-lg); }

  /* The gutter against the sidebar has no partner when stacked. */
  .news-content { padding-left: 0; }
}

/* Tablet devices */
@media (max-width: 992px) {
  .sidebar-section {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
  }
  
  .container-fluid {
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
}

/* Mobile devices */
@media (max-width: 768px) {
  .articles-pagination {
    margin-bottom: 20px;
  }

  /* Tighter padding on phones; the 991px query above already stacks the
     sidebar over the article panel. */
  .news-sidebar,
  .news-content {
    padding: var(--spacing-md);
  }
}

/* Extra small devices */
@media (max-width: 576px) {
  .container-fluid {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .news-sidebar,
  .news-content {
    padding-left: 5px;
    padding-right: 5px;
  }
}

.articles-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  padding: var(--spacing-md);
  height: 100%;
  overflow-y: auto;
  background-color: var(--card);
}

.no-articles {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--slate);
  background-color: var(--card);
}

/* ======================================================
   10. ADA Compliance & Accessibility
====================================================== */

/* Focus indicators for all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
.btn:focus,
.article-card:focus,
.page-link:focus,
[tabindex]:focus {
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}

/* Keyboard focus for article cards */
.article-card:focus-visible {
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18), var(--shadow-md);
}

/* Focus for radio buttons */
input[type="radio"]:focus {
  outline: 2px solid var(--azure);
  outline-offset: 2px;
}

/* Ensure buttons have visible focus state */
.btn-primary:focus,
.btn-outline-secondary:focus {
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}

/* Focus for pagination links */
.pagination .page-link:focus {
  z-index: 3;
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}

/* Focus for action links in footer */
.footer-copyright a:focus {
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  background-color: rgba(52, 152, 219, 0.1);
}

/* Focus visible for selectize inputs */
.selectize-input:focus,
.selectize-input.focus {
  border-color: var(--azure);
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}

/* Keyboard navigation for article cards */
.article-card[tabindex]:focus {
  outline: 3px solid var(--azure);
  outline-offset: 2px;
}

/* Ensure sufficient contrast for disabled elements */
.page-item.disabled .page-link {
  background-color: var(--mist);
  color: var(--slate);
  border-color: var(--mist);
}

.form-control:focus {
  border-color: var(--azure);
  outline: 3px solid var(--azure);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .18);
}

/* Ensure links have proper contrast */
a {
  color: var(--azure-ink);
  text-decoration: none;
}

a:hover {
  color: var(--azure-ink-hover);
  text-decoration: none;
}

/* Footer links */
.footer-copyright a {
  color: var(--azure-ink);
  text-decoration: none;
}

.footer-copyright a:hover,
.footer-copyright a:focus {
  color: var(--azure-ink-hover);
}

/* Ensure Read Full Article button has no underline */
.article-actions a,
.article-actions .btn {
  text-decoration: none;
}

.article-actions a:hover,
.article-actions .btn:hover {
  text-decoration: none;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .article-card {
    border: 2px solid #000000;
  }

  .btn-primary {
    border: 2px solid #000000;
  }

  .article-tag-pill {
    border: 2px solid var(--azure-ink);
  }
}

/* Ensure proper font size hierarchy is maintained */
.article-meta {
  font-size: var(--font-size-sm);
  color: var(--text-light);
}

.article-source,
.article-date {
  font-size: var(--font-size-sm);
  color: var(--text-light);
}
/* ======================================================
   11. Refinement layer - typography, rhythm, and depth.
   Palette colors are intentionally unchanged.
====================================================== */

h1, h2, h3, h4 { letter-spacing: -0.01em; }

/* Dates and counts align cleanly in lists */
.articles-pagination {
  font-variant-numeric: tabular-nums;
}

/* Quiet, consistent motion */
a, .btn, button, .article-tag-pill {
  transition: color var(--transition-fast),
              background-color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

/* Keyboard focus is always visible */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

::selection { background: var(--primary-light); }

/* Thin neutral scrollbars in long lists */
.news-sidebar, .news-content, .articles-container {
  scrollbar-width: thin;
}
.news-sidebar::-webkit-scrollbar,
.news-content::-webkit-scrollbar,
.articles-container::-webkit-scrollbar { width: 8px; }
.news-sidebar::-webkit-scrollbar-thumb,
.news-content::-webkit-scrollbar-thumb,
.articles-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  .article-card, a, .btn, button, .article-tag-pill { transition: none; }
  .article-card:hover { transform: none; }
}

/* ======================================================
   12. Article detail navigation (all screen sizes)
====================================================== */

.article-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* The wrapper has no padding of its own - the 1.5rem gutter lives on
     .article-detail-header/-content, so this row carries its own. The
     bottom padding clears the buttons' 5px focus ring (3px outline +
     2px offset), which the header's opaque background covers otherwise. */
  padding: 1rem 1.5rem 0.5rem;
}
.article-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font-body);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text-color);
  cursor: pointer;
}
.article-nav-btn:hover:not(:disabled) {
  background: var(--paper);
  border-color: var(--text-muted);
}
.article-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.article-nav-position {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ======================================================
   13. Phone layout - collapsible filters and one pane at
   a time. The .filters-open / .showing-article classes are
   toggled client-side (ui.R head script) and are inert on
   wider screens.
====================================================== */

.filters-toggle { display: none; }
.detail-back { display: none; }
/* Filters apply instantly, so the confirm button only exists on phones,
   where it closes the fold (relabeled "Done" in ui.R). */
#apply_filters { display: none; }

@media (max-width: 768px) {
  /* The count and search stay visible; everything else folds
     behind the Filters button. */
  .filters-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
    color: var(--text-color);
    cursor: pointer;
  }
  .sidebar-filters { display: none; }
  .news-sidebar.filters-open .sidebar-filters {
    display: block;
    margin-top: var(--spacing-md);
  }
  .filter-count-badge {
    background: var(--azure-ink);
    color: #ffffff;
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    padding: 1px 8px;
    margin-left: 4px;
  }
  #apply_filters { display: inline-block; }

  /* One pane at a time: the list fills the screen; tapping an
     article swaps in the detail with a Back control. Everything
     that belongs to the list view - sidebar, sort toggle,
     description, pagination - steps aside with it. */
  .news-content-container { min-height: 0; }
  .news-list-column { flex: 0 0 100%; }
  .news-detail-column { display: none; }
  #news-view.showing-article .app-description,
  #news-view.showing-article .sort-toggle-container,
  #news-view.showing-article .news-sidebar,
  #news-view.showing-article .news-list-column,
  #news-view.showing-article .articles-pagination { display: none; }
  #news-view.showing-article .news-detail-column {
    display: block;
    flex: 0 0 100%;
    border-left: none;
  }

  .detail-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    /* The column has no padding of its own; the 1.5rem sides line the
       button up with the article's own gutter instead of the screen edge. */
    margin: 12px 1.5rem;
    font-family: var(--font-body);
    font-weight: var(--font-weight-semibold);
    color: var(--text-color);
    cursor: pointer;
  }
}

/* ======================================================
   13. Loading skeletons (§5)
====================================================== */

/* Shiny outputs are empty elements until the first server render arrives.
   While they are, each shows a mist skeleton at the final layout's
   dimensions, so the page opens at its real height and nothing jumps.
   Rendered content, including the empty state, clears :empty. */

#articles_list:empty {
  display: block;
  position: relative;
  min-height: 656px;
  margin: var(--spacing-md);
  border-radius: var(--radius-sm);
  /* Five card-sized bars at the list's own rhythm. */
  background: repeating-linear-gradient(
      to bottom,
      var(--mist) 0,
      var(--mist) 112px,
      transparent 112px,
      transparent 136px);
}

#article_detail:empty {
  display: block;
  min-height: 500px;
  margin: var(--spacing-lg);
  /* A title, a meta line, then a paragraph. */
  background:
    linear-gradient(var(--mist), var(--mist)) 0 0 / 65% 26px no-repeat,
    linear-gradient(var(--mist), var(--mist)) 0 44px / 35% 15px no-repeat,
    linear-gradient(var(--mist), var(--mist)) 0 96px / 100% 15px no-repeat,
    linear-gradient(var(--mist), var(--mist)) 0 124px / 100% 15px no-repeat,
    linear-gradient(var(--mist), var(--mist)) 0 152px / 100% 15px no-repeat,
    linear-gradient(var(--mist), var(--mist)) 0 180px / 45% 15px no-repeat;
}

/* The sidebar's filter widgets, at the control's final height. */
#news_tag_filter:empty,
#news_source_filter:empty {
  display: block;
  height: 34px;
  border-radius: var(--radius);
  background: var(--mist);
}

/* §5: a mono progress line naming the work when it runs past 2s. */
#articles_list:empty::after {
  content: "Loading articles …";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 11.8px;
  color: var(--slate);
  background: var(--card);
  padding: 4px 10px;
  border-radius: var(--radius);
  opacity: 0;
  animation: ei-loading-note .3s ease 2s forwards;
}

@keyframes ei-loading-note {
  to { opacity: 1; }
}
