/*
 * editorial.css — Track I page-specific layout for the Editorial Feed (V1).
 *
 * Builds on top of Track A's tokens (loaded via styles.css). This file
 * adds only layout + editorial-specific styles; it introduces NO new
 * colour tokens beyond those defined in styles.css.
 *
 * Three-column grid: 220px (left nav) · 1fr (main feed) · 260px (right rail)
 * matching the V1-editorial.jsx reference.
 */

/* ── Full-page shell ─────────────────────────────────────────────────────── */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/*
 * .editorial-shell overrides .app-shell's generic declaration with the
 * exact column widths from the V1 prototype artboard.
 */
.editorial-shell {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  grid-template-areas: "nav main rail";
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  font-feature-settings: "ss01", "cv11";
}

/* ── Left navigation rail ───────────────────────────────────────────────── */
.ed-nav {
  grid-area: nav;
  border-right: 1px solid var(--rule);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  scrollbar-width: none;
}
.ed-nav::-webkit-scrollbar { display: none; }

.ed-nav__wordmark {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.ed-nav__location {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Navigation links */
.ed-nav__menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ed-nav__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  margin: 0 -10px;
  border-left: 2px solid transparent;
  color: var(--ink-2);
  font-weight: 400;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
}

.ed-nav__item.active {
  background: var(--paper-2);
  border-left-color: var(--ink);
  color: var(--ink);
  font-weight: 500;
}

.ed-nav__item:hover:not(.active) {
  background: var(--paper-2);
}

.ed-nav__badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

/* Delegate summary panel — bottom of left rail */
.ed-nav__delegate {
  margin-top: auto;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.5;
}

.ed-nav__delegate-heading {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 9px;
  margin-bottom: 8px;
}

.ed-delegate-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.ed-delegate-row__topic {
  color: var(--ink-2);
}

.ed-delegate-row__name {
  font-size: 10px;
  color: var(--ink-3);
}

.ed-delegate-row__score {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

/* Empty / degraded delegate state */
.ed-delegate-empty {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  padding: 4px 0;
}

/* ── Main editorial feed ────────────────────────────────────────────────── */
.ed-main {
  grid-area: main;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
}
.ed-main::-webkit-scrollbar { display: none; }

/* Masthead */
.ed-masthead {
  padding: 28px 32px 18px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-shrink: 0;
}

.ed-masthead__date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ed-masthead__headline {
  font-family: var(--serif);
  font-size: 38px;
  margin: 4px 0 0;
  line-height: 1.05;
  font-weight: 400;
}

.ed-masthead__subtitle {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 8px;
}

.ed-masthead__issue {
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  flex-shrink: 0;
}

/* Feed container */
.ed-feed {
  padding: 0 32px;
  flex: 1;
}

/* Article loading placeholder */
.ed-article-loading {
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
}

.ed-article-loading__bar {
  height: 14px;
  border-radius: 2px;
  margin-bottom: 8px;
}

/* Article card */
.ed-article {
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
}

.ed-article:last-child {
  border-bottom: none;
}

.ed-article__grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 28px;
}

/* Left column */
.ed-article__left {
  min-width: 0;
}

.ed-article__kicker-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.ed-article__kicker {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--civic);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ed-article__sep {
  color: var(--ink-4);
  font-size: 11px;
}

.ed-article__time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

.ed-article__headline {
  font-family: var(--serif);
  font-size: 24px;
  margin: 0 0 8px;
  line-height: 1.2;
  font-weight: 400;
  /* text-wrap: pretty is a progressive enhancement */
}

.ed-article__dek {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 12px;
}

/* Impact callout block */
.ed-article__impact {
  background: var(--paper-2);
  padding: 10px 14px;
  border-left: 2px solid var(--civic);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
}

.ed-article__impact-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--civic);
  margin-right: 8px;
}

/* Impact degraded / loading states */
.ed-article__impact--loading {
  background: var(--paper-2);
  padding: 10px 14px;
  border-left: 2px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ed-article__impact--unavailable {
  background: var(--paper-2);
  padding: 10px 14px;
  border-left: 2px solid var(--rule-soft);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Action row */
.ed-article__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
}

.ed-article__action-btn {
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 2px;
  font-family: inherit;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.ed-article__action-btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.ed-article__action-btn--support-active {
  border-color: var(--support);
  background: var(--support-soft);
  color: oklch(32% 0.08 150);
}

.ed-article__action-btn--oppose-active {
  border-color: var(--risk);
  background: var(--risk-soft);
  color: oklch(32% 0.09 30);
}

.ed-article__action-link {
  font-size: 12px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-color: var(--ink-4);
  text-underline-offset: 3px;
  transition: color 0.1s ease;
}

.ed-article__action-link:hover {
  color: var(--ink);
}

.ed-article__action-spacer {
  flex: 1;
}

.ed-article__stage {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* Right gutter (stat + stance bar + stage progress) */
.ed-article__right {
  border-left: 1px solid var(--rule);
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ed-stat__label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ed-stat__value {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  margin-top: 4px;
}

.ed-stat__value--risk    { color: var(--risk); }
.ed-stat__value--support { color: var(--support); }
.ed-stat__value--neutral { color: var(--ink); }

.ed-stat__value--em {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--ink-4);
  line-height: 1;
  margin-top: 4px;
}

/* Public-stance bar */
.ed-stance__label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.ed-stance__track {
  display: flex;
  height: 4px;
  background: var(--paper-3);
  overflow: hidden;
}

.ed-stance__counts {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: var(--ink-3);
}

/* Stage-progress bar */
.ed-progress {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

.ed-progress__header {
  display: flex;
  justify-content: space-between;
}

.ed-progress__track {
  height: 2px;
  background: var(--paper-3);
  margin-top: 4px;
}

/* Empty feed state */
.ed-feed-empty {
  padding: 48px 32px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Feed error state */
.ed-feed-error {
  padding: 48px 32px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--risk);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Right rail ─────────────────────────────────────────────────────────── */
.ed-rail {
  grid-area: rail;
  border-left: 1px solid var(--rule);
  padding: 28px 22px;
  background: var(--paper-2);
  overflow-y: auto;
  scrollbar-width: none;
}
.ed-rail::-webkit-scrollbar { display: none; }

.ed-rail__section-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

/* KPI block */
.ed-kpi__value {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 0.95;
}

.ed-kpi__sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.4;
}

.ed-kpi__dots {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
  font-size: 10px;
  color: var(--ink-3);
}

.ed-kpi__dot-label {
  margin-left: 2px;
}

/* Degraded KPI */
.ed-kpi__value--empty {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--ink-4);
  line-height: 1;
}

/* Deadlines */
.ed-deadline-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--rule-soft);
  font-size: 12px;
}

.ed-deadline-row__date {
  font-family: var(--mono);
  color: var(--ink-3);
}

.ed-deadline-row__title {
  color: var(--ink-2);
  line-height: 1.3;
}

.ed-deadline-row__days {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
}

.ed-deadlines-empty {
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--rule-soft);
}

/* Reps alignment */
.ed-rep-row {
  padding: 10px 0;
  border-top: 1px solid var(--rule-soft);
}

.ed-rep-row__header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.ed-rep-row__name {
  color: var(--ink);
}

.ed-rep-row__score {
  font-family: var(--mono);
  color: var(--ink-3);
}

.ed-rep-row__district {
  font-size: 10px;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.ed-rep-row__bar {
  height: 2px;
  background: var(--paper-3);
}

.ed-reps-empty {
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--rule-soft);
}

/* ── Responsive collapse ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .editorial-shell {
    grid-template-columns: 220px 1fr;
    grid-template-areas: "nav main";
  }
  .ed-rail { display: none; }
}

/* Tablet portrait (641–820px) — keep 2-of-3 rails: left nav + main feed +
 * a narrower right rail with collapsible sections. The summary chrome on
 * .ed-rail__accordion is shown via styles.css so users can fold sections
 * to reclaim vertical space. The masthead / feed padding shrink slightly
 * so the headline doesn't crowd the rail boundary. */
@media (min-width: 641px) and (max-width: 820px) {
  .editorial-shell {
    grid-template-columns: 200px 1fr 220px;
    grid-template-areas: "nav main rail";
  }
  .ed-rail {
    display: block;
    padding: 18px 14px;
  }
  .ed-nav { padding: 18px 14px; gap: 18px; }
  .ed-masthead { padding: 22px 22px 14px; }
  .ed-masthead__headline { font-size: 30px; }
  .ed-feed { padding: 0 22px; }
  /* Right gutter on each article shrinks so the headline keeps real estate */
  .ed-article__grid {
    grid-template-columns: 1fr 140px;
    gap: 20px;
  }
}

@media (max-width: 640px) {
  /* HP65 §13: replace the vanished left/right rails with: (a) a slide-out
   * drawer for the section nav (handled by .civic-mobile-nav in styles.css),
   * (b) a stacked layout that surfaces the right-rail "at-a-glance" content
   * ABOVE the masthead so users still see deadlines / KPI / rep alignment
   * on mobile.                                                           */
  .editorial-shell {
    display: block;             /* drop the grid; stack vertically */
    height: auto;               /* let the page scroll naturally */
    overflow: visible;
  }
  .ed-nav { display: none; }    /* replaced by .civic-mobile-drawer */
  .ed-rail {
    display: block;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 16px;
    overflow: visible;
    height: auto;
  }
  .ed-rail__section-label {
    margin-bottom: 6px;
  }
  .ed-main {
    overflow: visible;
    height: auto;
  }
  .ed-masthead__issue { display: none; }
  .ed-masthead { padding: 16px; }
  .ed-feed { padding: 0 16px; }
  .ed-masthead__headline { font-size: 26px; }
}

/* ── 375px-class refinements (≤480px) ────────────────────────────────────── */
/* Mobile responsiveness pass (HP52 §8.B.2). The article grid stops being
 * a 1fr/180px split — on a 375px viewport that left only ~135px for the
 * headline. Instead, fold the right gutter (stat + stance + progress)
 * underneath the headline as a horizontal flex row so each piece keeps
 * its visual weight without crowding the headline. */
@media (max-width: 480px) {
  .ed-article__grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .ed-article__right {
    border-left: none;
    border-top: 1px dashed var(--rule);
    padding-left: 0;
    padding-top: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-end;
  }
  .ed-article__headline { font-size: 20px; }
  .ed-stat__value { font-size: 26px; }
  .ed-progress { flex-basis: 100%; margin-top: 0; }
  .ed-masthead__headline { font-size: 22px; }
}
