/* ═══════════════════════════════════════════════
   brief.css — styles specific to the daily brief panel.
   Depends on base.css for tokens, buttons, layout.
   ═══════════════════════════════════════════════ */

/* ── Meta bar ── */
.meta-bar {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 8px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-bar span {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Intensity histogram ── */
.meta-histogram {
  flex: 1;
  min-width: 0;
}

.hist-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.hist-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
  width: 100%;
}

.hist-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 1px 1px 0 0;
  transition: opacity 0.15s ease;
}

.hist-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.hist-track {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
}

.hist-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.15s, transform 0.1s;
  pointer-events: none;
}

.hist-wrap:active .hist-thumb {
  background: var(--text);
  transform: translate(-50%, -50%) scale(1.25);
}

.hist-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

/* ── Articles ── */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.article-card:hover {
  border-color: var(--text-dim);
}

.article-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.article-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.article-title:hover {
  color: var(--accent);
}

.intensity-chip {
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1;
  align-self: center;
}

.article-title[data-article-id] {
  cursor: pointer;
}
.article-title[data-article-id]:hover {
  color: var(--accent);
}

.article-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 7px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.article-meta .source {
  color: var(--accent);
  font-weight: 500;
}

.article-meta .meta-time {
  flex-shrink: 0;
}

.article-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}

.domain-tag, .register-tag, .flag-tag {
  font-size: 0.65rem;
  padding: 2px 9px;
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Domain colours */
.domain-tag {
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.25);
  color: var(--accent);
}
.domain-politics     { border-color: rgba(163, 113, 247, 0.3); color: #a371f7; background: rgba(163, 113, 247, 0.08); }
.domain-conflict     { border-color: rgba(248, 81, 73, 0.3);   color: #f85149; background: rgba(248, 81, 73, 0.08); }
.domain-economy      { border-color: rgba(210, 153, 34, 0.3);  color: #d29922; background: rgba(210, 153, 34, 0.08); }
.domain-science      { border-color: rgba(63, 185, 80, 0.3);   color: #3fb950; background: rgba(63, 185, 80, 0.08); }
.domain-tech         { border-color: rgba(121, 192, 255, 0.3); color: #79c0ff; background: rgba(121, 192, 255, 0.08); }
.domain-environment  { border-color: rgba(63, 185, 80, 0.3);   color: #56d364; background: rgba(63, 185, 80, 0.08); }
.domain-health       { border-color: rgba(219, 97, 162, 0.3);  color: #db61a2; background: rgba(219, 97, 162, 0.08); }
.domain-culture      { border-color: rgba(210, 153, 34, 0.3);  color: #e3b341; background: rgba(210, 153, 34, 0.08); }
.domain-sports       { border-color: rgba(88, 166, 255, 0.3);  color: #58a6ff; background: rgba(88, 166, 255, 0.08); }
.domain-human        { border-color: rgba(63, 185, 80, 0.3);   color: #7ee787; background: rgba(63, 185, 80, 0.08); }
.domain-meta         { border-color: rgba(139, 148, 158, 0.3); color: #8b949e; background: rgba(139, 148, 158, 0.08); }

/* Register colours */
.register-tag {
  background: rgba(139, 148, 158, 0.06);
  border: 1px solid rgba(139, 148, 158, 0.2);
  color: var(--text-dim);
  font-style: italic;
}
.register-alert      { border-color: rgba(248, 81, 73, 0.4);   color: #f85149; background: rgba(248, 81, 73, 0.06); }
.register-concern    { border-color: rgba(210, 153, 34, 0.4);  color: #d29922; background: rgba(210, 153, 34, 0.06); }
.register-analysis   { border-color: rgba(163, 113, 247, 0.3); color: #a371f7; background: rgba(163, 113, 247, 0.06); }
.register-awareness  { border-color: rgba(139, 148, 158, 0.2); color: #8b949e; }
.register-curiosity  { border-color: rgba(63, 185, 80, 0.3);   color: #3fb950; background: rgba(63, 185, 80, 0.06); }
.register-reflection { border-color: rgba(121, 192, 255, 0.3); color: #79c0ff; background: rgba(121, 192, 255, 0.06); }

/* Country code badge */
.country-tag {
  font-size: 0.65rem;
  padding: 2px 9px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(139, 148, 158, 0.08);
  border: 1px solid rgba(139, 148, 158, 0.25);
  color: var(--text-muted);
  font-family: monospace;
}

/* Content flag badge */
.flag-tag {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--negative);
  cursor: help;
}

/* ── Sticky filter bar ── */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(22, 27, 34, 0.92);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.22s ease;
  transform: translateY(0);
  will-change: transform;
}

.filter-bar.is-peek-hidden {
  transform: translateY(calc(-100% + 1px));
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.filter-row-primary {
  flex-wrap: nowrap;
}

.filter-row-secondary {
  padding-top: 2px;
}

.page-search {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.75rem;
  width: 100%;
  min-width: 0;
  flex: 1 1 180px;
}
.page-search::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}
.page-search:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  flex: 0 1 108px;
  min-width: 0;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select.exclude-hover {
  border-color: rgba(248, 81, 73, 0.8);
  box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.15);
  color: var(--text);
}

.filter-select--age {
  color: var(--text-dim);
}

/* Exclude-mode toggle button */
.exclude-toggle {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
  user-select: none;
  position: relative;
}
.exclude-toggle:hover {
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--text);
}
.exclude-toggle.active {
  border-color: var(--negative);
  color: var(--negative);
  background: rgba(248, 81, 73, 0.08);
  box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.12);
}

.toggle-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toggle-glyph-selective { opacity: 1; }
.exclude-toggle.active .toggle-glyph-selective { opacity: 0; transform: scale(0.92); }
.exclude-toggle.active .toggle-glyph-exclusive { opacity: 1; }

.toggle-glyph-selective::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 1.6px solid currentColor;
  border-radius: 999px;
  display: block;
}
.toggle-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
}
.toggle-glyph-exclusive::before,
.toggle-glyph-exclusive::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 1.8px;
  background: currentColor;
  border-radius: 999px;
}
.toggle-glyph-exclusive::before { transform: rotate(45deg); }
.toggle-glyph-exclusive::after { transform: rotate(-45deg); }

.filters-summary-toggle {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filters-summary-toggle:hover,
.filters-summary-toggle[aria-expanded="true"] {
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--text);
}
.filters-summary-toggle.has-filters {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.35);
}

.active-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  justify-content: flex-start;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
  cursor: default;
  white-space: nowrap;
}

.filter-chip .remove-filter {
  cursor: pointer;
  opacity: 0.6;
  font-size: 0.8rem;
  line-height: 1;
}
.filter-chip .remove-filter:hover { opacity: 1; }

.filter-chip.chip-exclude {
  border-color: var(--negative);
  color: var(--negative);
  background: rgba(248, 81, 73, 0.08);
}

.filter-chip.chip-auto {
  opacity: 0.75;
  border-style: dashed;
}

.filter-chip.chip-country { border-color: var(--text-dim); color: var(--text-dim); background: rgba(139,148,158,0.08); }
.filter-chip.chip-domain  { border-color: var(--accent);   color: var(--accent); }
.filter-chip.chip-register { border-color: #d29922; color: #d29922; background: rgba(210,153,34,0.08); font-style: italic; }

/* ── Groups grid ── */
.groups-grid {
  column-count: 2;
  column-gap: 10px;
  margin-bottom: 16px;
}

/* Story group cards */
.story-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: inline-flex;
  flex-direction: column;
  min-height: 100px;
  cursor: pointer;
  transition: border-color 0.15s;
  min-width: 0;
  overflow: hidden;
  width: 100%;
  margin: 0 0 10px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}
.story-group:hover {
  border-color: rgba(88, 166, 255, 0.35);
}

/* Register colour on border-top */
.story-group.register-alert      { border-top-color: #f85149; }
.story-group.register-concern    { border-top-color: #d29922; }
.story-group.register-analysis   { border-top-color: #a371f7; }
.story-group.register-awareness  { border-top-color: #8b949e; }
.story-group.register-curiosity  { border-top-color: #3fb950; }
.story-group.register-reflection { border-top-color: #79c0ff; }

.group-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.group-headline {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.group-count {
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}

.group-footer {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.group-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.group-expand-indicator {
  font-size: 0.6rem;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  display: inline-block;
  line-height: 1;
}
.story-group.open .group-expand-indicator {
  transform: rotate(90deg);
}

/* Expandable article list inside group */
.group-articles {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.group-article-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(139, 148, 158, 0.08);
  font-size: 0.78rem;
  color: var(--text-dim);
  min-width: 0;
}
.group-article-row:last-child { border-bottom: none; }

.ga-source-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 76px;
  min-width: 0;
}

.group-article-row .ga-source {
  font-size: 0.68rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
}

.ga-source-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.ga-intensity-chip {
  flex-shrink: 0;
  font-size: 0.62rem;
}

.group-article-row .ga-title {
  flex: 1;
  color: var(--text);
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
  line-height: 1.3;
}
.group-article-row .ga-title:hover {
  color: var(--accent);
}

.ga-time {
  font-size: 0.62rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Drag mode ── */
.drag-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}
.drag-toggle:hover {
  border-color: rgba(88, 166, 255, 0.4);
  color: var(--text);
}
.drag-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.06);
}

.drag-mode .article-card { cursor: grab; }
.drag-mode .article-card:active { cursor: grabbing; }

.article-card.dragging {
  opacity: 0.4;
  transform: scale(0.97);
  border-color: var(--accent);
}

/* Drag overlay */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
  pointer-events: none;
}

/* ── Group sidebar ── */
.group-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.group-sidebar.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 400;
}

.sidebar-groups {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-group-slot {
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: border-color 0.15s, background 0.15s;
}
.sidebar-group-slot.drag-over {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.06);
}
.sidebar-group-slot .slot-headline {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}
.sidebar-group-slot .slot-count {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.sidebar-new {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-new .btn {
  width: 100%;
  text-align: center;
}

/* ── Reader modal ── */
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.reader-panel {
  position: relative;
  width: min(680px, 92vw);
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 0;
}

.reader-meta-line {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.reader-source {
  font-weight: 600;
  color: var(--accent);
}

.reader-close {
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
}
.reader-close:hover {
  background: rgba(139, 148, 158, 0.1);
  color: var(--text);
}

.reader-title {
  margin: 12px 20px 8px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.reader-tags {
  display: flex;
  gap: 6px;
  padding: 0 20px 12px;
  flex-wrap: wrap;
}

.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text);
}
.reader-body p { margin: 0 0 1em; }

.reader-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  text-align: right;
}

.reader-external-link {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
}
.reader-external-link:hover {
  color: var(--accent);
}

/* ── Brief responsive ── */
@media (max-width: 600px) {
  .meta-bar { gap: 10px; font-size: 0.75rem; }
  .article-card { padding: 12px 14px; }

  .filter-row-primary {
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-search {
    flex: 1 1 calc(100% - 126px);
    min-width: 0;
  }
  .exclude-toggle,
  .filter-select--age {
    flex: 0 0 auto;
  }
  .filter-row-primary .filter-select:not(.filter-select--age) {
    flex: 1 1 calc(25% - 6px);
  }
  .filters-summary-toggle {
    flex: 1 1 calc(25% - 6px);
    margin-left: 0;
  }

  .groups-grid {
    column-count: 1;
    column-gap: 0;
  }
  .group-sidebar { width: 260px; }
  .reader-panel { width: 98vw; max-height: 95vh; border-radius: 8px; }
}
