/* chaotic-monkey.com — site-owned stylesheet.
   theme.css is the capture's own CSS and is not edited. Everything added for
   article pages, hubs, the disclosure block and the search field lives here.
   Bump CSS_V in tools/build_chaotic_monkey.py when this file changes, and read
   the "`?v=` bump can be poisoned by the rolling update" gotcha in CLAUDE.md
   before trusting that the bump took. */

/* ── shared page furniture ───────────────────────────────────────────── */

.cm-wrap { padding: 0 4vw; }

.cm-breadcrumbs {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(0.7rem, 1vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
  padding: 1.5vw 4vw 0;
}
.cm-breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.cm-breadcrumbs li + li::before { content: "/"; margin-right: 0.6rem; color: #bbb; }
.cm-breadcrumbs a { border-bottom: 1px solid transparent; }
.cm-breadcrumbs a:hover { border-bottom-color: #666; }
.cm-breadcrumbs [aria-current] { color: #000; }

/* ── article ─────────────────────────────────────────────────────────── */

.cm-article { max-width: 46rem; margin: 0 auto; padding: 3vw 4vw 5vw; }

.cm-chip {
  display: inline-block;
  font-family: 'Kanit', sans-serif;
  font-size: clamp(0.7rem, 1.1vw, 0.95rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 3px solid #000;
  padding: 0.2rem 0.7rem;
  margin-bottom: 1.2rem;
}
.cm-chip:hover { background: #000; color: #fff; }

.cm-title {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(1.7rem, 4.4vw, 3.2rem);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.04;
  margin-bottom: 1rem;
}
.cm-standfirst {
  font-family: 'Kanit', sans-serif;
  font-weight: 300;
  font-size: clamp(1rem, 1.9vw, 1.45rem);
  line-height: 1.3;
  color: #222;
  margin-bottom: 1.2rem;
}
.cm-meta {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(0.72rem, 1vw, 0.9rem);
  color: #666;
  border-top: 3px solid #000;
  border-bottom: 1px solid #ccc;
  padding: 0.7rem 0;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

.cm-body { font-family: 'Roboto', sans-serif; font-size: 1.0625rem; line-height: 1.72; color: #111; }
.cm-body p { margin-bottom: 1.35rem; }
.cm-body h2 {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(1.25rem, 2.6vw, 1.85rem);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.15;
  margin: 2.6rem 0 1rem;
  padding-top: 1.2rem;
  border-top: 3px solid #000;
}
.cm-body h3 {
  font-family: 'Kanit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.8rem 0 0.7rem;
}
.cm-body a { border-bottom: 1px solid #000; }
.cm-body a:hover { background: #000; color: #fff; border-bottom-color: #000; }
.cm-body strong { font-weight: 700; }
.cm-body em { font-style: italic; }
.cm-body ul, .cm-body ol { margin: 0 0 1.35rem 1.4rem; }
.cm-body li { margin-bottom: 0.5rem; }
.cm-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: #f2f2f2;
  border: 1px solid #ddd;
  padding: 0.08em 0.32em;
}
.cm-body blockquote {
  border-left: 3px solid #000;
  padding: 0.2rem 0 0.2rem 1.2rem;
  margin: 0 0 1.35rem;
  color: #333;
}
.cm-body blockquote p:last-child { margin-bottom: 0; }

/* ── disclosure (automated section) ──────────────────────────────────── */

.cm-disclosure {
  border: 3px solid #000;
  background: #f7f7f7;
  padding: 1.1rem 1.3rem;
  margin: 0 0 2rem;
  font-family: 'Roboto', sans-serif;
  font-size: 0.94rem;
  line-height: 1.6;
  color: #222;
}
.cm-disclosure b {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}
.cm-disclosure a { border-bottom: 1px solid #000; }

/* ── sources ─────────────────────────────────────────────────────────── */

.cm-sources { margin-top: 3rem; padding-top: 1.2rem; border-top: 3px solid #000; }
.cm-sources h2 {
  font-family: 'Kanit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}
.cm-sources ol { list-style: decimal; margin-left: 1.3rem; }
.cm-sources li { margin-bottom: 0.55rem; font-size: 0.93rem; line-height: 1.5; }
.cm-sources a { border-bottom: 1px solid #000; word-break: break-word; }

/* ── related ─────────────────────────────────────────────────────────── */

.cm-related { border-top: 3px solid #000; padding: 2.5vw 4vw 4vw; }
.cm-related h2 {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}
.cm-related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2vw; }
.cm-related-grid .post-card { border-right: 1px solid #ccc; padding-right: 2vw; }
.cm-related-grid .post-card:last-child { border-right: none; padding-right: 0; }
@media (max-width: 768px) {
  .cm-related-grid { grid-template-columns: 1fr; gap: 0; }
  .cm-related-grid .post-card {
    border-right: none; border-bottom: 2px solid #000; padding: 4vw 0;
  }
  .cm-related-grid .post-card:last-child { border-bottom: none; }
}

/* ── hub ─────────────────────────────────────────────────────────────── */

.cm-hub-lede {
  font-family: 'Kanit', sans-serif;
  font-weight: 300;
  font-size: clamp(0.95rem, 1.8vw, 1.4rem);
  line-height: 1.35;
  max-width: 46rem;
  padding: 2vw 4vw 0;
  color: #111;
}
.cm-hub-disclosure { margin: 2vw 4vw 0; max-width: 46rem; }

.cm-search { padding: 2vw 4vw 0; max-width: 46rem; }
.cm-search label {
  display: block;
  font-family: 'Kanit', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  color: #666;
}
.cm-search input {
  width: 100%;
  font-family: 'Roboto', sans-serif;
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  border: 3px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
}
.cm-search input:focus { outline: 3px solid #000; outline-offset: 2px; }
.cm-search-count {
  font-family: 'Kanit', sans-serif;
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.45rem;
  min-height: 1.1em;
}
.post-card[hidden] { display: none !important; }

.cm-empty {
  font-family: 'Kanit', sans-serif;
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  font-weight: 300;
  color: #444;
  padding: 3vw 4vw 5vw;
  max-width: 46rem;
}

/* ── plate (a card with no photograph) ───────────────────────────────── */

.cm-plate {
  width: 100%;
  aspect-ratio: 4/3;
  border: 1px solid #ccc;
  background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2vw 0 1vw;
  overflow: hidden;
}
.cm-plate svg { width: 40%; opacity: 0.2; }

/* ── standalone pages ────────────────────────────────────────────────── */

.cm-page { max-width: 46rem; margin: 0 auto; padding: 3vw 4vw 5vw; }

/* ── 404 ─────────────────────────────────────────────────────────────── */

.cm-404 { max-width: 46rem; margin: 0 auto; padding: 6vw 4vw; text-align: center; }
.cm-404 .cm-title { font-size: clamp(2.4rem, 9vw, 6rem); }
.cm-404 ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 2rem; }

/* ── a11y ────────────────────────────────────────────────────────────── */

.cm-skip {
  position: absolute; left: -9999px; top: 0;
  background: #000; color: #fff; padding: 0.7rem 1rem; z-index: 999;
  font-family: 'Kanit', sans-serif;
}
.cm-skip:focus { left: 0; }
.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(1px,1px,1px,1px); white-space: nowrap;
}
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid #000; outline-offset: 2px;
}

@media (max-width: 700px) {
  .cm-article, .cm-page { padding: 6vw 5vw 10vw; }
  .cm-body { font-size: 1.02rem; }
}

/* ── capture repairs ─────────────────────────────────────────────────── */

/* The capture styles .nav-close only inside its @media (max-width: 640px)
   block and never hides it outside one, so the mobile menu's "✕ Close" button
   rendered at every width — visible in the header of the original homepage,
   next to the nav. Hide it by default and let the existing mobile rules turn
   it back on. */
.nav-close { display: none; }
@media (max-width: 640px) {
  .main-nav.open .nav-close { display: block; }
}

/* .monkey-badge is positioned at left:20% with white-space:nowrap, so at some
   widths it runs a few pixels past the right edge. The capture masks that with
   overflow-x:hidden on body alone, which does not reliably stop the document
   scrolling. Clipping on the root element as well makes the badge bleed off
   the edge — which is how it is meant to look — without ever producing a
   horizontal scrollbar. */
html { overflow-x: hidden; }

/* The badge is absolutely positioned at the foot of the hero. At desktop it
   overlaps the photograph, which is the intended look. Below the hero's
   flex-column breakpoint it lands on top of the hero buttons instead — which
   did not matter in the capture, where those buttons were dead href="#" links,
   and matters now that they are the route into the featured article. Let it
   flow as its own row on narrow screens. */
@media (max-width: 700px) {
  .monkey-badge {
    position: static;
    align-self: flex-start;
    padding: 2vw 4vw;
    border-top: 3px solid #000;
    width: 100%;
  }
}
