/* Phones and tablets, from Kieran's "CoSWAT Mobile" frames. Below 1100 px: the compact header (logo, the account
   avatar or sign-in icon, the menu button that opens the "Explore CoSWAT" card). Below 760 px: the bottom tab bar too. From 1100 px nothing here applies except hiding the parts below. Map pages and
   their sheets read --site-header-height and --tabbar-height; a page leaves the tab bar out with
   {% block tabbar %}{% endblock %}. */
.site-tabbar, .nav-card-head, .nav-links > a > .nav-icon, .nav-links > a > .nav-chevron, .home-phone, .updates-title,
.research-filter, .about-phone-card, .about-phone-built, .about-contents .about-icon, .about-contents .about-chevron { display: none; }

@media (max-width: 1099px) {
  body { --site-header-height: 60px; --tabbar-height: 0px; }

  /* Header: one 60 px row; the page links open below it. Above the map pages' sheets (900 to 950). */
  .site-header.site-header { position: relative; z-index: 1000; }
  .site-header .navbar { min-height: var(--site-header-height); padding: 0 12px 0 16px; gap: 6px; flex-wrap: nowrap; align-items: center; }
  .site-header .brand { flex-direction: column; align-items: flex-start; gap: 2px; min-height: var(--site-header-height); justify-content: center; margin-right: auto; font-size: 21px; }
  .site-header .brand-wordmark { height: 24px; }

  /* The menu button opens the page links as a card ("Explore CoSWAT") over a blurred page; phone.js moves the account
     control out of the links into the header row. */
  .site-header .nav-links { display: none; }
  .site-header .nav-links.is-open { position: fixed; z-index: 1100; top: calc(var(--site-header-height) + 10px); left: 12px; right: 12px; display: block; width: auto; max-height: calc(100dvh - var(--site-header-height) - 20px); padding: 4px 0 8px; overflow-y: auto; border: 0; border-radius: 16px; background: #fff; color: #10233a; box-shadow: 0 12px 36px #0f2c4d4d; }
  .site-header .navbar:has(.nav-links.is-open)::after { content: ""; position: fixed; inset: var(--site-header-height) 0 0; z-index: 1050; background: #0f2c4d59; backdrop-filter: blur(2px); }
  .site-header .nav-links.is-open .nav-card-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 18px; }
  .site-header .nav-card-head p { margin: 0; font-size: 20px; font-weight: 700; }
  .site-header .nav-card-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: #10233a; cursor: pointer; }
  .site-header .nav-card-close svg, .site-header .nav-links > a > svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
  .site-header .nav-card-close svg { width: 22px; height: 22px; stroke-width: 1.8; }
  .site-header .nav-links.is-open > a { display: flex; align-items: center; gap: 14px; min-height: 52px; margin: 0 12px; padding: 0 4px 0 6px; border-top: 1px solid #eef1f5; border-radius: 0; background: transparent; color: #10233a; font-size: 16px; font-weight: 500; }
  .site-header .nav-links.is-open > a:hover { color: #1462d1; }
  /* Some pages draw a tab under the current link (Home's uses the hero image); not in the card. */
  .site-header .nav-links.is-open > a::before, .site-header .nav-links.is-open > a::after { display: none !important; }
  .site-header .nav-links.is-open > a[aria-current] { min-height: 52px; margin-block: 0; padding-inline: 4px 4px; border-radius: 0; background: none; color: #1462d1; font-weight: 700; }
  .site-header .nav-links.is-open > a > .nav-icon { display: block; flex: none; width: 22px; height: 22px; stroke-width: 1.6; }
  .site-header .nav-links.is-open > a > .nav-chevron { display: block; flex: none; width: 18px; height: 18px; margin-left: auto; stroke: #5b6b7c; stroke-width: 1.8; }
  .site-header .navbar > .sign-in, .site-header .navbar > .account-menu { order: 1; }
  .site-header .navbar > .sign-in { display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; margin: 0; padding: 0; border-radius: 50%; background: transparent; color: #fff; }
  .site-header .navbar > .sign-in:hover { background: #ffffff1f; color: #fff; }
  .site-header .menu-toggle { order: 2; display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; font-size: 0; }
  .site-header .menu-toggle span { margin: 0; font-size: 22px; line-height: 1; }
}

/* Home: the updates are a section under the content up to 1402 px. The overlaid pane covers tiles at every width up to
   1402 (measured at window heights from 650 to 1080 px; from 1403 it clears them at all of those), so tiles are never
   overlaid. */
@media (max-width: 1402px) {
  .home-page .page-content { display: block; }
  /* The room kept under the tiles for the overlaid pane is not needed. */
  .home-page .home-content.home-content { padding-bottom: 8px; }
  .home-page .updates-reopen, .home-page .updates-heading { display: none !important; }
  .home-page.home-page .updates-pane { position: static; display: block; width: auto; max-width: none; height: auto; min-height: 0; margin: 0; padding: 8px 20px 24px; border: 0; background: #f4f7fa; }
  .home-page .updates-pane::before { display: none; }
  .home-page .updates-title { display: block; margin: 8px 0 4px; padding: 0; background: none; color: #10233a; font-size: 20px; }
  .home-page .updates-list { overflow: visible; }
}

/* Home's hero buttons at 44 px where the compact header is (Josie's note). */
@media (max-width: 1099px) {
  .home-page .hero-button { min-height: 44px; padding-inline: 16px; font-size: 13px; }
}

/* Tablets: the menu card under the menu button, not across the screen. */
@media (min-width: 760px) and (max-width: 1099px) {
  .site-header .nav-links.is-open { left: auto; width: 380px; }
}

@media (max-width: 759px) {
  body:has(.site-tabbar) { --tabbar-height: calc(64px + env(safe-area-inset-bottom, 0px)); padding-bottom: var(--tabbar-height); }
  /* Explore keeps its own bottom sheet, so no tab bar there (Calibration and the sign-in pages leave it out in their
     templates). */
  body.explore-page .site-tabbar { display: none; }
  body.explore-page:has(.site-tabbar) { --tabbar-height: 0px; padding-bottom: 0; }

  /* Home: Kieran's frame, a hero card with the emblem and "Open the map", then the sections as rows. */
  .home-page .hero-slideshow, .home-page .home-hero, .home-page .home-stats, .home-page .home-pathways, .home-page .page-content::before { display: none; }
  .home-page .home-phone { display: block; padding: 20px 16px 8px; }
  .home-phone-hero { padding: 24px 22px 22px; border: 1px solid #dbe5ef; border-radius: 18px; background: linear-gradient(180deg, #eef4fa, #f8fbfe); }
  .home-phone-hero img { display: block; width: 150px; height: 150px; margin: 0 auto 18px; }
  .home-phone-eyebrow { margin: 0 0 6px; color: #3d5670; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .home-phone-hero h1 { margin: 0 0 10px; color: #10233a; font-size: 32px; line-height: 1.12; letter-spacing: -.5px; }
  .home-phone-hero p:not(.home-phone-eyebrow) { margin: 0 0 18px; color: #3d5670; font-size: 15px; line-height: 1.45; }
  .home-phone-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 10px; background: #1462d1; color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; }
  .home-phone-button svg, .home-phone-icon svg, .home-phone-chevron { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .home-phone-button svg { width: 22px; height: 22px; }
  .home-phone-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
  .home-phone-stats li { display: grid; gap: 4px; padding: 14px; border: 1px solid #dbe5ef; border-radius: 14px; background: #fff; text-align: center; }
  .home-phone-stats strong { color: #10233a; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
  .home-phone-stats span { color: #3d5670; font-size: 14px; }
  .home-phone-links { margin: 14px 0 0; padding: 0; list-style: none; }
  .home-phone-links li + li { margin-top: 10px; }
  .home-phone-links a { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 12px 14px; border: 1px solid #dbe5ef; border-radius: 14px; background: #fff; color: #10233a; text-decoration: none; }
  .home-phone-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 10px; background: #e8f0fa; color: #1462d1; }
  .home-phone-icon svg { width: 24px; height: 24px; }
  .home-phone-text { display: grid; flex: 1; gap: 3px; }
  .home-phone-text strong { font-size: 17px; }
  .home-phone-text span { color: #3d5670; font-size: 14px; line-height: 1.4; }
  .home-phone-chevron { flex: none; width: 20px; height: 20px; stroke: #5b6b7c; }

  /* Research and About: Kieran's frames. */
  .reading-page .reading-main { padding: 22px 18px 28px; }
  .reading-page .reading-heading { margin-bottom: 18px; }
  .reading-page .reading-heading h1 { margin: 0 0 6px; font-size: 32px; }
  .reading-page .reading-heading > p:last-child { font-size: 15px; line-height: 1.5; }
  .research-page .reading-kicker { display: none; }
  .research-page .research-filter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 8px; padding: 4px; border-radius: 12px; background: #eef3f8; }
  .research-filter button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: #10233a; font: 600 15px "Fira Sans", Arial, Helvetica, sans-serif; cursor: pointer; }
  .research-filter button[aria-pressed="true"] { background: #fff; color: #1462d1; box-shadow: 0 1px 4px #0f2c4d1f; }
  .research-list[data-show="paper"] .research-entry:not([data-kind="paper"]),
  .research-list[data-show="assessment"] .research-entry:not([data-kind="assessment"]) { display: none; }
  .research-page .research-entry { gap: 8px; padding: 18px 0; }
  .research-page .research-date { justify-content: space-between; }
  .research-page .research-date time { order: 2; color: #3d5670; font-size: 13px; }
  .research-page .research-date span { order: 1; padding: 3px 10px; border-radius: 999px; background: #e8f0fa; color: #1f4f88; font-size: 12px; }
  .research-page .research-entry h2 { margin: 2px 0 6px; font-size: 21px; line-height: 1.3; }
  .research-page .research-entry p:not(.publication-source) { margin: 6px 0; font-size: 14.5px; line-height: 1.55; }
  /* The title first, then the source and authors (as in the frame). */
  .research-page .research-entry > div:last-child { display: flex; flex-direction: column; }
  .research-page .research-entry h2 { order: 1; }
  .research-page .research-entry .publication-source { order: 2; margin: 0; color: #3d5670; font-size: 13.5px; }
  .research-page .research-entry .publication-authors { order: 3; }
  .research-page .research-entry > div:last-child > p:not(.publication-source):not(.publication-authors) { order: 4; }
  .research-page .research-entry .publication-links { order: 5; }
  .reading-page .publication-links a, .reading-page .reading-link { gap: 6px; text-decoration: none; }
  .reading-page .publication-links a[href^="http"]::after, .reading-page .reading-link[href^="http"]::after { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat; }
  .reading-page .publication-links { gap: 0 20px; margin-top: 6px; }
  .reading-page .publication-links a, .reading-page .reading-link, .reading-page .model-citation a { display: inline-flex; align-items: center; min-height: 44px; color: #1462d1; font-size: 15px; }
  .about-page .reading-kicker { order: 2; margin: 0; }
  .about-page .reading-heading { display: flex; flex-direction: column; }
  .about-page .reading-heading h1 { order: 1; }
  .about-page .reading-heading > p:last-child { display: none; }
  .about-page .about-phone-card { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 18px; padding: 16px; border: 1px solid #dbe5ef; border-radius: 16px; background: linear-gradient(180deg, #eef4fa, #f8fbfe); }
  .about-phone-card img { flex: none; width: 64px; height: 64px; }
  .about-phone-card p { margin: 0; color: #3d5670; font-size: 14.5px; line-height: 1.45; }
  .about-phone-card .about-phone-title { margin-bottom: 8px; color: #10233a; font-size: 22px; font-weight: 700; line-height: 1.15; }
  .about-page .about-layout { gap: 18px; padding-top: 0; border-top: 0; }
  .about-page .about-contents { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; }
  .about-page .about-contents::before { content: "On this page"; margin-bottom: 4px; color: #3d5670; font-size: 13px; font-weight: 600; }
  .about-page .about-contents a { display: flex; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid #e4e8ee; color: #10233a; font-size: 16px; font-weight: 600; }
  .about-contents .about-icon, .about-contents .about-chevron { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .about-contents .about-icon { width: 22px; height: 22px; }
  .about-contents .about-chevron { width: 18px; height: 18px; margin-left: auto; stroke: #5b6b7c; }
  .about-page .about-phone-built { display: block; }
  .about-phone-built h2 { margin: 6px 0 6px; font-size: 22px; }
  .about-phone-built p { margin: 0 0 12px; color: #3d5670; font-size: 15px; line-height: 1.45; }
  .about-phone-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 10px; background: #1462d1; color: #fff !important; font-size: 16px; font-weight: 600; text-decoration: none !important; }
  .about-phone-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .about-page .model-citation { padding: 14px 16px; border: 1px solid #dbe5ef; border-left: 1px solid #dbe5ef; border-radius: 14px; }

  /* Bottom tab bar. */
  .site-tabbar { position: fixed; z-index: 960; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #d5e0ea; background: #fff; box-shadow: 0 -2px 10px #0f2c4d14; }
  .site-tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 10px; color: #3d5876; font-size: 12px; font-weight: 500; text-decoration: none; }
  .site-tabbar a[aria-current] { background: #e8f0fa; color: #1462d1; font-weight: 700; }
  .site-tabbar a:focus-visible { outline: 3px solid #0f2c4d; outline-offset: -3px; }
  .site-tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
}
