/* 24H CIRCLE — printed-sheet palettes. Each theme is one paper, one ink and
   three accents (mutual / inbound / outbound); the canvas reads the same names
   from circle.js, so the poster and the page always match. */

:root,
:root[data-theme="paper"] {
  --paper: #efe8da;
  --paper-2: #e7dfcf;
  --ink: #191410;
  --muted: #6d6152;
  --rule: rgba(25, 20, 16, 0.16);
  --rule-soft: rgba(25, 20, 16, 0.08);
  --both: #b4452b;
  --in: #2c5748;
  --out: #a1712a;
  --grain-blend: multiply;
  --grain-opacity: 0.5;
}

:root[data-theme="sage"] {
  --paper: #e6e9dd;
  --paper-2: #dbe0cd;
  --ink: #161a12;
  --muted: #5c6452;
  --rule: rgba(22, 26, 18, 0.16);
  --rule-soft: rgba(22, 26, 18, 0.08);
  --both: #a8452c;
  --in: #38543a;
  --out: #8a6a2c;
  --grain-blend: multiply;
  --grain-opacity: 0.5;
}

:root[data-theme="slate"] {
  --paper: #e6e7e6;
  --paper-2: #dcdedd;
  --ink: #141719;
  --muted: #5a6064;
  --rule: rgba(20, 23, 25, 0.16);
  --rule-soft: rgba(20, 23, 25, 0.08);
  --both: #a8452c;
  --in: #2b4a63;
  --out: #8a6a2c;
  --grain-blend: multiply;
  --grain-opacity: 0.5;
}

:root[data-theme="pink"] {
  --paper: #f4e6e5;
  --paper-2: #ecd8d8;
  --ink: #1b1213;
  --muted: #6c5356;
  --rule: rgba(27, 18, 19, 0.16);
  --rule-soft: rgba(27, 18, 19, 0.08);
  --both: #a93b4f;
  --in: #3f5a54;
  --out: #9a6a3a;
  --grain-blend: multiply;
  --grain-opacity: 0.5;
}

:root[data-theme="ink"] {
  --paper: #0e1420;
  --paper-2: #161e2c;
  --ink: #e8ecf1;
  --muted: #8d97a6;
  --rule: rgba(232, 236, 241, 0.18);
  --rule-soft: rgba(232, 236, 241, 0.09);
  --both: #d0704a;
  --in: #7ba7b8;
  --out: #cfa25e;
  --grain-blend: screen;
  --grain-opacity: 0.22;
}

:root {
  --sans: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E");
  mix-blend-mode: var(--grain-blend);
}


/* ---------- masthead ---------- */

.masthead {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 32px 0;
}

.mast {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 12px;
}

.foot-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.foot-link:hover {
  border-bottom-color: var(--ink);
}

.mast > .themes:last-child {
  margin-left: auto;
}

.theme-set {
  display: flex;
  align-items: center;
  gap: 10px;
}

.foot-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-right: 2px;
}

.themes {
  display: flex;
  align-items: center;
  gap: 9px;
}

.foot-end {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.swatch {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink);
}

.swatch[data-theme-pick="paper"] { background: #efe8da; }
.swatch[data-theme-pick="sage"] { background: #e6e9dd; }
.swatch[data-theme-pick="slate"] { background: #e6e7e6; }
.swatch[data-theme-pick="pink"] { background: #f4e6e5; }
.swatch[data-theme-pick="ink"] { background: #0e1420; }

.mark {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.24em;
  font-weight: 600;
}

.mast-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.tagline {
  margin: 18px 0 0;
  font-size: 16px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(38px, 6.4vw, 76px);
  line-height: 1.06;
  letter-spacing: -0.01em;
  margin: 44px 0 0;
  max-width: 12em;
}

.lede {
  margin: 22px 0 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 17px;
}

.hero-side {
  position: absolute;
  right: 32px;
  top: 190px;
  display: none;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  opacity: 0.85;
}

.hero-side-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--muted);
  writing-mode: vertical-rl;
}

@media (min-width: 1040px) {
  .hero-side {
    display: flex;
  }
}

/* ---------- query ---------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

.query {
  margin: 46px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--rule);
}

.query label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.field {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 8px;
  border-bottom: 2px solid var(--ink);
  max-width: 620px;
}

.at {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--muted);
  padding-right: 8px;
}

.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 600;
  padding: 6px 0 8px;
  outline: none;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.55;
  font-weight: 400;
}

.field button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  padding: 9px 20px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.field button:hover {
  transform: translateY(-1px);
}

.field button:disabled {
  opacity: 0.75;
  cursor: progress;
  transform: none;
}

/* a ring that turns while the x.com round trip runs */
.field button.is-busy::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .field button.is-busy::before {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.6;
  }
}

.refresh-link {
  margin-left: 8px;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  background: none;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.refresh-link:hover {
  color: var(--muted);
}

.refresh-link:disabled {
  opacity: 0.4;
  cursor: progress;
}

.samples-link {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0 0 2px;
  cursor: pointer;
}

.samples-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.hint,
.status {
  font-size: 13.5px;
  color: var(--muted);
  margin: 12px 0 0;
  max-width: 40em;
}

.status {
  min-height: 1.6em;
  font-family: var(--mono);
  font-size: 12.5px;
}

.status.is-error {
  color: var(--both);
}

/* ---------- result ---------- */

.result[hidden] {
  display: none;
}

.result {
  margin-top: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
  align-items: start;
}

.poster {
  margin: 0;
}

.poster canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  cursor: crosshair;
}

.poster figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.poster figcaption button {
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.poster figcaption button:hover {
  border-color: var(--ink);
}

.poster figcaption button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.poster figcaption .meta {
  margin-left: auto;
}

/* ---------- panel ---------- */

.tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}

.tab {
  border: 0;
  background: none;
  padding: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.is-on {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.counts .coverage {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule-soft);
}

.counts button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* the tint needs room to breathe without shifting the numbers */
  margin: -8px -10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 2px;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.counts button b {
  color: var(--ink);
  opacity: 0.72;
  transition: color 0.14s ease, opacity 0.14s ease;
}

.counts button:hover b {
  color: var(--ink);
}

/* the selected slice: tinted cell, full-strength number, ink rule underneath */
.counts button[aria-pressed="true"] {
  background: var(--paper-2);
  box-shadow: inset 0 -2px 0 var(--ink);
}

.counts button[aria-pressed="true"] b {
  opacity: 1;
}

.counts button[aria-pressed="true"] span {
  color: var(--ink);
}

.counts b {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}

.counts span {
  font-size: 12px;
  color: var(--muted);
}

.people {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  max-height: 560px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.people li button {
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.people li button:hover,
.people li button.is-on {
  background: var(--paper-2);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  justify-self: center;
}

.people .who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.people .who small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
}

.people .n {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.detail h3 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 2px;
}

.detail .sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.detail .badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  margin-right: 6px;
}

.samples {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.samples li {
  border-left: 2px solid var(--rule);
  padding-left: 12px;
}

.samples p {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.samples time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.samples a {
  color: inherit;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- notes / footer ---------- */

.notes {
  margin-top: 70px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  max-width: 46em;
}

.notes h2 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 12px;
  text-transform: uppercase;
}

.notes ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 15px;
}

.notes li {
  margin-bottom: 6px;
}

.c-both {
  color: var(--both);
}

.c-in {
  color: var(--in);
}

.c-out {
  color: var(--out);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 2px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-on {
  opacity: 0.96;
  transform: translate(-50%, 0);
}

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 32px 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  letter-spacing: 0.2em;
  white-space: nowrap;
}

/* ---------- responsive ---------- */

@media (max-width: 940px) {
  .result {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .people {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .masthead,
  main,
  .toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 2px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-on {
  opacity: 0.96;
  transform: translate(-50%, 0);
}

.foot {
    padding-left: 20px;
    padding-right: 20px;
  }

  .mast-note {
    display: none;
  }

  .field input {
    font-size: 22px;
  }

  .poster figcaption .meta {
    margin-left: 0;
    width: 100%;
  }

  h1 {
    margin-top: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
