/* Site chrome: the header band, the phone menu and the footer, on every page.
   Pages link this file and chrome.js as ?v=N; when either changes, bump N on every page,
   in sw.js PRECACHE and in _dev/verify-links.mjs, or browsers pair new markup with old CSS.
   The markup comes from /site-links.js (chromeHeader, chromeFooter), baked between
   <!-- chrome:header --> and <!-- chrome:footer --> markers by _dev/bake-links.mjs;
   never edit it in a page. It reads each page's look tokens from /assets/tokens.css:
   --bg, --ink, --muted, --accent, --maxw, --gutter, --sans, and on the Lav look also
   --hairline and the UI, Caption and Statement type roles. A look without those (the
   finance look) gets the Lav sizes from the fallbacks written here and --line for the
   hairline, so the structure, type sizes and spacing are the same on every page and
   only the palette and the typeface follow the page.
   Two variants of the header: the homepage one (homeNav), and .site-head--finance on
   /finance pages (financeNav, EN|SV, the Settings button, the menu from 1099 px down).
   Markup contract:

     <header class="site-head" id="site-head">
       <span class="site-head__line" aria-hidden="true"></span>
       <div class="site-head__in">
         <a class="site-head__name" href="/">Matthew MacLaine</a>
         <nav class="site-nav" id="site-nav" aria-label="Site"> <a>...</a>
           <span class="site-nav__group"> <a>Things I build</a> <span class="site-nav__sub"> <a>...</a> </span> </span>
           <span class="site-nav__spy"></span> </nav>
         <div class="site-head__right">
           <button class="menu-btn" aria-expanded="false" aria-controls="site-menu">Menu</button>
           <button class="theme-btn" aria-label="Switch to dark"><span class="theme-btn__ring"><span class="theme-btn__disc"></span></span></button>
         </div>
       </div>
       <nav class="site-menu" id="site-menu" aria-label="Site" hidden></nav>   (filled by chrome.js from .site-nav)
     </header>
     <footer class="site-foot" id="contact"> <div class="site-foot__in"> .site-foot__about + .site-foot__cols (three <div>s of .footer-col-title + .footer-links) </div> </footer>
   The finance variant adds .site-lang and .settings-btn to .site-head__right and
   .site-foot__sources to .site-foot__about.

   Behaviour (background once scrolled, the menu, the theme switch, the nav underline) is
   in /assets/chrome.js. Nothing in here animates; the homepage's load sequence does. */

.skip-link {
  position: fixed; top: 0; left: 0; z-index: 100; transform: translateY(-120%);
  padding: 10px 14px; margin: 8px; border: 1px solid var(--accent); border-radius: 4px;
  background: var(--bg); color: var(--ink); font-size: var(--t-ui, 15px); line-height: var(--lh-ui, 20px); text-decoration: none;
}
.skip-link:focus { transform: none; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Header: 64 px, a hairline under it. Transparent over the hero at rest, the page
   colour once scrolled (no blur, no height change, so nothing jumps). ── */
.site-head {
  position: sticky; top: 0; z-index: 20;
  height: 64px;
  background: transparent;
  transition: background-color .3s var(--ease, ease);
}
.site-head.is-scrolled, .site-head.is-open { background: var(--bg); }
.site-head__in {
  position: relative; height: 100%;
  max-width: var(--chrome-maxw, var(--maxw, 1440px)); margin: 0 auto; padding: 0 var(--gutter, 56px);
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 16px; align-items: center;
  font-family: var(--sans); font-size: var(--t-ui, 15px); line-height: var(--lh-ui, 20px); font-weight: 400; color: var(--ink);
}
/* the hairline is a child of the band itself, so it spans the whole width */
.site-head__line { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--hairline, var(--line)); transform-origin: 0 50%; pointer-events: none; }
.site-head__name { grid-column: 1 / span 4; justify-self: start; color: var(--ink); text-decoration: none; white-space: nowrap; padding: 6px 0; }
.site-nav { grid-column: 7 / span 5; position: relative; display: flex; gap: 28px; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 6px 0; border-bottom: 1px solid transparent; white-space: nowrap; transition: border-color .2s var(--ease, ease); }
.site-nav a:hover { border-bottom-color: var(--ink); }
/* Things I build: the tools under it, in a panel just below the band, on hover or keyboard focus.
   The panel's ::before bridges the gap so the pointer can travel down to it. */
.site-nav__group { position: relative; display: flex; }
.site-nav__sub {
  position: absolute; top: calc(100% + 18px); left: -13px; z-index: 21;
  display: flex; flex-direction: column; min-width: 220px; padding: 8px 0;
  background: var(--bg); border: 1px solid var(--hairline, var(--line)); border-radius: 16px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .2s var(--ease, ease), transform .2s var(--ease, ease), visibility 0s linear .2s;
}
.site-nav__sub::before { content: ""; position: absolute; left: 0; right: 0; top: -19px; height: 19px; }
.site-nav__group:hover .site-nav__sub, .site-nav__group:focus-within .site-nav__sub { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.site-nav .site-nav__sub a { padding: 8px 12px; border-bottom: 0; color: var(--muted); transition: color .2s var(--ease, ease); }
.site-nav .site-nav__sub a:hover, .site-nav .site-nav__sub a[aria-current] { color: var(--ink); }
.site-nav__spy { position: absolute; left: 0; bottom: 0; width: 0; height: 1px; background: var(--ink); opacity: 0; pointer-events: none; }
.site-head__right { grid-column: 12; justify-self: end; display: flex; align-items: center; gap: 0; }
.menu-btn { display: none; height: 44px; padding: 0 12px; font: inherit; color: var(--ink); background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.theme-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.theme-btn__ring { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--muted); display: grid; place-items: center; transition: border-color .2s var(--ease, ease); }
.theme-btn:hover .theme-btn__ring { border-color: var(--ink); }
.theme-btn__disc { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); }
.theme-btn:focus-visible, .menu-btn:focus-visible, .site-nav a:focus-visible, .site-head__name:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.theme-btn:focus-visible { border-radius: 50%; }

/* The menu: a solid band under the header with the links at the Statement size. It opens
   wherever the Menu button shows (phones; finance pages from 1099 px down). */
.site-menu {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 19;
  display: flex; flex-direction: column;
  padding: 12px var(--gutter, 20px) 28px;
  background: var(--bg); border-bottom: 1px solid var(--hairline, var(--line));
}
.site-menu[hidden] { display: none; }
.site-menu a { display: block; padding: 10px 0; color: var(--ink); text-decoration: none; font-size: var(--t-statement, 28px); line-height: var(--lh-statement, 1.143); letter-spacing: var(--tr-statement, -0.015em); }
.site-menu a[aria-current] { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
/* the tools under Things I build, smaller and indented under it */
.site-menu a.site-menu__sub { padding: 11px 0 11px 16px; font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); letter-spacing: 0; color: var(--muted); }
.site-menu a.site-menu__sub + a:not(.site-menu__sub) { margin-top: 6px; }
.site-menu a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
/* the language switch, copied into the menu by chrome.js on finance pages */
.site-menu .site-lang { margin-top: 16px; }
@media (min-width: 861px) { .site-menu .site-lang { display: none; } }   /* the header shows it there */
.site-menu .site-lang a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; padding: 0 8px; font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); letter-spacing: 0; }
.site-menu .site-lang a:first-child { padding-left: 0; min-width: 36px; }

/* Between a laptop and the design's 1440 the nav starts further left so six links still fit. */
@media (max-width: 1199px) {
  .site-nav { grid-column: 5 / span 7; }
}

@media (max-width: 860px) {
  .site-head { height: 56px; }
  .site-head__in { display: flex; justify-content: space-between; gap: 12px; padding: 0 8px 0 var(--gutter, 20px); font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); }
  .site-head__name { padding: 11px 0; }
  .site-nav { display: none; }
  .site-head.no-js .site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .site-nav__sub { display: none; }
  .site-head.no-js .menu-btn { display: none; }
  .menu-btn { display: inline-block; }
  .theme-btn { width: 44px; height: 44px; }
}

/* ── The finance header: financeNav (seven links), EN|SV, Settings, the theme switch.
   The finance pages run full width, so the band does too (their left edge is the
   gutter at every width). It keeps the old finance nav's stacking level, above the
   tools' own sticky bars. ── */
.site-head--finance { z-index: 50; }
.site-head--finance, .site-foot--finance { --chrome-maxw: none; }
.site-head--finance .site-head__name { grid-column: 1 / span 3; }
.site-head--finance .site-nav { grid-column: 4 / span 7; gap: 24px; }
.site-head--finance .site-head__right { grid-column: 11 / span 2; gap: 4px; }
.site-nav a[aria-current] { border-bottom-color: var(--ink); }
.site-lang { display: flex; align-items: center; margin-right: 8px; white-space: nowrap; }
.site-lang a { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 32px; padding: 0 2px; color: var(--muted); text-decoration: none; transition: color .2s var(--ease, ease); }
.site-lang a:hover, .site-lang a[aria-current] { color: var(--ink); }
.site-lang__sep { color: var(--muted); padding: 0 2px; }
.site-lang a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.site-head .settings-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; color: var(--ink); background: none; border: 0; border-radius: 50%; cursor: pointer; transform: none; transition: opacity .2s var(--ease, ease); -webkit-tap-highlight-color: transparent; }
.site-head .settings-btn:hover { opacity: .7; transform: none; }
.site-head .settings-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 1099px) and (min-width: 861px) {
  .site-head--finance .site-head__name { grid-column: 1 / span 4; }
  .site-head--finance .site-nav { display: none; }
  .site-head--finance .site-head__right { grid-column: 5 / span 8; }
  .site-head--finance .menu-btn { display: inline-block; }
  .site-head--finance.no-js .site-nav { display: flex; grid-column: 4 / span 9; flex-wrap: wrap; gap: 4px 16px; }
  .site-head--finance.no-js .menu-btn { display: none; }
}
@media (max-width: 860px) {
  .site-head--finance .site-head__right { gap: 0; }
  .site-head--finance .site-head__right > .site-lang { display: none; }
  .site-head .settings-btn { width: 44px; height: 44px; }
}

/* ── Footer: a hairline on top, the about text left, three link columns from column 7 (four from column 6 on finance pages). ── */
.site-foot { border-top: 1px solid var(--hairline, var(--line)); font-family: var(--sans); color: var(--muted); }
.site-foot__in {
  max-width: var(--chrome-maxw, var(--maxw, 1440px)); margin: 0 auto; padding: 56px var(--gutter, 56px) 88px;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 16px;
}
.site-foot__about { grid-column: 1 / span 5; display: flex; flex-direction: column; gap: 12px; max-width: 28em; }
.site-foot__about p { margin: 0; font-size: var(--t-ui, 15px); line-height: 22px; color: var(--muted); text-wrap: pretty; }
.site-foot__about .site-foot__copy, .site-foot__about .site-foot__sources { font-size: var(--t-caption, 13px); line-height: var(--lh-caption, 18px); letter-spacing: var(--tr-caption, 0.01em); }
.site-foot__cols { grid-column: 7 / span 6; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 16px; }
/* Finance pages add a fourth column (the suite's own links): four across from column 6 on a wide
   screen, two by two between that and the phone layout, which stays two columns as everywhere. */
@media (min-width: 861px) { .site-foot--finance .site-foot__cols { grid-column: 6 / span 7; } }
@media (min-width: 1281px) { .site-foot--finance .site-foot__cols { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.site-foot .footer-col-title { margin: 0 0 16px; font-size: var(--t-ui, 15px); line-height: var(--lh-ui, 20px); font-weight: 400; color: var(--ink); }
.site-foot .footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.site-foot .footer-links a { font-size: var(--t-ui, 15px); line-height: var(--lh-ui, 20px); color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 1px solid transparent; transition: color .2s var(--ease, ease), border-color .2s var(--ease, ease); }
.site-foot .footer-links a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.site-foot .footer-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

@media (max-width: 1280px) and (min-width: 861px) {
  .site-foot--finance .site-foot__cols { row-gap: 28px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .site-foot__in { display: flex; flex-direction: column; gap: 36px; padding: 40px var(--gutter, 20px) 64px; }
  .site-foot__about { gap: 10px; }
  .site-foot__about p { font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); }
  .site-foot__about .site-foot__copy, .site-foot__about .site-foot__sources { font-size: var(--t-caption, 13px); line-height: var(--lh-caption, 18px); }
  .site-foot__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
  .site-foot .footer-col-title { margin-bottom: 4px; font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); }
  .site-foot .footer-links { gap: 0; }
  .site-foot .footer-links a { display: block; padding: 11px 0; font-size: var(--t-ui, 16px); line-height: var(--lh-ui, 22px); border-bottom: 0; }
  .site-foot .footer-links a:active { color: var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
  .site-head, .site-nav a, .site-nav__sub, .theme-btn__ring, .site-foot .footer-links a, .site-lang a, .site-head .settings-btn { transition: none; }
}
