/* From AI to Chitta · FSE bridge (Phase B)
 *
 * Connects WordPress core block output to the locked v0.9 design system.
 * The handoff theme.css targets editorial classes (.entry, .pullquote,
 * pre.code, .byline strong) but core blocks render their own wrappers
 * (wp-block-post-template, wp-block-pullquote, wp-block-code, etc.).
 *
 * This file is intentionally additive. It does not redefine any v0.9
 * token or component; it only re-applies them through WP-block selectors.
 */

/* ---------- Query / post-template ---------- */
/* wp:post-template renders as <ul>, strip list chrome so .entries reads
 * as a plain stack. */
.entries .wp-block-post-template {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entries .wp-block-post-template > li {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* The article.entry sits inside an <li>, so .entry:last-child no longer
 * matches the visually last item. Close the bottom border on the list
 * wrapper instead. */
.entries .wp-block-post-template > li:last-child > .entry,
.entries .wp-block-post-template > li:last-of-type > .entry {
  border-bottom: var(--hair);
}

/* ---------- Entry: post-terms / post-title / excerpt / date ---------- */
/* wp:post-terms renders as <div class="taxonomy-category cat"> with a
 * link inside. Reset link chrome so the rendered text reads like the
 * mockup span. */
.cat.wp-block-post-terms {
  display: inline-flex;
}
.cat.wp-block-post-terms a,
.cat.wp-block-post-terms a:hover {
  color: inherit;
  text-decoration: none;
}
.cat.wp-block-post-terms a + a::before {
  content: ", ";
  color: var(--text-tertiary);
}

/* wp:post-title in entry context: link should inherit color, no underline. */
.entry .wp-block-post-title {
  font-family: var(--font-serif);
  font-weight: 350;
  font-size: 1.5rem;
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s-2);
  color: var(--text-primary);
}
.entry .wp-block-post-title a {
  color: inherit;
  text-decoration: none;
}
.entry .wp-block-post-title a:hover {
  color: var(--text-secondary);
}

/* wp:post-excerpt renders extra "more" link wrapper; .dek class inherits
 * the editorial styling. Also strip the read-more link if it sneaks back. */
.entry .dek.wp-block-post-excerpt {
  margin: 0;
}
.entry .dek.wp-block-post-excerpt p {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 56ch;
}
.entry .dek.wp-block-post-excerpt .wp-block-post-excerpt__more-text,
.entry .dek.wp-block-post-excerpt .wp-block-post-excerpt__more-link {
  display: none;
}

/* wp:post-date in entry context: keep the mono date column right-aligned. */
.entry .date.wp-block-post-date,
.entry .date.wp-block-post-date time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.entry .date.wp-block-post-date a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Article single: post-content + byline ---------- */
/* wp:post-content with .article-body class still renders an entry-content
 * wrapper. Forward the editorial padding via the bridged selector. */
.article-body.wp-block-post-content,
.article-body .wp-block-post-content {
  padding: var(--s-7) 0 var(--s-7);
}

/* Byline: wp:post-author-name renders as <div class="wp-block-post-author-name">.
 * The locked CSS expects <strong>; bridge to that visual treatment. */
.byline .wp-block-post-author-name {
  color: var(--text-secondary);
  font-weight: 500;
}
.byline .wp-block-post-author-name a {
  color: inherit;
  text-decoration: none;
}
.byline .wp-block-post-date,
.byline .wp-block-post-date time {
  color: var(--text-tertiary);
}

/* ---------- Article body: pullquote, code, lists ---------- */
/* wp:pullquote renders as <figure class="wp-block-pullquote"><blockquote>...
 * Bridge to the .pullquote treatment. */
.article-body .wp-block-pullquote {
  margin: var(--s-7) 0;
  padding: var(--s-2) 0 var(--s-2) var(--s-5);
  border-left: 1px solid var(--accent-saffron);
  border-top: 0;
  border-bottom: 0;
  text-align: left;
  max-width: 56ch;
}
.article-body .wp-block-pullquote blockquote,
.article-body .wp-block-pullquote p {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 0;
}
.article-body .wp-block-pullquote cite {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: block;
  margin-top: var(--s-3);
}

/* wp:code renders as <pre class="wp-block-code"><code>...</code></pre>.
 * Mirror pre.code with the cool-edge. */
.article-body .wp-block-code,
.article-body pre.wp-block-code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--code-bg);
  border: var(--hair);
  border-left: 2px solid var(--accent-cool);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-7) 0;
  overflow-x: auto;
  border-radius: var(--radius-1);
  max-width: 70ch;
}

/* wp:list inside article-body: keep editorial measure. */
.article-body ul,
.article-body ol {
  margin: 0 0 var(--s-5);
  padding-left: var(--s-6);
  max-width: 62ch;
  font-family: var(--font-serif);
}
.article-body li {
  margin-bottom: var(--s-2);
}

/* wp:image inside article-body: respect editorial measure. */
.article-body .wp-block-image {
  margin: var(--s-7) 0;
}
.article-body .wp-block-image figcaption {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-top: var(--s-3);
}

/* ---------- Pagination ---------- */
.wp-block-query-pagination {
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: var(--hair);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  display: flex;
  gap: var(--s-5);
  justify-content: space-between;
  flex-wrap: wrap;
}
.wp-block-query-pagination a {
  color: var(--text-secondary);
  text-decoration: none;
}
.wp-block-query-pagination a:hover {
  color: var(--text-primary);
}

/* ---------- Author footer + biography ---------- */
.author-foot .wp-block-post-author-biography {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
  max-width: 56ch;
}

/* ---------- Accessibility: skip-link, focus-visible, aria-live region ----- */

/* Skip-link is hidden until a keyboard user tabs into it. Once focused it
 * appears at the top of the viewport so screen-reader and sighted-keyboard
 * users can jump past the masthead to #main. */
.skip-link {
  position: absolute;
  left: 0;
  top: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--accent-saffron);
  border-radius: var(--radius-1);
  z-index: 1000;
  transform: translateY(-200%);
  transition: transform 120ms ease;
}
.skip-link:focus {
  transform: translateY(var(--s-2));
  outline: 2px solid var(--accent-saffron);
  outline-offset: 2px;
}

/* The skip-link target. tabindex=-1 lets us focus a non-interactive anchor
 * programmatically when activated, ensuring the next Tab moves the focus
 * into the article, not back to the masthead. */
#main {
  display: block;
  height: 0;
  overflow: hidden;
  scroll-margin-top: var(--s-4);
}

/* Visually hide the aria-live region but keep it readable to screen
 * readers. Standard "visually hidden" pattern. */
.theme-toggle-status,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Visible focus ring on every interactive element. :focus-visible keeps
 * mouse clicks unstyled so the ring only appears under keyboard or
 * accessibility-tool focus. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.theme-toggle:focus-visible,
.wp-block-button__link:focus-visible {
  outline: 2px solid var(--accent-saffron);
  outline-offset: 2px;
  border-radius: 2px;
}

/* The masthead nav links lose their hover underline by default; ensure the
 * focus ring is still readable above the masthead background. */
.masthead .mast-nav a:focus-visible {
  outline-offset: 4px;
}

/* Pagination links use bare anchors; lift the focus offset so the ring
 * does not collide with the hairline separator. */
.wp-block-query-pagination a:focus-visible {
  outline-offset: 3px;
}

/* ---------- MailPoet form (legacy SmartMag custom CSS override) ---------- */
/* MailPoet form 1 has per-form custom-CSS rules saved from the SmartMag era
 * that force `DM Serif Display` and `DM Sans` with !important. Those fonts
 * are not in the chitta-theme stack and look out of place next to Source
 * Serif 4. Override at the same #-id specificity, also with !important so
 * the cascade resolves cleanly. Long-term cleanup is to delete the custom
 * CSS in MailPoet form admin, but this keeps the live form readable until
 * then. */
#mailpoet_form_1 .mailpoet_form,
#mailpoet_form_1 .mailpoet_paragraph,
#mailpoet_form_1 .mailpoet_text_label,
#mailpoet_form_1 .mailpoet_segment_label,
#mailpoet_form_1 .mailpoet_text,
#mailpoet_form_1 .mailpoet_textarea,
#mailpoet_form_1 input.mailpoet_text,
#mailpoet_form_1 input.mailpoet_email {
  font-family: var(--font-serif) !important;
}
#mailpoet_form_1 .mailpoet_form h1,
#mailpoet_form_1 .mailpoet_form h2,
#mailpoet_form_1 .mailpoet_form h3,
#mailpoet_form_1 .mailpoet_form h4 {
  font-family: var(--font-serif) !important;
  font-weight: 350 !important;
}
#mailpoet_form_1 .mailpoet_submit,
#mailpoet_form_1 input.mailpoet_submit {
  font-family: var(--font-sans) !important;
  font-weight: 500 !important;
  letter-spacing: 0.02em !important;
}

/* ---------- Group wrappers should not introduce extra padding ---------- */
.wp-block-group.entry,
.wp-block-group.entries,
.wp-block-group.article-head,
.wp-block-group.byline,
.wp-block-group.author-foot,
.wp-block-group.meta-left,
.wp-block-group.container,
.wp-block-group.page,
.wp-block-group.writing,
.wp-block-group.building,
.wp-block-group.news,
.wp-block-group.prose,
.wp-block-group.page-head,
.wp-block-group.tagline {
  padding: 0;
}
