:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #9ca3af;
  --accent: #2563eb;
  --focus: rgba(37, 99, 235, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Page Shell ── */

.page-shell {
  width: min(880px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

/* ── Header ── */

.page-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.page-copy h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.page-description {
  max-width: 50ch;
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-soft);
}

.page-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.hero-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--text);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.12);
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.hero-star:hover {
  text-decoration: none;
  transform: translateY(-1px);
  background: var(--text-soft);
  border-color: var(--text-soft);
  color: var(--bg);
}

.hero-star-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}

.hero-star-secondary:hover {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.page-kicker {
  display: none;
}

.page-meta {
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-shrink: 0;
}

.page-meta li {
  text-align: center;
}

.meta-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.meta-label {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Controls ── */

.controls-shell {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: 16px;
  padding: 12px 0 14px;
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.controls-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-label,
.section-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.search-field {
  flex: 1;
  display: grid;
  gap: 0;
}

.search-field .field-label {
  display: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.filters-toggle {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.filters-toggle:hover {
  background: var(--surface-muted);
}

.filters-toggle:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

/* ── Quick Filters ── */

.quick-filters {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.quick-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.quick-chip:hover {
  border-color: var(--text-soft);
  color: var(--text-soft);
}

.quick-chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.quick-chip.is-active:hover {
  background: var(--text-soft);
  border-color: var(--text-soft);
}

.quick-chip:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

/* ── Filters Panel ── */

.filters-panel {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.js-enabled .filters-panel {
  display: none;
}

.js-enabled .filters-panel.is-open {
  display: block;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.filter-control {
  display: grid;
  gap: 6px;
}

.filter-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 16px,
    calc(100% - 11px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  transition: border-color 150ms ease;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.tag-filter-group {
  margin-top: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag-chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.tag-chip:hover {
  background: var(--surface-muted);
}

.tag-chip.is-active {
  background: var(--focus);
  border-color: var(--accent);
  color: var(--accent);
}

.tag-chip:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

/* ── Results Bar ── */

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.results-summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.clear-filters {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.clear-filters:hover {
  background: var(--surface-muted);
}

.clear-filters:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

/* ── Feed ── */

.feed-shell {
  margin-top: 24px;
}

.timeline-root {
  display: grid;
  gap: 32px;
}

/* ── Sections ── */

.feed-section {
  display: grid;
  gap: 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.section-count {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Timeline Stack ── */

.section-stack {
  position: relative;
  display: grid;
  gap: 0;
}

.section-stack::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 76px;
  width: 1px;
  background: var(--border);
}

/* ── Milestone Card ── */

.milestone-card {
  position: relative;
  border-bottom: 1px solid var(--border-light);
}

.milestone-shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 20px;
  padding: 10px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.milestone-shell:hover {
  background: rgba(0, 0, 0, 0.015);
}

.milestone-shell:active {
  background: rgba(0, 0, 0, 0.03);
}

@media (hover: none) {
  .milestone-shell:hover {
    background: transparent;
  }
}

.js-enabled .milestone-card {
  opacity: 0;
  transform: translateY(8px);
}

.js-enabled .milestone-card.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 280ms ease, transform 280ms ease;
}

/* ── Date Rail ── */

.milestone-rail {
  position: relative;
  padding-top: 2px;
}

.milestone-rail::after {
  content: "";
  position: absolute;
  top: 10px;
  right: -6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent));
  box-shadow: 0 0 0 3px var(--bg);
}

.milestone-date {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  color: var(--text-muted);
}

.milestone-date-main {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.milestone-date-year {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ── Milestone Content ── */

.milestone-main {
  min-width: 0;
}

.milestone-header {
  display: grid;
  gap: 0;
}

.milestone-meta {
  display: none;
}

.milestone-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.milestone-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.milestone-org {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  text-decoration: none;
}

.milestone-org:hover {
  color: var(--text);
  text-decoration: underline;
}

.milestone-organization {
  display: none;
}

.signal-pill {
  display: none;
}

.detail-toggle {
  display: none;
}

/* ── Expanded Details ── */

.milestone-details {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  will-change: grid-template-rows, opacity;
  /* Collapse: height shrinks over 250ms, opacity drops immediately */
  transition:
    grid-template-rows 250ms cubic-bezier(0.4, 0, 1, 1),
    opacity 150ms ease;
}

.milestone-details-inner {
  min-height: 0;
  overflow: hidden;
}

.milestone-card.is-expanded .milestone-details {
  grid-template-rows: 1fr;
  opacity: 1;
  /* Expand: height grows over 380ms with gentle ease-out,
     opacity fades in AFTER height is mostly done */
  transition:
    grid-template-rows 380ms cubic-bezier(0, 0, 0.2, 1),
    opacity 200ms ease 180ms;
}

.milestone-card.is-expanded .milestone-shell {
  background: transparent;
}

.detail-block {
  padding-top: 12px;
}

.detail-block-intro {
  margin-top: 8px;
}

.detail-block + .detail-block {
  margin-top: 10px;
}

.detail-block h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-block p {
  margin: 0;
  max-width: 65ch;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-soft);
}

.detail-list,
.source-list {
  margin: 0;
  padding-left: 16px;
  font-size: 14px;
  color: var(--text-soft);
}

.detail-list li + li,
.source-list li + li {
  margin-top: 4px;
}

.source-list a {
  font-size: 13px;
}

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

.milestone-tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

/* ── Footer ── */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.footer-credit a {
  color: var(--text-soft);
  font-weight: 500;
}

.footer-credit a:hover {
  color: var(--text);
}

.footer-links {
  display: flex;
  gap: 6px;
}

.footer-links a {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  transition: border-color 150ms ease, color 150ms ease;
}

.footer-links a:hover {
  border-color: var(--text-soft);
  color: var(--text-soft);
  text-decoration: none;
}

/* ── Organization Pages ── */

.org-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.org-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.04);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.org-card:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.25);
  box-shadow: 0 14px 26px rgba(17, 24, 39, 0.07);
  text-decoration: none;
}

.org-card h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.org-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.org-card-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.org-milestone-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.org-milestone {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.04);
}

.org-milestone-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.org-milestone-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.org-milestone-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.org-milestone-date {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.org-milestone-summary {
  margin: 12px 0 0;
  color: var(--text-soft);
}

.org-highlights {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--text);
}

.org-tags {
  margin-top: 14px;
}

/* ── Empty State ── */

.empty-state {
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.empty-state h2 {
  margin: 8px 0 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.empty-state p:last-child {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .page-shell {
    width: min(100vw - 24px, 880px);
    padding-top: 20px;
  }

  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-description {
    font-size: 13px;
  }

  /* Keep controls sticky on mobile — search always accessible */
  .controls-shell {
    margin-top: 12px;
    padding: 10px 0 12px;
  }

  /* Search + filter button stay side by side */
  .controls-bar {
    flex-direction: row;
    align-items: center;
  }

  .search-input {
    height: 38px;
    font-size: 14px;
  }

  .filters-toggle {
    height: 38px;
    padding: 0 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .results-bar {
    flex-direction: row;
    align-items: center;
  }

  .results-summary {
    font-size: 12px;
  }

  .section-header {
    flex-direction: row;
    align-items: baseline;
  }

  .section-header h2 {
    font-size: 1.2rem;
  }

  /* Tighter timeline on tablet */
  .section-stack::before {
    left: 64px;
  }

  .milestone-shell {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 16px;
    padding: 12px 0;
  }

  .milestone-title {
    font-size: 0.9rem;
  }

  .site-footer {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .page-shell {
    width: min(100vw - 16px, 880px);
    padding-top: 16px;
  }

  .page-header {
    padding-bottom: 14px;
  }

  .quick-filters {
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .quick-filters::-webkit-scrollbar {
    display: none;
  }

  .quick-chip {
    font-size: 12px;
    padding: 4px 10px;
    flex-shrink: 0;
  }

  .page-copy h1 {
    font-size: 1.5rem;
  }

  .page-description {
    display: none;
  }

  .page-meta {
    gap: 12px;
  }

  .meta-value {
    font-size: 1.1rem;
  }

  .meta-label {
    font-size: 9px;
  }

  /* Hide timeline line on small phones */
  .section-stack::before {
    display: none;
  }

  /* Single column layout — date inline with title */
  .milestone-shell {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 12px 4px;
  }

  .milestone-rail {
    padding-top: 0;
  }

  .milestone-rail::after {
    display: none;
  }

  /* Date as inline row with colored dot */
  .milestone-date {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .milestone-date::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dot-color, var(--accent));
    flex-shrink: 0;
  }

  .milestone-date-main {
    font-size: 12px;
  }

  .milestone-date-year {
    font-size: 10px;
  }

  .milestone-title {
    font-size: 0.88rem;
  }

  .milestone-org {
    font-size: 12px;
  }

  /* Touch-friendly expanded details */
  .detail-block p {
    font-size: 13px;
    line-height: 1.55;
  }

  .detail-list,
  .source-list {
    font-size: 13px;
  }

  .milestone-tag {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* Tighter tag chips in filters */
  .tag-chip {
    font-size: 11px;
    padding: 4px 8px;
  }

  .filters-panel {
    padding: 12px;
  }

  .empty-state {
    padding: 32px 16px;
  }

  .empty-state h2 {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .js-enabled .milestone-card {
    opacity: 1;
    transform: none;
  }
}
