:root {
  --bg: #f7f7f4;
  --ink: #242323;
  --muted: #65625d;
  --line: #dad8d1;
  --card: #ffffff;
  --soft: #f0f1ed;
  --topic: #1661a8;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Onest, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body.detail-open { overflow: hidden; }

button,
a { font: inherit; }

main {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

@media (min-width: 1280px) {
  main { width: min(1320px, calc(100% - 48px)); }
}

.page-header { margin-top: 20px; }

.title-row { display: block; }

h1 {
  max-width: 15ch;
  margin: 0;
  font-size: 4rem;
  font-weight: 780;
  line-height: .98;
}

.intro {
  max-width: 62ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.52;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  min-height: 18px;
  margin: 16px 0 11px;
  color: var(--muted);
  font-size: .8rem;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--category-color);
}

.legend-label { color: var(--muted); }

.swatch {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.method-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.45;
}

.method-row > p { margin: 0; }

.methodology { flex: none; }

.methodology summary {
  display: flex;
  width: max-content;
  min-height: 30px;
  align-items: center;
  padding: 6px 0;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
}

.methodology summary:focus-visible {
  outline: 3px solid rgba(22, 97, 168, .25);
  outline-offset: 2px;
}

.methodology-body {
  max-width: 78ch;
  margin: 8px 0 4px;
  color: var(--muted);
}

.methodology[open] {
  flex: 1 0 100%;
  order: 3;
}

.method-row:has(.methodology[open]) { flex-wrap: wrap; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(270px, .45fr);
  align-items: start;
  gap: 22px;
  margin-top: 14px;
}

.cloud-panel {
  min-width: 0;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.cloud {
  position: relative;
  display: grid;
  gap: clamp(2px, .45vw, 7px);
  width: 100%;
  min-width: 0;
  min-height: 320px;
  padding: clamp(14px, 2.2vw, 26px) 0 clamp(18px, 2.8vw, 34px);
  overflow: visible;
  isolation: isolate;
}

.cloud[aria-busy="false"] { min-height: 0; }

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  transform: translate(-50%, -50%);
}

.tag {
  --tag-size: 16px;
  --tag-bg: transparent;
  position: relative;
  display: block;
  width: auto;
  max-width: min(100%, 15ch);
  padding: 3px;
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--tag-color, var(--ink));
  font-size: var(--tag-size);
  font-weight: 700;
  line-height: .96;
  text-align: center;
  text-decoration: none;
  text-wrap: balance;
  white-space: normal;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .14s ease, box-shadow .14s ease, color .14s ease, transform .14s ease;
}

.tag-name { display: block; }

.tag:hover { --tag-bg: color-mix(in srgb, currentColor 8%, transparent); }

.tag:focus-visible {
  outline: 3px solid color-mix(in srgb, currentColor 35%, white);
  outline-offset: 2px;
}

.tag.on {
  --tag-bg: color-mix(in srgb, currentColor 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 30%, transparent);
}

.cloud-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 1px clamp(3px, .35vw, 6px);
  width: 100%;
}

.details {
  position: sticky;
  top: 14px;
  min-width: 0;
}

.detail-card {
  max-height: min(calc(100svh - 28px), 520px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  overscroll-behavior: contain;
}

.placeholder {
  display: flex;
  min-height: 104px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.5;
}

.placeholder[hidden] { display: none; }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.category {
  margin-bottom: 5px;
  color: var(--topic);
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.35;
}

.detail-head h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.02;
}

.frequency {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .79rem;
}

.close {
  display: grid;
  flex: none;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.close:hover { background: var(--soft); }

.close:focus-visible {
  outline: 3px solid rgba(22, 97, 168, .25);
  outline-offset: 2px;
}

.quotes {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.quotes blockquote {
  margin: 0;
  padding: 13px 14px 14px 16px;
  border-left: 3px solid var(--topic);
  border-radius: 0 8px 8px 0;
  background: var(--soft);
  font-size: .98rem;
  line-height: 1.58;
}

.related {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.related-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .73rem;
}

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

.related-links a {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: .79rem;
  font-weight: 650;
  text-decoration: none;
}

.related-links a:hover { background: var(--soft); }

.privacy-note {
  margin: 11px 2px 0;
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.45;
}

.scrim,
.scrim[hidden] { display: none; }

.footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.45;
}

.footer a {
  color: inherit;
  text-underline-offset: 3px;
}

@media (max-width: 1279px) {
  main {
    width: min(100% - 32px, 1120px);
    padding: 16px 0 34px;
  }

  .stage {
    display: block;
    margin-top: 8px;
  }

  .tag { max-width: min(100%, 20ch); }

  .details {
    position: fixed;
    z-index: 50;
    inset: 0 0 0 auto;
    display: none;
    width: min(430px, 100%);
    max-height: 100svh;
    overflow-y: auto;
    padding: 18px;
    background: var(--card);
    overscroll-behavior: contain;
  }

  .details[data-open="1"] { display: block; }

  .detail-card {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 18px;
    border-radius: 8px;
  }

  .scrim {
    position: fixed;
    z-index: 49;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(36, 35, 35, .28);
    cursor: pointer;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 20px, 600px);
    padding-top: 10px;
  }

  .page-header { margin-top: 12px; }

  h1 {
    max-width: 17ch;
    font-size: 2.25rem;
  }

  .intro {
    max-width: 54ch;
    margin-top: 9px;
    font-size: .94rem;
  }

  .legend {
    gap: 7px 13px;
    margin: 12px 0 8px;
  }

  .method-row { display: block; }

  .cloud {
    gap: 2px;
    padding: 14px 0 22px;
  }

  .details {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: min(88svh, 760px);
    padding: 10px max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    border-radius: 10px 10px 0 0;
  }

  .detail-card {
    height: auto;
    max-height: none;
    padding: 14px;
  }

  .placeholder { min-height: 0; }

  .detail-head h2 { font-size: 1.42rem; }

  .quotes blockquote {
    font-size: .97rem;
    line-height: 1.55;
  }

  .footer { margin-top: 14px; }
}

@media (min-width: 641px) and (max-width: 660px) {
  h1 { font-size: 3.75rem; }
}

@media (max-width: 430px) {
  .legend {
    display: grid;
    grid-template-columns: 1fr;
  }

}

@media (max-width: 389px) {
  h1 { font-size: 2.1rem; }

}

@media (max-width: 360px) {
  h1 { font-size: 1.8rem; }
}

@media (hover: hover) and (pointer: fine) {
  .tag:hover {
    z-index: 1;
    transform: translateY(-2px) scale(1.025);
  }
}

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