/* ==========================================================================
   ETM Tabernacle — Base
   What theme.json cannot express: semantic text variables and their dark-
   ground remap, the responsive token steps, focus, the skip link, prose
   rhythm, block-style type utilities, reduced motion and print.

   Every colour, size and space here is a theme.json preset or custom value
   (--wp--preset--*, --wp--custom--*). No literal hex values.
   Reference: assets/css/base.css, layout.css and tokens.css in the project.
   ========================================================================== */

/* ---- Semantic text tokens. Remapped on dark grounds below. ------------- */
:root {
  --etm-ink:               var(--wp--preset--color--grey);        /* 12.6:1 on surface */
  --etm-ink-strong:        var(--wp--preset--color--navy);        /* 14.1:1 on surface */
  --etm-ink-muted:         var(--wp--preset--color--ink-muted);   /*  6.3:1 on surface */
  --etm-ink-inverse:       var(--wp--preset--color--surface);
  --etm-ink-inverse-muted: var(--wp--preset--color--beige);       /*  6.9:1 on navy    */
  --etm-link:              var(--wp--preset--color--blue);        /*  6.6:1 on surface */
  --etm-link-inverse:      var(--wp--preset--color--beige);
  --etm-gold-text:         var(--wp--preset--color--gold-text);   /*  6.2:1 on surface */
  --etm-focus:             var(--wp--custom--focus--ring);
  --etm-focus-inverse:     var(--wp--custom--focus--ring-inverse);

  /* Responsive steps (mobile values; desktop below 782px media query). */
  --etm-gutter:    var(--wp--preset--spacing--5);   /* 20px */
  --etm-section-y: var(--wp--preset--spacing--12);  /* 48px */
}

@media (min-width: 48.875em) {   /* 782px */
  :root {
    --etm-gutter:    var(--wp--preset--spacing--10);  /* 40px */
    --etm-section-y: var(--wp--preset--spacing--20);  /* 80px */
  }
}

@media (max-width: 48.8125em) {  /* below 782px — display and h1/h2 step down */
  :root {
    --wp--preset--font-size--display-1: 2.5rem;   /* 40px */
    --wp--preset--font-size--display-2: 2rem;     /* 32px */
    --wp--preset--font-size--heading-1: 2rem;     /* 32px */
    --wp--preset--font-size--heading-2: 1.5625rem;/* 25px */
    --wp--custom--line-height--display-1: 1.05;
    --wp--custom--line-height--display-2: 1.125;
  }
}

/* ---- Dark grounds. Any block given a navy or deep-navy background remaps
   the semantic tokens so muted text, links and headings stay legible. ---- */
.etm-on-dark,
.has-navy-background-color,
.has-ink-deep-background-color {
  --etm-ink:        var(--etm-ink-inverse);
  --etm-ink-strong: var(--etm-ink-inverse);
  --etm-ink-muted:  var(--etm-ink-inverse-muted);
  --etm-link:       var(--etm-link-inverse);
  --etm-gold-text:  var(--wp--preset--color--gold);
  --etm-focus:      var(--etm-focus-inverse);
  color: var(--etm-ink);
}
.etm-on-dark :is(h1, h2, h3, h4, h5, h6),
.has-navy-background-color :is(h1, h2, h3, h4, h5, h6),
.has-ink-deep-background-color :is(h1, h2, h3, h4, h5, h6) {
  color: var(--etm-ink-strong);
}
.etm-on-dark a:where(:not(.wp-block-button__link)),
.has-navy-background-color a:where(:not(.wp-block-button__link)),
.has-ink-deep-background-color a:where(:not(.wp-block-button__link)) {
  color: var(--etm-link);
}

/* ---- Document -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--wp--custom--header-height) + 24px);
}
body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden; /* guards the 320px no-horizontal-scroll rule */
}
img, picture, svg, video { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; overflow-wrap: anywhere; }
.wp-block-site-title { overflow-wrap: anywhere; }
h1, h2, h3 { letter-spacing: var(--wp--custom--tracking--heading); }
a { text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
strong, b { font-weight: var(--wp--custom--weight--semibold); }
small { font-size: var(--wp--preset--font-size--caption); }
hr.wp-block-separator:not(.is-style-etm-gold-rule) {
  border: 0;
  border-top: var(--wp--custom--border--hairline) solid var(--wp--preset--color--line);
  margin-block: var(--wp--preset--spacing--8);
}

/* ---- Focus. 3px solid, 2px offset. outline:none appears nowhere. -------- */
:focus-visible {
  outline: var(--wp--custom--border--focus) solid var(--etm-focus);
  outline-offset: 2px;
  border-radius: var(--wp--custom--radius--xs);
}

/* ---- Skip link. First focusable element on every page (inc/setup.php). -- */
.etm-skip-link {
  position: absolute;
  left: var(--wp--preset--spacing--4);
  top: var(--wp--preset--spacing--4);
  transform: translateY(-200%);
  z-index: 100;
  background: var(--wp--preset--color--navy);
  color: var(--etm-ink-inverse);
  padding: var(--wp--preset--spacing--3) var(--wp--preset--spacing--5);
  border-radius: var(--wp--custom--radius--sm);
  font-weight: var(--wp--custom--weight--bold);
  text-decoration: none;
}
.etm-skip-link:focus { transform: translateY(0); }

/* ---- Screen-reader-only ---------------------------------------------- */
.etm-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Type utilities. Block styles registered in inc/block-styles.php. -- */
.is-style-etm-display-1 {
  font-size: var(--wp--preset--font-size--display-1) !important;
  line-height: var(--wp--custom--line-height--display-1);
  font-weight: var(--wp--custom--weight--bold);
  letter-spacing: var(--wp--custom--tracking--display);
}
.is-style-etm-display-2 {
  font-size: var(--wp--preset--font-size--display-2) !important;
  line-height: var(--wp--custom--line-height--display-2);
  font-weight: var(--wp--custom--weight--bold);
  letter-spacing: var(--wp--custom--tracking--display);
}
.is-style-etm-lead {
  font-size: var(--wp--preset--font-size--lead);
  line-height: var(--wp--custom--line-height--lead);
}
.is-style-etm-body-lg {
  font-size: var(--wp--preset--font-size--body-lg);
  line-height: var(--wp--custom--line-height--body-lg);
}
.is-style-etm-body-sm { font-size: var(--wp--preset--font-size--body-sm); line-height: 1.6; }
.is-style-etm-caption {
  font-size: var(--wp--preset--font-size--caption);
  line-height: 1.54;
  color: var(--etm-ink-muted);
}
.is-style-etm-meta {
  font-size: var(--wp--preset--font-size--meta);
  line-height: 1.43;
  font-weight: var(--wp--custom--weight--medium);
  color: var(--etm-ink-muted);
}
.is-style-etm-eyebrow {
  font-size: var(--wp--preset--font-size--eyebrow) !important;
  line-height: 1.23;
  font-weight: var(--wp--custom--weight--bold);
  letter-spacing: var(--wp--custom--tracking--eyebrow);
  text-transform: uppercase;
  color: var(--etm-gold-text);
}

/* The 44px gold rule that opens a section heading unit or page hero. */
hr.wp-block-separator.is-style-etm-gold-rule:not(.is-style-wide) {
  display: block;
  width: 44px;
  height: var(--wp--custom--border--accent);
  border: 0;
  background: var(--wp--preset--color--gold);
  margin: 0 0 var(--wp--preset--spacing--4);
  opacity: 1;
}

/* ---- Buttons. theme.json sets colour, size, weight, radius, padding. ---- */
.wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wp--preset--spacing--2);
  min-height: var(--wp--custom--tap);
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: background-color var(--wp--custom--transition), border-color var(--wp--custom--transition);
}

/* ---- Prose rhythm. Post content is long-form reading. -------------------
   Post content flows left-aligned inside the wide column, as .etm-prose does
   inside .etm-container in the reference: text blocks hold the 68ch measure,
   wide blocks (galleries, bands) may span the column.
   Block gap (20px) comes from theme.json; headings get more room above. */
.wp-block-post-content {
  font-size: var(--wp--preset--font-size--body-lg);
  line-height: var(--wp--custom--line-height--body-lg);
}
/* A page composed of bands is not prose: inside a band the reference sets the
   body size, and only a group marked .etm-prose reads at body-lg. */
.wp-block-post-content > .etm-band {
  font-size: var(--wp--preset--font-size--body);
  line-height: var(--wp--custom--line-height--body);
}
.wp-block-post-content > :where(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, figure.wp-block-table) {
  max-width: var(--wp--custom--measure--prose);
}
.wp-block-post-content > h2 { margin-block: var(--wp--preset--spacing--10) var(--wp--preset--spacing--4); }
.wp-block-post-content > h3 { margin-block: var(--wp--preset--spacing--8) var(--wp--preset--spacing--3); }
.wp-block-post-content > :is(h2, h3) + * { margin-block-start: 0; }
.wp-block-post-content > :first-child { margin-block-start: 0; }
.wp-block-post-content :is(ul, ol):not([class]) { padding-left: var(--wp--preset--spacing--6); }
/* Prose lists only: a list that is a direct child of the content. Lists inside
   bands (section navigation, resource lists) take the reference's own rules;
   .etm-prose li + li in reference.css covers a prose group inside a band. */
.wp-block-post-content > :is(ul, ol) li + li { margin-block-start: var(--wp--preset--spacing--2); }

/* ---- An article ends before the footer begins ---------------------------
   A mission report or a notice is an <article>, not a band, so nothing gave
   it room at the bottom: its last button or card touched the footer. The
   reference has the same fault (missions/article.html). One band's worth. */
.etm-main > .etm-article { padding-block-end: var(--etm-section-y); }

/* ---- Interior page hero (patterns/page-hero.php) ----------------------- */
.etm-page-hero {
  padding-block: var(--wp--preset--spacing--12);
}
.etm-page-hero .wp-block-post-title {
  color: var(--etm-ink-inverse);
  margin-block: 0 var(--wp--preset--spacing--3);
}
.etm-page-hero .wp-block-post-excerpt__excerpt,
.etm-page-hero .is-style-etm-lead {
  color: var(--etm-ink-inverse-muted);
  max-width: 52ch;
  margin: 0;
}
.etm-page-hero .wp-block-post-excerpt__more-text { display: none; }

/* ---- Main content landmark --------------------------------------------- */
.etm-main { display: block; }

/* ---- Reduced motion. Transitions are removed, not shortened. ----------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Print. Drop chrome, keep the article. ----------------------------- */
@media print {
  .etm-site-header, .etm-site-footer, .etm-announcement-bar, .etm-skip-link,
  .etm-nav-toggle, .etm-fab { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }
}
