/* Shared layer on top of each page's inline styles: skip link, video placeholders, reading width,
   one-row header from 1240px, Menu button below 1240px, phone spacing and touch targets below 640px. */

.menu-btn { display: none; }

/* Skip link: hidden until focused with the keyboard */
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 16px; top: 12px; z-index: 50; background: #0A1A2A; color: #FFFFFF; padding: 12px 18px; border-radius: 4px; font-family: 'Schibsted Grotesk', system-ui, sans-serif; font-weight: 600; }

/* Video placeholders: a still frame that loads YouTube only when played */
.yt-lite { position: relative; display: block; width: 100%; height: 100%; background: #12263A; color: #FFFFFF; text-decoration: none; }
.yt-lite img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-play { position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; margin: -24px 0 0 -34px; border-radius: 12px; background: rgba(10, 26, 42, 0.82); transition: background .15s ease; }
.yt-play::after { content: ""; position: absolute; left: 27px; top: 14px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #FFFFFF; }
.yt-lite:hover .yt-play, .yt-lite:focus-visible .yt-play { background: #14B8D9; }
.yt-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Reading width on wide screens: keep running text under about 70 characters a line */
@media (min-width: 1024px) {
  main p, main ul, .pg-fig .fig-sub { max-width: 62ch; }
}

/* Laptops and desktops: logo and links on one row */
@media (min-width: 1240px) {
  .site-header { flex-wrap: nowrap !important; }
  .site-header nav { flex-wrap: nowrap !important; gap: 8px 18px !important; white-space: nowrap; }
}

@media (max-width: 1239px) {
  /* Header: logo and a Menu button; the links open as a full-width list */
  .site-header { padding: 16px 32px !important; gap: 0 12px !important; flex-wrap: wrap !important; }
  .site-header > a:first-child { flex: 1 1 0; min-width: 0; max-width: max-content; gap: 10px !important; }
  .site-header > a:first-child svg { width: 30px; height: 30px; }
  .site-header > a:first-child > span > span:first-child { font-size: 16px !important; }
  .site-header > a:first-child > span > span:last-child { font-size: 12px !important; }
  .menu-btn { flex: none; }
  .site-header > a:first-child img { height: auto !important; width: 100% !important; max-width: 260px; }
  .js .menu-btn {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 44px; padding: 0 16px; margin-right: -8px;
    font: inherit; font-size: 15px; font-weight: 600; color: #0A1A2A;
    background: transparent; border: 1px solid #C9D3DD; border-radius: 999px; cursor: pointer;
  }
  .menu-btn .bars { position: relative; width: 16px; height: 10px; }
  .menu-btn .bars::before, .menu-btn .bars::after {
    content: ""; position: absolute; left: 0; right: 0; height: 2px; background: #0A1A2A; border-radius: 2px;
    transition: transform .2s ease, top .2s ease;
  }
  .menu-btn .bars::before { top: 0; }
  .menu-btn .bars::after { top: 8px; }
  .menu-btn[aria-expanded="true"] .bars::before { top: 4px; transform: rotate(45deg); }
  .menu-btn[aria-expanded="true"] .bars::after { top: 4px; transform: rotate(-45deg); }

  .js .site-header nav { display: none !important; }
  .js .site-header.open nav {
    display: flex !important; flex-direction: column; align-items: stretch !important; flex-wrap: nowrap !important;
    gap: 0 !important; width: 100%; margin-top: 14px; padding-top: 6px; border-top: 1px solid #DCE3EA;
    font-size: 18px !important;
  }
  .js .site-header.open nav a {
    display: flex !important; align-items: center; min-height: 52px; padding: 0 2px !important;
    border-bottom: 1px solid #E8EEF3; text-decoration: none !important;
  }
  .js .site-header.open nav a[aria-current="page"] { color: #0E6F86; box-shadow: inset 3px 0 0 #14B8D9; padding-left: 14px !important; }
  .js .site-header.open nav a[href="/contact"] {
    justify-content: center; margin: 18px 0 8px; border-bottom: 0; border-radius: 4px; min-height: 52px; padding: 0 20px !important;
  }
}

@media (max-width: 640px) {
  /* Side gutters: one consistent 24px */
  [style*="padding:"][style*=" 32px"]:not(nav):not(a) { padding-left: 24px !important; padding-right: 24px !important; }
  .pg-hero, .pg-sec { padding-left: 24px !important; padding-right: 24px !important; }

  /* Vertical rhythm: desktop section padding (80 to 128px) is too tall on a phone */
  [style*="padding: 80px"], [style*="padding: 88px"], [style*="padding: 104px"],
  [style*="padding: 112px"], [style*="padding: 120px"], [style*="padding: 128px"] { padding-top: 64px !important; }
  [style*="32px 88px"], [style*="32px 96px"], [style*="32px 104px"], [style*="32px 112px"], [style*="32px 120px"],
  [style*="padding: 88px 32px;"], [style*="padding: 104px 32px;"], [style*="padding: 112px 32px;"],
  [style*="padding: 120px 32px;"], [style*="padding: 128px 32px;"] { padding-bottom: 72px !important; }
  .pg-sec { padding-top: 56px !important; padding-bottom: 56px !important; }
  #top { padding-top: 24px !important; padding-bottom: 64px !important; }

  /* Home hero: the tangled-lines drawing is decoration; on a phone it only pushes the content down */
  #top svg[aria-label^="Fifteen tangled"] { display: none !important; }

  /* Touch targets: small text links get a 44px tap height */
  #papers li a, .paper-links a, a[download],
  a[style*="font-weight: 600"]:not([style*="padding"]):not(p a), footer a:not(p a), a[href^="tel:"] { display: inline-flex; align-items: center; min-height: 44px; }

  /* Long email addresses wrap at sensible points */
  a[href^="mailto:"] { overflow-wrap: break-word; word-break: normal; font-size: 14px; letter-spacing: -0.005em; }

  /* Network: profiles collapse to name and summary, with a button for the full profile */
  .bio-toggle {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
    font: inherit; font-size: 15px; font-weight: 600; color: #0A1A2A; background: #FFFFFF;
    border: 1px solid #C9D3DD; border-radius: 999px; cursor: pointer;
  }
  .bio-toggle::after { content: "+"; font-size: 18px; line-height: 1; color: #0E6F86; }
  .bio-toggle[aria-expanded="true"]::after { content: "\2212"; }
  article.bio-collapsible { padding-top: 32px !important; padding-bottom: 32px !important; gap: 16px !important; }
}
