/* Eight June UX correction layer — 31 Aug 2026.
 * Surgical overrides only; preserves the established Eight June visual system.
 */

/* Never use clipping as the only defence against oversized children. */
.site-header,
.site-header nav,
.section-shell,
.story-layout,
.story-body,
.article-card,
.current-card,
.lens-card,
.world-path-card,
.tool-record-grid article,
.tide-card,
footer,
.footer-links { min-width: 0; }

.hero h1,
.ask-hero h1,
.story-hero h1,
.discover-hero h1,
.world-hero h1,
.tool-hero h1,
.tide-hero h1,
.tide-entry-hero h1,
.current-card h3,
.article-card h3,
.tide-card h2,
.source-list a,
.tool-source-list h3,
.footer-links a { overflow-wrap: break-word; word-break: normal; }

html { scroll-padding-top: 96px; }

/* Drawer backdrop: blocks the page and gives users a clear outside-close target. */
.ux-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(4,25,34,.46);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s ease, visibility .25s ease;
}
.ux-menu-open .ux-nav-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* backdrop-filter can establish a containing block for fixed descendants;
 * remove it only while the drawer is open so the drawer is truly viewport-fixed. */
.ux-menu-open .site-header {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--chalk);
}
.ux-menu-open { overscroll-behavior: none; }
.ux-mobile-enquire { display: none; }

/* Large touch devices should not depend on hover-only desktop submenus. */
.ux-drawer-nav .site-header {
  grid-template-columns: 1fr auto;
  height: 74px;
  padding-inline: 24px;
}
.ux-drawer-nav .header-enquire { display: none; }
.ux-drawer-nav .menu-button {
  z-index: 70;
  background: transparent;
  border: 0;
  gap: 6px;
  padding: 10px;
  min-width: 46px;
  min-height: 46px;
  display: grid;
  place-content: center;
  position: relative;
}
.ux-drawer-nav .menu-button span {
  background: var(--navy);
  transform-origin: 50%;
  width: 26px;
  height: 1px;
  transition: transform .28s;
  display: block;
}
.ux-drawer-nav .menu-button.is-open span:first-child { transform: translateY(3.5px) rotate(45deg); }
.ux-drawer-nav .menu-button.is-open span:last-child { transform: translateY(-3.5px) rotate(-45deg); }
.ux-drawer-nav .site-header nav {
  background: var(--chalk);
  border-left: 1px solid var(--rule);
  overscroll-behavior: contain;
  pointer-events: none;
  visibility: hidden;
  z-index: 60;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 28px;
  width: min(72vw, 520px);
  height: 100dvh;
  padding: 98px 32px 40px;
  transition: transform .32s ease, visibility .32s ease;
  display: flex;
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  box-shadow: -18px 0 40px rgba(8,44,59,.12);
}
.ux-drawer-nav .site-header nav.nav-open {
  pointer-events: auto;
  visibility: visible;
  transform: translateX(0);
}
.ux-drawer-nav .site-header nav .nav-group { width: 100%; }
.ux-drawer-nav .site-header nav .nav-primary { font-size: 12px; }
.ux-drawer-nav .site-header nav .nav-submenu {
  border: 0;
  border-left: 1px solid var(--rule);
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  background: transparent;
  gap: 0;
  width: 100%;
  min-width: 0;
  margin-top: 16px;
  padding: 0 0 0 14px;
  position: static;
  left: auto;
  transform: none;
}
.ux-drawer-nav .site-header nav .nav-submenu:before { display: none; }
.ux-drawer-nav .site-header nav .nav-submenu a {
  border-bottom-color: rgba(8,44,59,.12);
  grid-template-columns: 46px 1fr;
  gap: 10px;
  min-height: 48px;
  padding: 8px 0;
}
.ux-drawer-nav .site-header nav .nav-submenu a:hover,
.ux-drawer-nav .site-header nav .nav-submenu a:focus-visible {
  background: transparent;
  padding-left: 5px;
}
.ux-drawer-nav .site-header nav .nav-submenu strong { letter-spacing: .08em; font-size: 11px; }
.ux-drawer-nav .ux-mobile-enquire {
  border-top: 1px solid var(--rule);
  border-bottom: 0;
  width: 100%;
  margin-top: 2px;
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ux-drawer-nav .ux-mobile-enquire span { color: var(--coral); font-size: 17px; }

body.admin-bar.ux-drawer-body .site-header nav { top: 32px; height: calc(100dvh - 32px); }

/* Footer links must reflow rather than be hidden by global overflow clipping. */
.footer-links { flex-wrap: wrap; row-gap: 14px; }
.footer-links a { line-height: 1.4; }
.legal, .copyright { overflow-wrap: anywhere; }

/* Pagination should remain usable as the content library grows. */
.page-numbers { flex-wrap: wrap; justify-content: center; }
.article-pagination { column-gap: 8px; }

/* Tablet article navigation: keep a compact contents map instead of removing it. */
@media (min-width: 641px) and (max-width: 1180px) {
  .story-aside nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    column-gap: 28px;
    margin-top: 28px;
  }
  .story-aside nav a { min-height: 48px; display: flex; align-items: center; }

  /* Give intermediate-width Tide List forms room before phone layout. */
  .tide-letter,
  .tide-home-letter { grid-template-columns: 1fr; gap: 36px; }
  .tide-letter form { grid-template-columns: 1fr 1fr auto; }
  .tide-home-letter form { max-width: 760px; }
}

@media (min-width: 761px) and (max-width: 900px) {
  .tide-hero { grid-template-columns: 1fr; min-height: 0; }
  .tide-hero-mark { justify-self: center; width: min(58vw, 430px); margin-top: 30px; }
  .tide-letter form { grid-template-columns: 1fr 1fr; }
  .tide-letter form .button { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 782px) {
  body.admin-bar.ux-drawer-body .site-header nav { top: 46px; height: calc(100dvh - 46px); }
}

@media (max-width: 640px) {
  html { scroll-padding-top: 82px; }
  .ux-drawer-nav .site-header { padding-inline: 18px; }
  .ux-drawer-nav .site-header nav {
    width: min(86vw, 390px);
    padding: 88px 22px 34px;
    gap: 24px;
  }

  /* Comfortable touch targets. */
  .site-header nav .nav-submenu a,
  .subject-filters button,
  .article-pagination button,
  .studio-navigation button,
  .studio-choice-heading > button,
  .studio-ratio-row button,
  .footer-links a,
  .tide-pagination a { min-width: 44px; min-height: 44px; }
  .subject-filters button { padding: 11px 12px; }
  .article-pagination button { min-width: 44px; min-height: 44px; padding-inline: 8px; }
  .footer-links a { display: inline-flex; align-items: center; padding-block: 6px; }

  /* Preserve the editorial scale while removing illegibly small UI text. */
  .article-top,
  .article-foot,
  .article-subjects span,
  .result-count,
  .library-control-label,
  .approach-select > span,
  .approach-select select,
  .lens-action,
  .card-action,
  .source-tags span,
  .source-list .source-index,
  .source-explainer,
  .story-byline span,
  .story-visual figcaption,
  .world-path-meta,
  .world-path-name,
  .world-path-action,
  .tool-record-meta,
  .tool-record-scope,
  .tool-record-footer > div span,
  .tool-record-footer small,
  .tool-record-profile-cta,
  .tide-card-top,
  .tide-card-foot,
  .tide-tags span,
  .tide-filters label > span,
  .tide-form label > span,
  .tide-letter label > span,
  .tide-home-letter label > span,
  .legal,
  .copyright { font-size: 10px; line-height: 1.5; }

  .footer-links { width: 100%; justify-content: flex-start; gap: 8px 20px; }
  .legal { line-height: 1.7; }

  /* Forms: readable without mobile browser zoom and easier to tap. */
  form input,
  form select,
  form textarea,
  .tide-filters input,
  .tide-filters select,
  .tide-form input,
  .tide-form select,
  .tide-form textarea,
  .tide-letter input,
  .tide-letter select,
  .tide-home-letter input {
    min-height: 48px;
    font-size: 16px;
  }
  form textarea,
  .tide-form textarea { min-height: 120px; }

  /* Long content should wrap instead of forcing clipped width. */
  .studio-navigation span { max-width: min(145px, 42vw); }
  .source-list li,
  .tool-source-list > a { min-width: 0; }
  .source-list a,
  .tool-source-list a,
  .tide-research-sources a { overflow-wrap: anywhere; }

  .article-card { min-height: 0; }
  .article-card-content { min-height: 340px; }

  .hero h1,
  .ask-hero h1,
  .story-hero h1,
  .discover-hero h1,
  .world-hero h1,
  .tool-hero h1,
  .tide-hero h1,
  .tide-entry-hero h1 { hyphens: auto; }
}

@media (max-width: 360px) {
  .ux-drawer-nav .site-header nav { width: 90vw; padding-inline: 18px; }
  .footer-links { gap: 6px 14px; }
  .story-hero h1,
  .tide-entry-hero h1 { font-size: 46px; }
}

/* Keep large screens editorially dense instead of allowing grids to expand forever. */
@media (min-width: 1700px) {
  .current-grid,
  .lens-grid,
  .article-grid,
  .world-path-grid,
  .world-more-grid,
  .tool-item-grid,
  .tool-record-grid,
  .tool-related-grid,
  .tide-grid,
  .section-heading,
  .library-heading,
  .compact-heading,
  .tool-workspace-heading,
  .tool-records-heading,
  .tool-evidence-heading { max-width: 1680px; margin-inline: auto; }
}

/* Clear, consistent keyboard focus without changing the normal visual state. */
.menu-button:focus-visible,
.site-header nav a:focus-visible,
.footer-links a:focus-visible,
.subject-filters button:focus-visible,
.article-pagination button:focus-visible,
.studio-choice-panel button:focus-visible,
form input:focus-visible,
form select:focus-visible,
form textarea:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .ux-nav-backdrop,
  .ux-drawer-nav .site-header nav { transition: none !important; }
}
