/* ==========================================================
   DEEP WATER — PUBLIC RESEARCH ARCHIVE (index + intro)
   Clean, modern index that mirrors the report page tokens
   (web/research-report.css). White surface, slim brand bar,
   blue accents, soft cards — no typewriter/manila theme.
   ========================================================== */

/* A few bare/compound `a`/`strong` rules in later sections have lower
   specificity than earlier ones; the cascade is unaffected by the ordering, so
   the specificity-ordering rule is disabled (same approach as
   research-report.css). */
/* stylelint-disable no-descending-specificity */

:root {
  --dw-bg: #f6f8fb;
  --dw-surface: #fff;
  --dw-surface-muted: #f0f0f2;
  --dw-border: #e7e8ec;
  --dw-border-strong: #d9dbe1;
  --dw-text-strong: #1a1b1f;
  --dw-text: #2c2e35;
  --dw-text-muted: #6f737c;
  --dw-text-soft: #a4a6ae;
  --dw-blue: #3f72c9;
  --dw-blue-bright: #6ba3fb;
  --dw-blue-tint: rgb(107 163 251 / 8%);
  --dw-blue-tint-strong: rgb(107 163 251 / 16%);
  --dw-font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', roboto, sans-serif;
  --dw-mono: ui-monospace, sfmono-regular, 'SF Mono', menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--dw-font);
  color: var(--dw-text);
  background: var(--dw-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizelegibility;
}

a {
  color: var(--dw-blue);
}

/* ── Top brand bar (matches report page) ── */
.dw-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgb(255 255 255 / 86%);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--dw-border);
}

.dw-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--dw-text-strong);
  text-decoration: none;
  white-space: nowrap;
}

.dw-brand-mark {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(155deg, var(--dw-blue-bright), var(--dw-blue));
  box-shadow: 0 2px 6px rgb(63 114 201 / 35%);
}

.dw-topbar-actions {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.dw-topbar-actions a {
  color: var(--dw-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.dw-topbar-actions a:hover {
  color: var(--dw-text-strong);
}

@media (width <= 480px) {
  /* The topbar is a flex row whose children cannot shrink (brand and links
     are nowrap so labels never break mid-word). Below the row's natural min
     width the only non-overflowing option is to wrap: the nav drops to a
     second row, so the document never scrolls horizontally regardless of
     which font (Inter or a wider fallback) is active. */
  .dw-topbar {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 12px 16px;
  }

  .dw-topbar-actions {
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 12px;
  }

  .dw-topbar-actions a {
    white-space: nowrap;
  }
}

/* ── Shell ── */
.dw-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* ── Archive header ── */
.dw-archive-header {
  margin-bottom: 30px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--dw-border);
}

.dw-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dw-blue);
  margin-bottom: 12px;
}

.dw-archive-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--dw-text-strong);
  margin: 0 0 12px;
}

.dw-archive-lead {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--dw-text-muted);
  margin: 0 0 18px;
  max-width: 64ch;
}

.dw-stats-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 13px;
  color: var(--dw-text-muted);
}

.dw-stats-line .dw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
}

.dw-stats-line .dw-chip strong {
  color: var(--dw-text-strong);
  font-weight: 700;
}

/* ── Controls row ── */
.dw-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.dw-segmented {
  display: flex;
  flex: 1 0 100%;
  flex-direction: row;
  gap: 0;
  width: 100%;
  margin-bottom: 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--dw-border);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dw-segmented::-webkit-scrollbar {
  display: none;
}

.dw-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--dw-text-muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.dw-pill:hover {
  color: var(--dw-text);
  border-bottom-color: var(--dw-border);
}

.dw-pill.is-active {
  color: var(--dw-text-strong);
  font-weight: 600;
  border-bottom-color: var(--dw-blue);
}

.dw-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--dw-surface-muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--dw-text-soft);
}

.dw-controls-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.dw-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
  border-radius: 10px;
}

.dw-sort-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dw-text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.dw-sort-link:hover {
  color: var(--dw-text-strong);
}

.dw-sort-link.is-active {
  color: var(--dw-text-strong);
  background: var(--dw-surface-muted);
}

.dw-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  padding: 0 14px;
  height: 40px;
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dw-search:focus-within {
  border-color: var(--dw-blue-bright);
  box-shadow: 0 0 0 3px var(--dw-blue-tint);
}

.dw-search svg {
  flex: none;
  color: var(--dw-text-soft);
}

.dw-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--dw-text);
}

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

/* ── Card grid ── */
.dw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.dw-card {
  display: flex;
  flex-direction: column;
  min-height: 168px;
  padding: 20px;
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.dw-card:hover {
  border-color: var(--dw-blue);
  box-shadow: 0 4px 16px rgb(15 23 42 / 12%), 0 1px 4px rgb(15 23 42 / 8%);
}

.dw-card-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dw-text-muted);
  margin-bottom: 10px;
}

.dw-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--dw-text-strong);
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dw-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: auto;
  font-size: 12.5px;
  color: var(--dw-text-muted);
}

.dw-card-meta .dw-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--dw-text-soft);
}

.dw-card-meta strong {
  font-weight: 700;
  color: var(--dw-text-strong);
}

/* ── Empty state ── */
.dw-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 32px;
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
  border-radius: 16px;
}

.dw-empty h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--dw-text-strong);
}

.dw-empty p {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--dw-text-muted);
  max-width: 44ch;
}

.dw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.dw-btn-primary {
  color: #fff;
  background: linear-gradient(155deg, var(--dw-blue-bright), var(--dw-blue));
  box-shadow: 0 6px 16px rgb(63 114 201 / 28%);
}

.dw-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgb(63 114 201 / 34%);
}

.dw-btn-secondary {
  color: var(--dw-text-muted);
  background: var(--dw-surface);
  border: 1px solid var(--dw-border);
}

.dw-btn-secondary:hover {
  color: var(--dw-text-strong);
  border-color: var(--dw-border-strong);
}

/* ── Footer ── */
.dw-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 56px;
  font-size: 12.5px;
  color: var(--dw-text-soft);
  border-top: 1px solid var(--dw-border);
  text-align: center;
}

.dw-footer a {
  color: var(--dw-text-muted);
  text-decoration: none;
  font-weight: 600;
}

.dw-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-top: 10px;
}

/* ── Intro page (deepwater.live/research) ── */
.dw-intro {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.dw-intro-inner {
  max-width: 620px;
  text-align: center;
}

.dw-intro-title {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--dw-text-strong);
  margin: 0 0 16px;
}

.dw-intro-lead {
  font-size: 16px;
  line-height: 1.7;
  color: var(--dw-text-muted);
  margin: 0 auto 32px;
  max-width: 52ch;
}

.dw-intro-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* Match the report page's <=640px shell tightening (research-report.css) so
   phones get the same 16px gutters on both pages. */
@media (width <= 640px) {
  .dw-shell {
    padding: 32px 16px 64px;
  }

  .dw-footer {
    padding: 28px 16px 56px;
  }
}

@media (width <= 560px) {
  .dw-controls-right {
    margin-left: 0;
    width: 100%;
  }

  /* The segmented sort control's min content width ("Newest / Most sources /
     Longest") is what pushed 320px viewports into horizontal document scroll.
     Tighter link padding lets it fit at 320px; overflow-x keeps anything
     narrower scrolling INSIDE the control (scrollbar hidden, same convention
     as .dw-segmented) instead of widening the document. */
  .dw-sort {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .dw-sort::-webkit-scrollbar {
    display: none;
  }

  .dw-sort-link {
    padding: 6px 10px;
  }

  .dw-search {
    width: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --dw-bg: #0f1117;
    --dw-surface: #181a22;
    --dw-surface-muted: #1f2130;
    --dw-border: #2a2d3a;
    --dw-border-strong: #3a3d4d;
    --dw-text-strong: #f0f1f5;
    --dw-text: #c8cad4;
    --dw-text-muted: #7b7f8e;
    --dw-text-soft: #555870;
    --dw-blue: #5d8fef;
    --dw-blue-bright: #7aa8f7;
  }

  .dw-topbar {
    background: rgb(15 17 23 / 88%);
  }

  .dw-card:hover {
    box-shadow: 0 4px 20px rgb(0 0 0 / 40%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dw-card,
  .dw-btn {
    transition: none;
  }

  .dw-btn-primary:hover {
    transform: none;
  }
}
