/*
 * Site chrome injected into every article: a slim top bar and a site footer.
 * Deliberately minimal — each article carries its own design, and the chrome
 * must not compete with it.
 */

.site-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px clamp(16px, 4vw, 34px);
  background: rgba(251, 250, 246, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line, #d2d8d2);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}

.site-bar a { text-decoration: none; }

.site-bar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink, #172226);
}

/* 32px keeps the tile clearly legible in a slim bar — below ~24px the
   inner flame stops reading and the mark turns into an amber blob. */
.site-bar-mark {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}
.site-bar-mark svg { display: block; width: 100%; height: 100%; }

.site-bar-word { font-size: 1.02rem; }
.site-bar-word .ai { color: var(--green, #176b52); }
.site-bar-word .tld { color: var(--muted, #526166); font-weight: 600; }

.site-bar-brand:hover .site-bar-word { color: var(--blue, #315f78); }
.site-bar-brand:hover .ai { color: var(--blue, #315f78); }

@media (max-width: 560px) {
  .site-bar-word .tld { display: none; }
}

.site-bar-nav { display: flex; align-items: center; gap: 18px; }
.site-bar-nav a { color: var(--muted, #526166); }
.site-bar-nav a:hover { color: var(--blue, #315f78); }

.site-foot {
  padding: 30px clamp(16px, 4vw, 34px) 44px;
  color: var(--faint, #718086);
  text-align: center;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.84rem;
}
.site-foot a { color: inherit; }

@media print {
  .site-bar, .site-foot, .cw { display: none; }
}

/*
 * Discussion widget.
 *
 * Every colour reads the host article's custom properties with a fallback, so
 * the widget adopts each article's palette instead of imposing its own. All
 * class names are cw- prefixed to avoid colliding with hand-written article CSS.
 */

.cw {
  --cw-ink: var(--ink, #172226);
  --cw-muted: var(--muted, #526166);
  --cw-faint: var(--faint, #718086);
  --cw-paper: var(--paper, #fbfaf6);
  --cw-panel: var(--panel, #f2f3ee);
  --cw-panel-strong: var(--panel-strong, #e7ebe4);
  --cw-line: var(--line, #d2d8d2);
  --cw-accent: var(--blue, #315f78);
  --cw-positive: var(--green, #176b52);
  --cw-danger: var(--red, #a03d35);
  --cw-radius: var(--radius, 14px);

  padding: 48px clamp(28px, 8vw, 100px) 56px;
  border-top: 1px solid var(--cw-line);
  color: var(--cw-ink);
  font-family: inherit;
}

.cw h2 {
  font-size: 1.28rem;
  line-height: 1.3;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.cw .cw-sub {
  margin: 0 0 18px;
  color: var(--cw-muted);
  font-size: 0.94rem;
}

.cw-block + .cw-block { margin-top: 44px; }

/* ── Reactions ──────────────────────────────────────────── */

.cw-react-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cw-react {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--cw-line);
  border-radius: 999px;
  background: var(--cw-panel);
  color: var(--cw-ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}

.cw-react:hover:not(:disabled) {
  background: var(--cw-panel-strong);
  border-color: var(--cw-accent);
}

.cw-react:active:not(:disabled) { transform: scale(.97); }

.cw-react[aria-pressed="true"] {
  border-color: var(--cw-accent);
  background: var(--blue-soft, #dde9ef);
  font-weight: 600;
}

.cw-react .cw-emoji { font-size: 1.05rem; line-height: 1; }
.cw-react .cw-n {
  min-width: 1ch;
  color: var(--cw-muted);
  font-variant-numeric: tabular-nums;
}
.cw-react[aria-pressed="true"] .cw-n { color: var(--cw-accent); }

.cw-react:disabled { opacity: .55; cursor: default; }

/* ── Comment list ───────────────────────────────────────── */

.cw-list { list-style: none; margin: 0; padding: 0; }

.cw-item {
  padding: 18px 0;
  border-top: 1px solid var(--cw-line);
}
.cw-item:first-child { border-top: none; }

.cw-replies {
  list-style: none;
  margin: 14px 0 0;
  padding: 0 0 0 22px;
  border-left: 2px solid var(--cw-line);
}
.cw-replies .cw-item { padding: 14px 0 4px; }

.cw-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.cw-author { font-weight: 650; }
.cw-time { color: var(--cw-faint); font-size: 0.84rem; }

.cw-body {
  margin: 0;
  white-space: pre-wrap;   /* keeps the author's paragraphs without allowing HTML */
  overflow-wrap: anywhere;
}

.cw-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cw-react-sm {
  padding: 4px 10px;
  font-size: 0.82rem;
  gap: 6px;
}

.cw-reply-btn {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--cw-accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.cw-reply-btn:hover { border-color: var(--cw-line); background: var(--cw-panel); }

.cw-empty {
  padding: 26px;
  border: 1px dashed var(--cw-line);
  border-radius: var(--cw-radius);
  background: var(--cw-panel);
  color: var(--cw-muted);
  text-align: center;
}

/* ── Form ───────────────────────────────────────────────── */

.cw-form {
  margin-top: 26px;
  padding: 22px;
  border: 1px solid var(--cw-line);
  border-radius: var(--cw-radius);
  background: var(--cw-panel);
}

.cw-form-title { font-weight: 650; margin-bottom: 4px; }

.cw-replying {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--cw-panel-strong);
  font-size: 0.88rem;
}
.cw-replying.is-on { display: flex; }

.cw-cancel {
  border: none;
  background: none;
  color: var(--cw-accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.cw-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 12px;
}
@media (max-width: 620px) { .cw-fields { grid-template-columns: 1fr; } }

.cw-field { display: flex; flex-direction: column; gap: 5px; }
.cw-field label { font-size: 0.84rem; color: var(--cw-muted); }
.cw-field .cw-optional { color: var(--cw-faint); }

.cw input[type="text"],
.cw input[type="email"],
.cw textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cw-line);
  border-radius: 8px;
  background: var(--cw-paper);
  color: var(--cw-ink);
  font: inherit;
  font-size: 0.95rem;
}
.cw textarea { min-height: 130px; resize: vertical; line-height: 1.55; }

.cw input:focus-visible,
.cw textarea:focus-visible,
.cw button:focus-visible {
  outline: 2px solid var(--cw-accent);
  outline-offset: 2px;
}

/* The honeypot must be reachable by bots parsing HTML but invisible and
   unreachable for humans and screen readers. */
.cw-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cw-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.cw-note { color: var(--cw-faint); font-size: 0.82rem; margin: 0; }

.cw-submit {
  padding: 11px 22px;
  border: none;
  border-radius: 999px;
  background: var(--cw-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cw-submit:hover:not(:disabled) { background: var(--cw-positive); }
.cw-submit:disabled { opacity: .6; cursor: default; }

.cw-status {
  margin: 14px 0 0;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}
.cw-status.is-on { display: block; }
.cw-status.is-ok {
  background: var(--green-soft, #dcebe4);
  color: var(--cw-positive);
}
.cw-status.is-error {
  background: var(--red-soft, #f4e1de);
  color: var(--cw-danger);
}

@media (prefers-reduced-motion: reduce) {
  .cw-react { transition: none; }
}
