/*
 * Shared site chrome (header + footer) - Legum Law legal-reference site.
 *
 * Paired with Assets/site-chrome.js, which builds the markup at run
 * time. Link this sheet AFTER a page's own inline <style> block so its body
 * offsets win, then load the script with defer:
 *
 * Both are loaded at the END of <body> so the statute text paints first on a
 * poor connection; the page reserves the header's height in its own inline
 * <style> so nothing shifts when this sheet arrives.
 *
 * --statute-header-base is the header at full height and drives the body's top
 * padding; --statute-header-height tracks its live height for anchor offsets.
 * Keeping them apart is what stops the text shifting when the header compacts.
 */

html {
  scroll-behavior: smooth;
}
:root {
  color-scheme: light;
  --legum-blue: #004d91;
  --legum-blue-dark: #003b70;
  --legum-gold: #d6a41f;
  --legum-ink: #10161d;
  --legum-muted: #4a5766;
  --legum-rule: #d6dce3;
  --legum-tint: #f3f6fa;
  --legum-ui-font: "Noto Serif", Georgia, "Times New Roman", serif;
  --statute-header-base: 6.35rem;
  --statute-header-height: 6.35rem;
}
[id] {
  scroll-margin-top: calc(var(--statute-header-height) + 1rem);
}

.statute-noscript {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--legum-tint);
  border-left: 0.25rem solid var(--legum-blue);
  font-family: var(--legum-ui-font);
  font-weight: 600;
}
noscript .statute-noscript a { color: var(--legum-blue); }

/* ---------- shell ---------- */
.statute-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  color: var(--legum-ink);
  background: #fff;
  box-shadow: 0 0.15rem 0.85rem rgba(0, 36, 69, 0.14);
  font-family: var(--legum-ui-font);
  transform: translateY(0);
  transition: transform 200ms ease;
}
.statute-header.is-hidden {
  transform: translateY(calc(-100% - 0.5rem));
}
.statute-header *,
.statute-header *::before,
.statute-header *::after { box-sizing: border-box; }
/* The brand sits in its own column spanning both rows, so the logo can be
   large without making the header any taller than the nav plus the toolbar. */
.statute-header__inner {
  display: flex;
  align-items: stretch;
  width: min(100%, 84rem);
  margin: 0 auto;
}
.statute-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.4rem 1.15rem;
  color: inherit;
  background: #fff;
  text-decoration: none;
}
.statute-brand img {
  display: block;
  width: auto;
  height: 5.6rem;
  transition: height 180ms ease;
}
.statute-brand__copy {
  display: grid;
  line-height: 1.15;
}
.statute-brand__copy strong {
  font-size: clamp(1.15rem, 1.6vw, 1.5rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.statute-brand__copy span {
  margin-top: 0.25rem;
  color: var(--legum-muted);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.statute-header__stack {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.statute-brand:hover .statute-brand__copy strong,
.statute-brand:focus-visible .statute-brand__copy strong { color: var(--legum-blue); }

/* ---------- site navigation ---------- */
.statute-site-nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 1.1rem;
  background: #fff;
}
.statute-site-nav > .statute-menu { width: 100%; }
.statute-menu,
.statute-submenu {
  margin: 0;
  padding: 0;
  list-style: none;
}
.statute-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.1rem 0.15rem;
}
.statute-menu > li { position: relative; }
.statute-menu > li > a,
.statute-nav-parent > a {
  display: block;
  padding: 0.42rem 0.5rem;
  color: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0.15rem;
}
.statute-menu a:hover,
.statute-menu a:focus-visible { color: var(--legum-blue); outline: none; }
.statute-menu > li > a:focus-visible,
.statute-nav-parent > a:focus-visible { outline: 2px solid var(--legum-gold); outline-offset: 1px; }
.statute-menu a[aria-current="page"] {
  color: var(--legum-blue);
  box-shadow: inset 0 -0.16rem 0 var(--legum-gold);
}
.statute-nav-parent {
  display: flex;
  align-items: center;
}
.statute-submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  margin-left: -0.28rem;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0.15rem;
  cursor: pointer;
}
.statute-submenu-toggle svg {
  display: block;
  width: 0.58rem;
  height: 0.58rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: transform 180ms ease;
}
.statute-submenu-toggle:hover,
.statute-submenu-toggle:focus-visible { color: var(--legum-blue); }
.statute-has-submenu.submenu-open .statute-submenu-toggle svg { transform: rotate(180deg); }
.statute-submenu {
  display: none;
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  min-width: 15rem;
  max-width: min(24rem, 88vw);
  max-height: min(28rem, 65vh);
  overflow-y: auto;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--legum-rule);
  border-top: 0.22rem solid var(--legum-blue);
  box-shadow: 0 0.6rem 1.5rem rgba(0, 36, 69, 0.2);
}
.statute-has-submenu:hover > .statute-submenu,
.statute-has-submenu:focus-within > .statute-submenu,
.statute-has-submenu.submenu-open > .statute-submenu { display: block; }
.statute-submenu a {
  display: block;
  padding: 0.45rem 0.6rem;
  color: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  text-decoration: none;
}
.statute-submenu a:hover,
.statute-submenu a:focus-visible { color: #fff; background: var(--legum-blue); outline: none; }

.statute-menu-toggle {
  display: none;
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  margin-left: auto;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid var(--legum-rule);
  border-radius: 0.2rem;
  cursor: pointer;
}
.statute-menu-toggle svg { display: block; width: 1.25rem; height: 1.25rem; margin: 0 auto; fill: currentColor; }
.statute-menu-toggle .statute-icon-close { display: none; }
.statute-header.menu-open .statute-menu-toggle .statute-icon-close { display: block; }
.statute-header.menu-open .statute-menu-toggle .statute-icon-open { display: none; }
.statute-menu-toggle:hover,
.statute-menu-toggle:focus-visible { color: #fff; background: var(--legum-blue); border-color: var(--legum-blue); }

/* ---------- statute toolbar ---------- */
.statute-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 1.1rem;
  background: var(--legum-tint);
}
.statute-toolbar form { margin: 0; }
.statute-tool {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 2.1rem;
  background: #fff;
  border: 1px solid #b9c3cf;
  border-radius: 0.25rem;
}
.statute-tool:focus-within {
  border-color: var(--legum-blue);
  box-shadow: 0 0 0 0.13rem rgba(0, 77, 145, 0.22);
}
.statute-tool__label {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: var(--legum-muted);
  background: #eef2f7;
  border-right: 1px solid #dbe2ea;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.statute-tool input,
.statute-tool select {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 0.45rem;
  color: inherit;
  background: transparent;
  border: 0;
  font-family: var(--legum-ui-font);
  font-size: 0.86rem;
}
.statute-tool input:focus,
.statute-tool select:focus { outline: none; }
.statute-tool input::-webkit-search-cancel-button,
.statute-tool input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.statute-chapters { flex: 4 1 17rem; }
.statute-chapters select { padding-right: 0.2rem; cursor: pointer; }
.statute-goto { flex: 0 0 auto; }
.statute-goto .statute-tool__label { font-size: 0.95rem; letter-spacing: 0; text-transform: none; }
.statute-goto input { width: 5.2rem; flex: 0 0 5.2rem; text-align: center; }
.statute-goto.is-invalid { border-color: #b3261e; box-shadow: 0 0 0 0.13rem rgba(179, 38, 30, 0.2); }
.statute-search { flex: 3 1 15rem; }
.statute-search__count {
  flex: 0 0 auto;
  padding: 0 0.4rem;
  color: var(--legum-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statute-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.4rem;
  color: var(--legum-ink);
  background: #fff;
  border: 1px solid #b9c3cf;
  border-radius: 0.25rem;
  font-family: var(--legum-ui-font);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.statute-btn svg { display: block; width: 1rem; height: 1rem; fill: currentColor; }
.statute-btn:hover:not(:disabled),
.statute-btn:focus-visible {
  color: #fff;
  background: var(--legum-blue);
  border-color: var(--legum-blue);
  outline: none;
}
.statute-btn:focus-visible { box-shadow: 0 0 0 0.13rem rgba(0, 77, 145, 0.3); }
.statute-btn:disabled { opacity: 0.42; cursor: default; }
.statute-tool .statute-btn {
  height: auto;
  align-self: stretch;
  border: 0;
  border-left: 1px solid #e3e9ef;
  border-radius: 0;
  background: transparent;
}
.statute-tool .statute-btn:last-child { border-top-right-radius: 0.2rem; border-bottom-right-radius: 0.2rem; }
.statute-goto .statute-btn { padding: 0 0.6rem; font-weight: 600; }

.statute-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding-left: 0.45rem;
  border-left: 1px solid var(--legum-rule);
}

.statute-message {
  display: none;
  width: min(100%, 84rem);
  margin: 0 auto;
  padding: 0.3rem 1.1rem 0.4rem;
  background: var(--legum-tint);
  color: var(--legum-muted);
  font-size: 0.8rem;
}
.statute-message.is-visible { display: block; }
.statute-message.is-error { color: #8a2018; }

/* ---------- reading progress ---------- */
.statute-progress {
  height: 0.2rem;
  background: #e4eaf1;
  border-bottom: 1px solid rgba(0, 36, 69, 0.08);
}
.statute-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--legum-blue) 0%, var(--legum-gold) 100%);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ---------- compact mode while reading ---------- */
.statute-header.is-compact .statute-brand { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.statute-header.is-compact .statute-brand img { height: 3.4rem; }
.statute-header.is-compact .statute-brand__copy span { display: none; }
.statute-header.is-compact .statute-brand__copy strong { font-size: 1.05rem; }
.statute-header.is-compact .statute-menu > li > a,
.statute-header.is-compact .statute-nav-parent > a {
  padding-top: 0.26rem;
  padding-bottom: 0.26rem;
  font-size: 0.84rem;
}

/* ---------- search highlights (no DOM mutation) ---------- */
::highlight(statute-search) {
  background-color: #ffeaa0;
  color: #10161d;
}
::highlight(statute-search-current) {
  background-color: var(--legum-gold);
  color: #10161d;
}
tr.statute-section-target > td,
.statute-section-target { background-color: #fff4cf; }
tr.statute-section-target > td:first-child { box-shadow: inset 0.18rem 0 0 var(--legum-gold); }

/* ---------- site footer ---------- */
/* Mirrors the footer on the landing page, scoped so it cannot collide with an
   enactment's own styles. Injected by Assets/site-chrome.js. */
.statute-footer {
  /* Full bleed without 100vw: site-chrome.js measures the body's own inset so
     the band reaches the viewport edge with no horizontal overflow. */
  margin: 5rem calc(-1 * var(--statute-bleed-x, 0px)) calc(-1 * var(--statute-bleed-b, 0px));
  color: #fff;
  background: var(--legum-blue);
  font-family: var(--legum-ui-font);
  font-size: 1rem;
  line-height: 1.55;
}
.statute-footer *,
.statute-footer *::before,
.statute-footer *::after { box-sizing: border-box; }
.statute-footer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.2rem 2.4rem;
  width: min(94rem, calc(100% - 7rem));
  margin: 0 auto;
  padding: 4rem 0 0;
}
.statute-footer h2,
.statute-footer h3 {
  margin: 1.2rem 0 0;
  font-size: clamp(0.875rem, 1.33vw, 1.125rem);
  line-height: 1.2;
}
.statute-footer h3:first-child { margin-top: 0; }
.statute-footer p { margin: 1.2rem 0 0; }
.statute-footer a { color: #fff; text-underline-offset: 0.18em; }
.statute-footer a:hover,
.statute-footer a:focus-visible { color: #ffe7a2; }
.statute-footer .statute-footer-brand {
  margin: 0;
  font-size: clamp(1.018rem, 1.783vw, 1.5625rem);
  font-weight: 600;
  /* Tight leading so the brand's cap-height lines up with the other columns'
     headings rather than sitting a few pixels below them. */
  line-height: 1.2;
}
.statute-footer-brand a { text-decoration: none; }
.statute-footer-since { text-align: left; }
.statute-language-link { font-weight: 700; text-decoration: none; }
.statute-footer-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 700;
}
.statute-footer-nav > li { position: relative; width: 100%; }
.statute-footer-nav a { text-decoration: none; }
.statute-footer-nav .statute-nav-parent { justify-content: flex-start; }
.statute-footer-nav .statute-submenu-toggle { color: #fff; }
.statute-footer-nav .statute-submenu {
  left: 0;
  transform: none;
  color: var(--legum-ink);
}
.statute-footer-nav .statute-submenu a { color: var(--legum-ink); }
.statute-footer-nav .statute-submenu a:hover,
.statute-footer-nav .statute-submenu a:focus-visible { color: #fff; }
.statute-social {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
}
.statute-social li { line-height: 0; }
.statute-social a {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.statute-social svg { display: block; width: 1.5rem; height: 1.5rem; fill: currentColor; }
.statute-footer-bottom {
  width: min(102rem, calc(100% - 4rem));
  margin: 3.125rem auto 0;
  padding: 1.25rem 0;
  color: #000;
  background: #d99201;
  border-top: 1px solid #78789f;
}
.statute-footer-bottom p {
  width: min(53.46rem, calc(100% - 2.5rem));
  margin: 0 auto;
  text-align: center;
}
.statute-footer-bottom a,
.statute-footer-bottom a:hover,
.statute-footer-bottom a:focus-visible { color: #000; }

@media (max-width: 68rem) {
  .statute-menu > li > a,
  .statute-nav-parent > a { padding: 0.42rem 0.34rem; font-size: 0.84rem; }
  .statute-brand__copy strong { font-size: 0.98rem; }
}
@media (max-width: 76rem) {
  /* The menu bar needs more width than the toolbar, so it folds away first
     while the brand column and the toolbar row both stay as they are. */
  .statute-menu-toggle {
    display: block;
    order: 3;
    align-self: center;
    margin: 0 0.7rem;
  }
  .statute-header__stack { order: 2; }
  .statute-site-nav {
    display: none;
    padding: 0;
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
  }
  .statute-header.menu-open .statute-site-nav { display: block; }
  .statute-menu {
    display: block;
    width: 100%;
    padding: 0 1.1rem;
  }
  .statute-menu > li { border-bottom: 1px solid #e7ebf0; }
  .statute-menu > li > a,
  .statute-nav-parent > a { padding: 0.7rem 0.2rem; font-size: 0.95rem; }
  .statute-nav-parent { justify-content: space-between; }
  .statute-nav-parent > a { flex: 1 1 auto; }
  .statute-submenu-toggle { width: 2.4rem; height: 2.4rem; margin: 0; }
  .statute-submenu-toggle svg { width: 0.75rem; height: 0.75rem; }
  .statute-has-submenu:hover > .statute-submenu,
  .statute-has-submenu:focus-within > .statute-submenu { display: none; }
  .statute-has-submenu.submenu-open > .statute-submenu {
    display: block;
    position: static;
    transform: none;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0 0 0.35rem;
    border: 0;
    border-left: 0.18rem solid var(--legum-blue);
    box-shadow: none;
  }
  .statute-submenu a { font-size: 0.88rem; padding: 0.5rem 0.7rem; }
}
@media (max-width: 54rem) {
  /* Too narrow for one toolbar row: chapter + section jump, then search. */
  .statute-chapters { flex: 1 1 calc(100% - 10rem); }
  .statute-search { flex: 1 1 calc(100% - 8.5rem); }
}
@media (max-width: 46rem) {
  /* Too narrow for a brand column: brand becomes a row above the toolbar. */
  .statute-header__inner { display: block; position: relative; }
  .statute-brand {
    padding: 0.3rem 0.7rem;
    gap: 0.6rem;
  }
  .statute-brand img { height: 2.9rem; }
  .statute-brand__copy strong { font-size: 1rem; }
  .statute-brand__copy span { font-size: 0.7rem; }
  .statute-menu-toggle {
    position: absolute;
    top: 0.45rem;
    right: 0.7rem;
    margin: 0;
  }
  .statute-menu { padding: 0 0.7rem; }
  .statute-toolbar { gap: 0.35rem; padding: 0.4rem 0.7rem; }
  /* Row one: chapter selector + section jump. Row two: search + actions. */
  .statute-chapters { flex: 1 1 calc(100% - 6.5rem); }
  .statute-search { flex: 1 1 calc(100% - 3.1rem); }
  .statute-goto input { width: 4.1rem; flex: 0 0 4.1rem; }
  .statute-goto .statute-btn { display: none; }
  /* Phones have their own back gesture; keep the row for the search field. */
  #history-back,
  #history-forward { display: none; }
  .statute-actions { padding-left: 0.35rem; }
  .statute-actions .statute-btn { min-width: 1.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .statute-header,
  .statute-brand img,
  .statute-submenu-toggle svg { transition: none; }
}
@media print {
  .statute-header { display: none; }
  body { padding: 2%; }
  [id] { scroll-margin-top: 0; }
}

@media (max-width: 64rem) {
  .statute-footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
}
@media (max-width: 48.8125rem) {
  .statute-footer-grid { grid-template-columns: 1fr; gap: 1.2rem; width: calc(100% - 3rem); }
  .statute-footer-bottom { width: calc(100% - 3rem); }
}
@media print {
  .statute-footer { display: none; }
}
