/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Keep overflow visible so long content cannot hide layout defects. */
body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: var(--space-4) var(--space-4) var(--space-12);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  width: 100%;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}

.brand-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
}

.brand-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.brand-title span {
  color: var(--color-accent);
}

.lang-switcher-pill {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
}

.lang-opt {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.lang-opt.active {
  background: var(--color-accent);
  color: var(--color-accent-text);
}

/* ==========================================================================
Component 2: Loudness Threshold Controller
At 390px: 4 equal-width segments, short labels, white-space: nowrap
========================================================================== */
.threshold-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.threshold-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
  padding: 0 var(--space-1);
}

.threshold-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

.threshold-segments {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-1);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  width: 100%;
}

.threshold-segment {
  min-width: 0;
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.threshold-segment.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.threshold-label-short {
  display: none;
}

@media (max-width: 420px) {
  .threshold-label-full {
    display: none;
  }
  .threshold-label-short {
    display: inline;
  }
}

/* ==========================================================================
Component 3: Catch-up Badge / Card
Addressing the reader informally
========================================================================== */
.catchup-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  width: 100%;
}
.catchup-icon {
  font-size: var(--text-xl);
  line-height: 1;
  padding-top: 2px;
}
.catchup-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}
.badge-loudness {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1;
}

.badge-loudness svg {
  width: 24px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
}

.badge-loudness-1 {
  color: var(--loudness-1-color);
  background-color: var(--loudness-1-bg);
  border-color: var(--loudness-1-border);
}

.badge-loudness-2 {
  color: var(--loudness-2-color);
  background-color: var(--loudness-2-bg);
  border-color: var(--loudness-2-border);
}

.badge-loudness-3 {
  color: var(--loudness-3-color);
  background-color: var(--loudness-3-bg);
  border-color: var(--loudness-3-border);
}

.badge-loudness-4 {
  color: var(--loudness-4-color);
  background-color: var(--loudness-4-bg);
  border-color: var(--loudness-4-border);
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.event-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.event-card:hover {
  border-color: var(--color-border-hover);
}

.event-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.meta-group-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.topic-tag {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.time-badge {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.event-headline {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.event-headline a {
  color: inherit;
  text-decoration: none;
}

.event-headline a:hover {
  color: var(--color-accent);
}

.event-snippet {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  overflow-wrap: anywhere;
}

.event-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.sources-bubble {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  overflow-wrap: anywhere;
}

/* ==========================================================================
Component 7: Post Block
("what happened / why it matters / what changed")
========================================================================== */
.synthesis-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.synthesis-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1_5);
}

.synthesis-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
}

.synthesis-text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

/* ==========================================================================
Component 8: Timeline with Date & Time
========================================================================== */
.timeline-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
}

.timeline-heading {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.timeline-list {
  list-style: none;
  position: relative;
  padding-left: var(--space-5);
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--space-5) - 5px);
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
  border: 2px solid var(--color-surface);
}

.timeline-time {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.timeline-desc {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

/* ==========================================================================
Component 9: Sources List
========================================================================== */
.sources-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.source-item:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

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

.source-pub {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.source-headline {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

.source-icon {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: var(--space-2_5) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface-subtle);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}
.btn-outline:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-border-hover);
}
.app-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0 var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  width: 100%;
}

.footer-brand {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.footer-brand span {
  color: var(--color-accent);
}

.footer-tagline {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.footer-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* Page composition; component colors, spacing and typography use the design tokens. */
[hidden] { display: none !important; }
.site-container {
  width: 100%;
  max-width: var(--max-w-feed);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}
main, .feed-list, .event-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.app-header { gap: var(--space-3); flex-wrap: wrap; }
.page-heading { font-family: var(--font-serif); font-size: var(--text-2xl); }
.event-card .event-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.event-intro .event-headline { font-size: var(--text-3xl); }
.event-lead { color: var(--color-text-secondary); line-height: var(--leading-relaxed); }
.event-detail { overflow-wrap: anywhere; }
.event-meta-top, .meta-group-left, .event-card-bottom { min-width: 0; flex-wrap: wrap; }
.sound-wave { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.catchup-card { justify-content: flex-start; }
.catchup-count { margin-inline-start: auto; font-weight: var(--weight-bold); }
.new-marker {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.empty-state {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-8) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  color: var(--color-text-secondary);
}
.empty-icon { font-size: var(--text-3xl); }
.facts-list { padding-inline-start: var(--space-5); }
.facts-list li + li { margin-top: var(--space-2); }
.sources-list { list-style: none; }
.source-pub { overflow-wrap: anywhere; }
.version-label { font-size: var(--text-xs); font-weight: var(--weight-bold); }
.back-link { font-size: var(--text-sm); color: var(--color-accent); align-self: flex-start; }
.pagination { align-self: center; }
a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
@media (max-width: 420px) {
  .lang-opt { padding-inline: var(--space-2); }
  .event-intro .event-headline { font-size: var(--text-2xl); }
}
