/* newsdesk-design-system.css — mobile-first layout + components (§1–§6) */

/* ===== §1 CRITICAL: visible story headlines ===== */
.nd-story .nd-story-headline,
.nd-story-headline {
  display: block;
  visibility: visible;
  opacity: 1;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-2);
  min-height: calc(var(--fs-md) * var(--lh-tight));
  max-height: calc(var(--fs-md) * var(--lh-tight) * 2.15);
  overflow: hidden;
  word-break: break-word;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  text-overflow: ellipsis;
}

@supports (-webkit-line-clamp: 2) {
  .nd-story-headline {
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }
}

.nd-story.selected .nd-story-headline {
  color: var(--text);
}

.nd-story-summary {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  margin: 0 0 var(--sp-2);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

@supports (-webkit-line-clamp: 1) {
  .nd-story-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    white-space: normal;
  }
}

/* ===== Base desk shell ===== */
.nd-root {
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
}

.nd-grid {
  background: var(--bg);
  gap: var(--sp-3);
}

.nd-story {
  color: var(--text-2);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: auto;
}

.nd-story:hover {
  background: var(--raised);
}

.nd-story.selected {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nd-story-meta {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}

/* ===== §5 Components ===== */
.nd-cta {
  min-height: 36px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
}

.nd-cta.ghost,
.nd-cta.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.nd-cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nd-breaking-pill,
.nd-heat-pill,
.nd-solo-chip,
.nd-src-count,
.nd-cat-chip,
.nd-src-chip,
.nd-scoop-chip {
  font-size: var(--fs-xs);
  border-radius: 999px;
  padding: 2px var(--sp-2);
  line-height: 1.3;
}

.nd-search,
.nd-entity-jump-in,
.nd-sort,
.nd-quality-select,
select.nd-quality-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: var(--fs-sm);
  min-height: 36px;
  padding: var(--sp-2) var(--sp-3);
}

.nd-search:focus,
.nd-entity-jump-in:focus,
.nd-sort:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.nd-brief,
.nd-rail,
.nd-dossier,
.nd-dossier-card {
  background: var(--surface);
  border-color: var(--border);
  border-radius: var(--r);
}

.nd-section-title {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nd-section-body,
.nd-brief-headline,
.nd-brief-empty-title,
.nd-dossier-title {
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
}

.nd-brief-headline {
  font-size: var(--fs-lg);
  max-width: var(--maxread);
}

.nd-empty,
.nd-dossier-muted,
.nd-ps-quiet-msg {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.nd-feed-banner,
.nd-dossier-warn,
.nd-ps-error {
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
}

/* ===== §2 MOBILE (≤768px) ===== */
@media (max-width: 768px) {
  .nd-root {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow-x: hidden;
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .nd-chrome {
    flex-shrink: 0;
    width: 100%;
  }

  .nd-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
    overflow: visible;
  }

  .nd-topbar-primary {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--tap);
  }

  .nd-topbar-primary .nd-mode-toggle {
    flex: 1;
    min-width: 0;
  }

  .nd-topbar-primary .nd-live-dot {
    flex-shrink: 0;
    font-size: var(--fs-xs);
  }

  .nd-search {
    width: 100%;
    min-height: var(--tap);
    font-size: var(--fs-base);
    order: 0;
  }

  .nd-topbar-scroll {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sp-1);
    scrollbar-width: none;
  }

  .nd-topbar-scroll::-webkit-scrollbar {
    display: none;
  }

  .nd-topbar-scroll > * {
    flex-shrink: 0;
  }

  .nd-topbar-scroll .nd-sort,
  .nd-topbar-scroll .nd-quality-wrap select,
  .nd-topbar-scroll .nd-cta.ghost {
    min-height: var(--tap);
  }

  .nd-mode-btn,
  .nd-bell-btn,
  .nd-mute-btn,
  .nd-cat,
  .nd-cta,
  .nd-dossier-compose-btn,
  .nd-article-btn {
    min-height: var(--tap);
    font-size: var(--fs-base);
  }

  /* Beats = horizontal chip strip */
  .nd-rail {
    order: 2;
    flex-shrink: 0;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface);
    overflow: visible;
  }

  .nd-rail-eyebrow,
  .nd-doctrine-note,
  .nd-wl-list,
  .nd-wl-filings-mount {
    display: none;
  }

  .nd-cat-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--sp-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sp-1);
  }

  .nd-cat {
    flex: 0 0 auto;
    min-height: var(--tap);
    padding: var(--sp-2) var(--sp-3);
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--raised);
  }

  .nd-cat.active {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text);
  }

  /* Story list = full-width cards */
  .nd-center {
    order: 3;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .nd-center .nd-grid {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2) var(--sp-3) var(--sp-6);
    gap: var(--sp-3);
    -webkit-overflow-scrolling: touch;
  }

  .nd-story {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r);
    border-bottom: 1px solid var(--border);
    position: relative;
    min-height: auto;
  }

  .nd-compare-pick {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-3);
    width: var(--tap);
    height: var(--tap);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nd-story-scores {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-2);
    order: 1;
    width: 100%;
    padding-top: 0;
    min-width: 0;
  }

  .nd-score {
    font-size: var(--fs-xs);
    min-height: 28px;
    padding: var(--sp-1) var(--sp-2);
  }

  .nd-story-body {
    order: 2;
    width: 100%;
    min-width: 0;
    padding-right: var(--sp-6);
  }

  .nd-story-headline {
    font-size: var(--fs-md);
    max-height: none;
    min-height: calc(var(--fs-md) * var(--lh-tight));
  }

  .nd-story-right {
    order: 3;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: var(--sp-3);
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .nd-story-sources {
    display: none;
  }

  .nd-trend-board {
    display: none;
  }

  /* Full-screen reading view */
  .nd-brief {
    position: fixed;
    inset: 0;
    z-index: 300;
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: var(--sp-4);
    padding-top: max(var(--sp-4), env(safe-area-inset-top));
    padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: var(--bg);
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
  }

  .nd-brief-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    min-height: var(--tap);
    font-size: var(--fs-lg);
    margin-bottom: var(--sp-2);
  }

  .nd-root.nd-brief-open .nd-brief {
    transform: translateX(0);
    pointer-events: auto;
  }

  .nd-brief-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .nd-root.nd-brief-open .nd-brief-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nd-brief > * {
    max-width: 100%;
  }

  .nd-dossier-compose-block {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
  }

  .nd-dossier-compose-btn {
    width: 100%;
    min-height: var(--tap);
    font-size: var(--fs-base);
  }

  .nd-quality-radios,
  .nd-dossier-compose-block .nd-quality-radios {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .nd-quality-radios label,
  .nd-quality-radio {
    min-height: var(--tap);
    padding: var(--sp-2) var(--sp-4);
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--raised);
    font-size: var(--fs-sm);
    display: inline-flex;
    align-items: center;
  }

  .nd-onboard-checklist {
    display: none !important;
  }

  #adm-newsdesk-mount,
  #adm-main {
    overflow-x: hidden;
  }
}

@media (max-width: 414px) {
  .nd-story-headline {
    font-size: var(--fs-base);
  }
}

/* ===== §3 DESKTOP 3-pane (≥1024px) ===== */
@media (min-width: 1024px) {
  .nd-root {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 440px;
    grid-template-rows: auto 1fr;
    gap: var(--sp-5);
    padding: var(--sp-5);
    background: var(--bg);
    border: 0;
    border-radius: 0;
    min-height: calc(100vh - 180px);
    height: calc(100vh - 180px);
    max-height: none;
    overflow: hidden;
  }

  .nd-chrome {
    grid-column: 1 / -1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
  }

  .nd-rail {
    grid-column: 1;
    grid-row: 2;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    border-right: 1px solid var(--border);
    padding: var(--sp-4);
  }

  .nd-center {
    grid-column: 2;
    grid-row: 2;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
  }

  .nd-brief {
    grid-column: 3;
    grid-row: 2;
    position: relative;
    transform: none;
    pointer-events: auto;
    height: auto;
    max-height: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: var(--sp-5);
    overflow-y: auto;
  }

  .nd-brief-close {
    display: none;
  }

  .nd-brief-backdrop {
    display: none !important;
  }

  .nd-center .nd-grid {
    background: var(--surface);
  }

  .nd-story {
    display: grid;
    grid-template-columns: 28px 52px minmax(0, 1fr) auto;
    gap: var(--sp-3);
    padding: var(--sp-4);
    min-height: 108px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }

  .nd-story:hover {
    background: var(--raised);
  }

  .nd-story-body {
    grid-column: 3;
    grid-row: 1;
  }

  .nd-story-right {
    grid-column: 4;
    grid-row: 1;
  }

  .nd-brief .nd-section-body,
  .nd-brief .nd-bullet-list,
  .nd-dossier-article-body {
    max-width: var(--maxread);
  }

  .nd-topbar {
    flex-wrap: wrap;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }

  .nd-topbar-primary {
    display: contents;
  }

  .nd-topbar-scroll {
    display: contents;
  }
}

/* ===== §6 Readability ===== */
.nd-root p,
.nd-root li,
.nd-root dd,
.nd-brief-section,
.nd-dossier-snippet {
  color: var(--text-2);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
}

.nd-root .nd-fact-claim,
.nd-root .nd-dossier-title a {
  color: var(--text);
}

.nd-root small,
.nd-time-ago,
.nd-ps-doc-date {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Undo conflicting min-height crush on story cards */
.nd-story {
  min-height: auto;
}

@media (min-width: 769px) {
  .nd-story {
    min-height: 108px;
  }
}

/* ===== §A Mobile usability pass (beats top, gutters, scroll) ===== */
@media (max-width: 768px) {
  #adm-root,
  #adm-main,
  #adm-newsdesk-mount,
  .adm-newsdesk-host {
    overflow-x: hidden;
    max-width: 100vw;
  }

  #adm-newsdesk-mount .nd-root {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .nd-root > .nd-chrome {
    order: 0 !important;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
    box-sizing: border-box;
  }

  .nd-root > .nd-rail {
    order: 1 !important;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: var(--sp-2) var(--sp-4);
    box-sizing: border-box;
    overflow: visible;
  }

  .nd-root > .nd-center {
    order: 2 !important;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .nd-topbar {
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
  }

  .nd-search,
  .nd-topbar-scroll,
  .nd-ps-ticker-mount {
    max-width: 100%;
    box-sizing: border-box;
  }

  .nd-cat-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--sp-2);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: var(--sp-1) 0 var(--sp-2);
    width: 100%;
    max-width: 100%;
  }

  .nd-cat {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .nd-center .nd-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: var(--sp-3) var(--sp-4) var(--sp-8);
    gap: var(--sp-3);
  }

  .nd-story {
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 8px 10px;
    min-height: auto;
    padding: 12px var(--sp-4, 16px);
    max-width: 100%;
    overflow: hidden;
  }
  .nd-compare-pick {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
  }
  .nd-story-scores {
    grid-column: 2;
    grid-row: 1;
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
    padding-top: 0;
  }
  .nd-story-body {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  .nd-story-right { display: none; }
  .nd-story-sources {
    flex-wrap: wrap;
    max-width: 100%;
    overflow: hidden;
  }
  .nd-story-headline,
  .nd-story-summary {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .nd-brief {
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
  }
}

@media (max-width: 414px) {
  .nd-root > .nd-chrome,
  .nd-root > .nd-rail,
  .nd-center .nd-grid {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }
}

.nd-dossier-quiet .nd-dossier-muted {
  color: var(--text-2);
}

