/* Article pages — same token system as the app, tuned for long-form reading. */

.article-wrap {
  width: 100%; /* auto margins would otherwise size it to fit-content, letting a long <pre> line widen the page */
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1.5rem 5rem;
  box-sizing: border-box;
}

.article-hero { margin: 1.5rem 0 0.5rem; }
.article-hero svg { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); }

.article-kicker {
  margin: 2rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

article h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 3vw + 0.5rem, 2.375rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}

.article-byline {
  margin: 0 0 2rem;
  font-size: 0.8125rem;
  color: var(--fg-faint);
}

article h2 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Section numbers — the scannable spine of every article. */
article h2 .sec-num {
  margin-right: 0.4em;
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 700;
  color: var(--accent);
}

/* related — two-tier keep-reading nav at the foot of every article. */
.related {
  margin: 3rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.related-head a { font-size: 0.8125rem; }

/* touch: keep the small link but grow its hit area */
@media (pointer: coarse) {
  .related-head a { padding: 0.75rem 0.375rem; margin: -0.75rem -0.375rem; }
}

.related-kicker {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.related-label {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.related-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.6rem;
  padding: 0;
  margin: 0;
}

.related-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  text-decoration: none;
  transition: border-color 120ms ease;
}

.related-card:hover { border-color: var(--accent); }

.related-thumb {
  display: block;
  border-bottom: 1px solid var(--border);
  background: light-dark(
    color-mix(in srgb, var(--accent) 6%, #f0f1f7),
    color-mix(in srgb, var(--accent) 5%, transparent)
  );
}

.related-thumb svg { display: block; width: 100%; height: auto; }

.related-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.9rem 0.8rem;
}

.related-group {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--fg-muted); /* AA contrast on the raised card */
}

.related-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--fg);
}

/* fig-panel — inline concept diagrams, same visual language as the hero. */
.fig-panel {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: light-dark(
    color-mix(in srgb, var(--accent) 6%, #f0f1f7),
    color-mix(in srgb, var(--accent) 5%, var(--bg-raised))
  );
}
.fig-panel svg { display: block; width: 100%; height: auto; }
.fig-panel figcaption {
  padding: 0 1rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--fg-muted);
  text-align: center;
}

article p, article li {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--fg);
}

article p { margin: 0 0 1.1rem; }
article ul, article ol { padding-left: 1.4rem; margin: 0 0 1.1rem; }
article li { margin-bottom: 0.35rem; }

article code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

article pre {
  padding: 0.875rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0 0 1.1rem;
}

article pre code { background: none; padding: 0; font-size: 0.8125rem; line-height: 1.6; }

article table {
  border-collapse: collapse;
  margin: 0 0 1.1rem;
  font-size: 0.875rem;
  width: 100%;
}

article th, article td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.65rem;
  text-align: left;
}

article th { background: color-mix(in srgb, var(--fg) 4%, transparent); font-weight: 600; }

article blockquote {
  margin: 0 0 1.1rem;
  padding: 0.25rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--fg-muted);
}

.shot-note {
  margin: 0 0 1.1rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, var(--bg-raised));
  border: 1px dashed color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--radius-md);
}

/* file paths inside the marker: darker/lighter amber so the chip passes contrast */
.shot-note code {
  color: light-dark(#7c3d00, #fcd34d);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

.article-cta {
  margin: 2.5rem 0 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

.article-cta p { margin: 0 0 0.75rem; font-size: 0.9375rem; }

/* The homepage drop target, article-sized (cta-drop.js wires drop + click) */
.drop-target-inline {
  margin-top: 0.25rem;
  padding: 2.25rem 1.5rem 2rem;
  gap: 0.625rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.article-cta a {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.article-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--fg-faint);
}

/* changelog (/changelog.html) — one .log-entry per release, newest first */
.log-entry {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.log-entry:first-of-type { margin-top: 2rem; }

.log-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.log-version {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.1875rem 0.5625rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.log-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-faint);
}

.log-badge {
  font-family: var(--font-mono);
  font-size: 0.65625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ok);
  padding: 0.125rem 0.4375rem;
  border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent);
  border-radius: 999px;
}

.log-entry h2 { margin: 0 0 0.625rem; }
.log-entry ul { margin: 0.75rem 0 0; }
.log-entry li { margin-bottom: 0.625rem; }

article a { color: var(--accent); text-decoration: none; }
article a:hover { text-decoration: underline; }

/* In-text links need a non-color cue (accent-on-body is 2.81:1) */
article p a, article li a, article td a, article figcaption a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* blog index — gallery view grouped by theme */
.article-wrap.wide { max-width: 60rem; }

.gallery-group { margin-top: 3rem; }

.gallery-kicker {
  margin: 0 0 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

.gallery-blurb { margin: 0; font-size: 0.875rem; color: var(--fg-muted); }

.gallery-grid {
  list-style: none;
  margin: 1.125rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.gallery-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 4px 18px -8px color-mix(in srgb, var(--accent) 22%, transparent);
  text-decoration: none;
}

/* thumb glyph lifts a hair on hover — gated by the global reduced-motion rule */
@media (prefers-reduced-motion: no-preference) {
  .card-thumb svg { transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1); }
  .gallery-card:hover .card-thumb svg { transform: translateY(-2px); }
}

.card-thumb {
  aspect-ratio: 16 / 8;
  background: light-dark(
    color-mix(in srgb, var(--accent) 6%, #f0f1f7),
    color-mix(in srgb, var(--accent) 5%, transparent)
  );
  border-bottom: 1px solid var(--border);
}

.card-thumb svg { display: block; width: 100%; height: 100%; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.875rem 1rem 1rem;
}

.card-order {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
}

.gallery-card h3 { margin: 0; font-size: 0.96875rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.gallery-card .card-desc { flex: 1; margin: 0; font-size: 0.8125rem; color: var(--fg-muted); line-height: 1.55; }
.gallery-card .card-meta { margin: 0; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--fg-muted); }

/* index card list (formats + examples) — column count follows the window */
.post-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.875rem;
}
.post-list > li { display: grid; }
.post-card {
  display: block;
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--ease);
}
.post-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.post-card h2 { margin: 0 0 0.375rem; font-size: 1.0625rem; letter-spacing: -0.01em; }
.post-card p { margin: 0; font-size: 0.875rem; color: var(--fg-muted); line-height: 1.6; }
.post-card .post-date { display: block; margin-top: 0.5rem; font-family: var(--font-mono); font-size: 0.71875rem; color: var(--fg-faint); }

/* format chips strip on the gallery */
.format-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0; }
.format-chips a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--fg-muted);
  text-decoration: none;
  transition: border-color var(--ease), color var(--ease);
}
.format-chips a:hover { color: var(--fg); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; }

/* format guides: before/after sample pair */
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0 0 1.1rem; }
.ba > * { min-width: 0; } /* wide <pre> scrolls inside its column instead of blowing out the grid */
.ba-label {
  margin: 0 0 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.ba-after .ba-label { color: var(--ok); }
.ba pre { margin: 0; height: calc(100% - 1.4rem); }
.ba-after pre { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
@media (max-width: 720px) { .ba { grid-template-columns: 1fr; } .ba pre { height: auto; } }

/* Small screens: wide tables scroll inside their own box instead of
   stretching the page (a 5-column mapping table's min width is ~620px). */
@media (max-width: 767px) {
  article table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* icon hero — the article's gallery glyph, promoted */
.icon-hero {
  max-width: 24rem;
  margin: 0.25rem auto 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: light-dark(
    color-mix(in srgb, var(--accent) 6%, #f0f1f7),
    color-mix(in srgb, var(--accent) 5%, var(--bg-raised))
  );
}
.icon-hero svg { display: block; width: 100%; height: auto; }

/* reserved ad containers — CLS-safe (fixed min-height), clearly labeled.
   Demo styling until AdSense approval; the real unit replaces the inner box. */
.ad-slot {
  margin: 2rem 0;
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--fg) 2.5%, transparent);
}
.ad-slot::before {
  content: "Advertisement";
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.ad-slot.ad-demo::after {
  content: "reserved · " attr(data-unit);
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  max-width: 24rem;
  text-align: center;
}

/* in-feed demo card in the gallery grid — native list unit, one per group max */
.gallery-grid .ad-card { list-style: none; }
.ad-infeed { margin: 0; height: 100%; min-height: 16rem; }

/* two-cell in-feed unit — fills a section's trailing free cells; only spans
   when the grid is guaranteed a second column */
@media (min-width: 768px) {
  .gallery-grid > .ad-card-wide { grid-column: span 2; }
}

/* Fixed side rails on wide screens — the 42rem content column is untouched;
   rails ride the empty margins (hidden below 1240px, AdSense-supported). */
.ad-rail-fixed {
  display: none;
  position: fixed;
  top: 5.5rem;
  width: 160px;
  min-height: 600px;
  margin: 0;
}

@media (min-width: 1240px) {
  .ad-rail-fixed { display: grid; }
  .ad-rail-fixed.rail-left { left: calc(50vw - 21rem - 13rem); }
  .ad-rail-fixed.rail-right { right: calc(50vw - 21rem - 13rem); }
}

/* emphasis components ------------------------------------------------------- */

/* takeaway — the article's one-sentence point, impossible to miss */
.takeaway {
  margin: 1.5rem 0;
  padding: 0.875rem 1.125rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  font-size: 1rem;
  line-height: 1.6;
}
.takeaway strong:first-child { color: var(--accent); }

/* pull-stats — key numbers lifted out of the prose */
.pull-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}
.pull-stat {
  flex: 1 1 10rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  text-align: center;
}
.pull-stat .n {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.625rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.pull-stat .l {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
  line-height: 1.45;
}

/* ui-demo — the actual UI element rebuilt live inside the article, so it
   follows the reader's theme. Decorative: inert + pointer-events none. */
.ui-demo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  pointer-events: none;
  overflow-x: auto;
}

.ui-demo .pane-title { margin: 0; padding: 0; border: 0; }
.ui-demo .drop-error { margin: 0; }
.ui-demo .ocr-offer { margin: 0; padding: 0; border: 0; }
.ui-demo .qc-checks { margin: 0; }
.ui-demo .dag-wrap { width: 100%; }

/* Dual-theme embeds of theme-baked SVG output (the dependency DAG) */
.demo-dag-light, .demo-dag-dark { display: none; }
:root[data-theme="light"] .demo-dag-light { display: block; }
:root[data-theme="dark"] .demo-dag-dark { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .demo-dag-light { display: block; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .demo-dag-dark { display: block; }
}

/* ui-shot — real product screenshots embedded at the action point */
.ui-shot { margin: 1.25rem 0 1.5rem; }
.ui-shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px -14px rgb(0 0 0 / 0.35);
}
.ui-shot figcaption {
  margin-top: 0.5rem;
  font-size: 0.78125rem;
  color: var(--fg-faint);
  text-align: center;
}
