/**
 * WordPress-specific bridges for Minescore Paper.
 * Keeps Gutenberg layout + paper chrome playing nicely.
 */

body {
  background: var(--paper, #efe9df);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.wp-site-blocks {
  padding: 0;
}

/* Match static .wrap (980px) — one reading shell */
.paper-shell,
.entry-content.paper-shell,
.paper-shell--wide,
.is-paper-wide,
.wrap.paper-shell,
.wrap.paper-shell--wide,
.wrap--home {
  width: min(100% - 2rem, 980px);
  max-width: 980px;
  margin-inline: auto;
  padding-block: 1.25rem 3rem;
}

.wrap--home {
  padding-block: 0 3rem;
}

/* Align core blocks with paper type */
.entry-content > :where(h1, h2, h3, h4) {
  font-family: var(--font-display, "Sora", system-ui, sans-serif);
}

.entry-content > :where(p, li) {
  font-family: var(--font-body, "Figtree", system-ui, sans-serif);
}

.paper-masthead-wrap {
  width: min(100% - 2rem, 980px);
  max-width: 980px;
  margin-inline: auto;
  padding-top: max(1rem, env(safe-area-inset-top, 0px));
}

/* Centered paper masthead (static parity) */
.paper-masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  text-align: center;
  margin: 0 0 1.5rem;
}

.paper-masthead .wp-block-site-logo {
  margin-inline: auto;
}

.paper-masthead .wp-block-site-logo img,
.paper-masthead .custom-logo {
  display: block;
  width: min(420px, 88vw);
  max-width: 100%;
  height: auto;
  max-height: none;
  margin-inline: auto;
}

/* Map core Navigation onto paper-nav tap targets + current state */
.paper-masthead .wp-block-navigation,
.paper-nav.wp-block-navigation {
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-weight: 500;
  gap: 0.15rem 0.2rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 0.55rem;
}

.paper-masthead .wp-block-navigation a,
.paper-nav.wp-block-navigation a,
.paper-masthead .wp-block-navigation__submenu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted, #4a4e53);
  border-radius: 4px;
}

.paper-masthead .wp-block-navigation a:hover,
.paper-nav.wp-block-navigation a:hover {
  color: var(--accent, #345c1a);
  background: rgba(52, 92, 26, 0.08);
}

.paper-masthead .wp-block-navigation .current-menu-item > a,
.paper-masthead .wp-block-navigation .current-menu-ancestor > a,
.paper-nav.wp-block-navigation .current-menu-item > a,
.paper-masthead .wp-block-navigation a[aria-current="page"],
.paper-masthead .wp-block-navigation a[aria-current="true"] {
  color: var(--accent, #345c1a);
  background: rgba(52, 92, 26, 0.1);
  font-weight: 600;
}

.paper-masthead .wp-block-navigation a:focus-visible,
.paper-nav.wp-block-navigation a:focus-visible {
  outline: 2px solid var(--accent, #345c1a);
  outline-offset: 2px;
}

/* Ensure skip target exists even if filter misses */
main#main {
  scroll-margin-top: 1rem;
}

.paper-article {
  display: flow-root;
}

/* Paper hero: WP groups must still hit static header.hero / hero-lead rules */
.wp-block-group.hero,
header.hero.wp-block-group {
  margin: 0 0 1.25rem;
}

/* Defeat core constrained centering so kicker/H1/deck match static left alignment */
.paper-article .hero .hero-copy.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
.paper-article .hero .is-layout-constrained.hero-copy > * {
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.paper-article .hero .kicker,
.paper-article .hero h1,
.paper-article .hero .wp-block-post-title,
.paper-article .hero .deck,
.paper-article .hero .wp-block-post-excerpt {
  text-align: left;
}

.hero .meta__author {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

/* Keep the static green pill; only nudge type for WP meta row */
.hero .meta__badge {
  text-transform: none;
}

.hero .meta__item,
.hero time.meta__item,
.hero .wp-block-post-date.meta__item {
  font-size: 0.9rem;
  color: var(--muted, #4a4e53);
}

.hero .meta__item::before,
.hero .wp-block-post-date.meta__item::before {
  content: "Updated: ";
  font-weight: 400;
}

.hero figure.hero-feature,
.hero .wp-block-post-featured-image.hero-feature,
.hero .wp-block-post-featured-image {
  margin: 1.25rem 0 0;
}

.hero .wp-block-post-featured-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

/* TL;DR spacing when hero is a WP group */
.hero + .tldr,
.wp-block-group.hero + .tldr,
.hero + * .tldr {
  margin-top: 0.5rem;
}

.footer-terrain {
  margin-top: 0;
  background: #5c3018;
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
}
body:has(.footer-terrain) .wrap,
body:has(.footer-terrain) main.wrap {
  padding-bottom: 0.75rem;
}
.home-about + .paper-foot,
body:has(.footer-terrain) .paper-foot {
  margin-top: 1rem;
}

.footer-terrain__img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  vertical-align: bottom;
}

/* Core buttons ≈ home CTAs */
.wp-block-button .wp-block-button__link,
.home-hero .wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.65rem 1.05rem;
  border-radius: 4px;
}

/* Home: match static wrap width + left-aligned hero copy */
.wrap.wrap--home,
.wrap--home.paper-shell--wide {
  width: min(100% - 2rem, 980px);
  max-width: 980px;
  margin-inline: auto;
}

.wrap--home .home-hero,
.wrap--home .home-hero__grid,
.wrap--home .hero-copy {
  text-align: left;
}

.wrap--home .home-hero__scene {
  background: transparent;
}

/* Home featured shelf from Query loop (legacy) + curated shelves */
.home-featured-query .home-featured,
ul.home-featured.wp-block-post-template,
.home-featured.home-featured--shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.home-featured.home-featured--shelf {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.home-featured .wp-block-post,
.home-featured > li {
  margin: 0;
}

.home-featured .home-featured__item,
.home-featured .wp-block-post .home-featured__item {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line, #d4cfc3);
  background: var(--card, #faf8f3);
  border-radius: 6px;
  overflow: hidden;
}

.home-featured .home-featured__item:hover {
  border-color: var(--accent, #345c1a);
}

.home-featured .wp-block-post-featured-image {
  margin: 0;
}

.home-featured .wp-block-post-featured-image img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.home-featured .home-featured__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.85rem 1rem;
}

.home-featured .home-featured__kicker,
.home-featured .home-featured__kicker a,
.home-featured .taxonomy-category {
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #4a4e53);
  text-decoration: none;
}

.home-featured .wp-block-post-title,
.home-featured .wp-block-post-title a {
  font-family: var(--font-display, "Sora", system-ui, sans-serif);
  font-size: 1rem;
  line-height: 1.3;
  color: var(--ink, #1d1d21);
  text-decoration: none;
}

.home-featured .wp-block-post-excerpt {
  font-size: 0.85rem;
  color: var(--muted, #4a4e53);
  margin: 0;
}

.home-featured .wp-block-post-excerpt p {
  margin: 0;
}

/* Archive / papers hub: article-list feel */
.article-list.wp-block-post-template,
ul.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.article-list .article-list__item {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line, #d4cfc3);
}

@media (min-width: 640px) {
  .article-list .article-list__item {
    grid-template-columns: 160px 1fr;
    align-items: start;
  }
}

/* Chart title: match static .chart-box h3 */
.chart-box .minescore-chart__title,
.chart-box h3.minescore-chart__title {
  font-family: var(--font-display, "Sora", system-ui, sans-serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.65rem;
  color: var(--ink, #1d1d21);
}

/* Tables in classic/HTML content: scroll, never clip */
.entry-content .table-scroll,
.paper-article .table-scroll {
  margin: 0.75rem 0 1rem;
}

.entry-content > table,
.entry-content .wp-block-table table {
  width: 100%;
}

.entry-content .wp-block-table,
.entry-content > .wp-block-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

@media (max-width: 900px) {
  .home-featured-query .home-featured,
  ul.home-featured.wp-block-post-template {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .entry-content .wp-block-table::before {
    content: "Swipe for all columns →";
    display: block;
    font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--muted, #4a4e53);
    margin: 0 0 0.4rem;
  }

  .home-featured-query .home-featured,
  ul.home-featured.wp-block-post-template {
    grid-template-columns: 1fr;
  }
}

/* Hero avatar + meta byline on narrow screens (matches static paper) */
@media (max-width: 560px) {
  .hero-lead .hero-copy {
    display: contents;
  }
  .hero-lead .hero-avatar,
  .hero-lead .wp-block-image.hero-avatar,
  .hero-lead img.hero-avatar {
    order: 4;
    grid-column: 1;
    width: 96px;
    max-width: 96px;
    margin: 0;
  }
  .hero-lead .meta {
    order: 5;
    grid-column: 2;
    margin-top: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
  .hero-lead .meta > .meta__item,
  .hero-lead .meta > .wp-block-post-date {
    padding-left: 0;
    border-left: none;
  }
}
