/* Site chrome: the shared Carbon Eyes header and footer.
 *
 * A hand-written replacement for the Squarespace export (no Squarespace CSS or JS
 * needed). Markup is rendered by site-chrome.js; see docs/site-chrome.md.
 *
 * Contents
 *   1. Tokens and base
 *   2. Header bar (logo, nav, actions)
 *   3. Desktop dropdowns
 *   4. Phone/tablet: burger + full-screen menu
 *   5. Footer
 *   6. Page typography (.site-theme)
 *   7. Page sections (.page-section)
 *
 * Breakpoints (same as the Squarespace original)
 *   header: burger menu at <= 799px, or on touch devices <= 1024px
 *   footer: single-column layout at <= 767px
 */

/* ---------- 1. Tokens and base ---------- */

:root {
  --chrome-navy: #233161;      /* text, rules, burger */
  --chrome-blue: #2a75b7;      /* links, Sign Up button */
  --chrome-bg: #fff;
  --chrome-gutter: 3vw;        /* page side padding */
  --chrome-max-width: 1500px;  /* footer content width cap */
  --chrome-font: Inter, system-ui, sans-serif;
  /* Fluid type, as Squarespace did it: a 14px base plus a multiple of --chrome-u.
   * Body text is 14px + 0.06u (about 15px on a laptop); an h1 is 14px + 4.1u (about 85px). */
  --chrome-u: 1.2vw;
  --chrome-font-size: calc(14px + 0.06 * var(--chrome-u));
  --chrome-heading-font: "Hanken Grotesk", Inter, system-ui, sans-serif;
  /* --site-header-h is set by site-chrome.js to the header's measured height. */
}

@media (max-width: 767px) {
  :root { --chrome-u: min(1.2vh, 10.8px); }
}

/* Page styles were written against Squarespace's 14px root, so rem sizes depend on it. */
html { font-size: 14px; }
body { margin: 0; background: var(--chrome-bg); color: var(--chrome-navy); }
site-header, site-footer { display: contents; }

.header, .footer {
  font-family: var(--chrome-font);
  color: var(--chrome-navy);
  -webkit-font-smoothing: antialiased;
}
.header *, .footer * { box-sizing: border-box; }

/* The header is fixed, so content must start below it. Opt in per page. */
.below-site-header { padding-top: var(--site-header-h, 104px); }

/* ---------- 2. Header bar ---------- */

.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;                      /* above sticky page bars, below page modals (100+) */
  font-size: var(--chrome-font-size);
  line-height: 1;
}

.header-inner {
  position: relative;
  z-index: 2;                       /* stays above the open phone menu */
  display: flex;
  align-items: center;
  padding: 1vw var(--chrome-gutter);
  background: var(--chrome-bg);
}

/* Logo and actions each take a third; the nav sits centred between them. */
.header-title,
.header-actions { flex: 1 0 33%; min-width: 0; }

.header-title { line-height: 0; }
/* Fixed width + aspect ratio reserve the logo's space before the image loads, so the
 * header height (which pages measure) is right from the first paint. */
.header-title img { display: block; width: 300px; max-width: 100%; height: auto; aspect-ratio: 4 / 1; }

.header-nav { flex: 0 1 auto; padding: 0 1.6vw; }
.header-nav-list { display: flex; flex-wrap: wrap; justify-content: center; }
.header-nav-item { position: relative; margin: 0 0.6vw; line-height: 1.59; }

.header a { color: inherit; text-decoration: none; }
.header-nav-item > a,
.header-nav-item > button {
  display: block;
  padding: 0.1em 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.header-actions { display: flex; justify-content: flex-end; align-items: center; }
.header-actions button { font-family: inherit; }   /* Log In / Log Out, added by the page */
.header-actions svg,
.header-menu-actions svg { display: block; width: 15px; height: 15px; fill: currentColor; }
.header-menu-actions svg { width: 20px; height: 20px; }

/* ---------- 3. Desktop dropdowns ---------- */

.header-nav-folder {
  display: none;
  position: absolute;
  top: 100%;
  left: -1em;
  z-index: 10;
  padding: 0.5em 1em;
  border-radius: 8px;
  background: var(--chrome-bg);
  text-align: left;
  white-space: nowrap;
}
.header-nav-item:hover > .header-nav-folder,
.header-nav-item:focus-within > .header-nav-folder { display: block; }

.header-nav-folder a {
  display: block;
  padding: 10px 15px;
  font-size: 16px;
  line-height: 1.3;
}
.header-nav-folder a:hover { opacity: 0.7; }

/* ---------- 4. Phone/tablet: burger + full-screen menu ---------- */

.header-burger-btn,
.header-menu { display: none; }

@media (max-width: 799px), (pointer: coarse) and (max-width: 1024px) {
  .header-inner { min-height: calc(6vw + 53px); padding: 3vw 6vw; }
  .header-title img { width: 200px; }
  .header-nav,
  .header-actions { display: none; }

  /* Burger: two lines that cross into an X while the menu is open. */
  .header-burger-btn {
    display: block;
    position: relative;
    width: 35px;
    height: 35px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .header-burger-btn span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--chrome-navy);
    transition: transform 0.25s;
  }
  .header-burger-btn span:first-child { top: 12px; }
  .header-burger-btn span:last-child  { top: 22px; }
  .header-menu-open .header-burger-btn span:first-child { transform: translateY(5px) rotate(45deg) scaleX(0.8); }
  .header-menu-open .header-burger-btn span:last-child  { transform: translateY(-5px) rotate(-45deg) scaleX(0.8); }

  /* Full-screen menu, faded in under the header bar. */
  .header-menu {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 1;
    padding-top: var(--site-header-h, 76px);
    background: var(--chrome-bg);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }
  .header-menu-open .header-menu { opacity: 1; visibility: visible; }
  .header-menu-open .header { z-index: 9000; }   /* the open menu covers everything on the page */
  body.header-menu-open { overflow: hidden; }

  /* One list per level ("root" plus one per folder); only the active one shows. */
  .header-menu-list {
    display: none;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    padding: 40px 3vw 0;
  }
  .header-menu-list.is-active { display: flex; }

  .header-menu-list a,
  .header-menu-list button {
    display: block;
    width: fit-content;
    margin: 4.5vw 5vw;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: min(8.5vw, 48px);
    line-height: 1;
    text-align: left;
    cursor: pointer;
  }

  /* Chevrons: "Products >" opens a folder, "< Back" leaves it. */
  .header-menu-list button::after,
  .header-menu-list button.is-back::before {
    content: "";
    display: inline-block;
    width: 0.3em;
    height: 0.3em;
    border: solid currentColor;
    border-width: 1px 1px 0 0;
    opacity: 0.7;
    vertical-align: 0.2em;
  }
  .header-menu-list button::after { margin-left: 0.4em; transform: rotate(45deg); }
  .header-menu-list button.is-back { margin-left: calc(5vw + 0.6em); opacity: 0.5; }
  .header-menu-list button.is-back::before { margin-right: 0.5em; transform: rotate(-135deg); }
  .header-menu-list button.is-back::after { content: none; }

  .header-menu-actions {
    display: flex;
    align-items: center;
    min-height: 55px;
    margin: 0 20px 6vw;
    padding-left: 11px;
  }
}

/* ---------- 5. Footer ---------- */

.footer {
  padding: 34px var(--chrome-gutter) 200px;  /* Squarespace left ~200px empty at the bottom; kept for parity */
  background: var(--chrome-bg);
  font-size: var(--chrome-font-size);
  line-height: 1.59;
}
.footer > * { max-width: var(--chrome-max-width); margin-inline: auto; }

.footer h3 {
  margin: 0 0 15px;
  font-family: var(--chrome-heading-font);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.footer p { margin: 14px 0; }
.footer h3 + p { margin-top: 0; }
.footer a {
  color: inherit;
  display: inline-block;
  text-decoration: underline 1px var(--chrome-blue);
  text-underline-offset: 0.15em;
}
.footer .is-small { font-size: 13.3px; }
.footer .is-large { font-size: max(16.4px, calc(14px + 0.3vw)); }
.footer .is-spaced { margin-top: 22px; }       /* FAQs sits apart from the policy links */

/* Newsletter sign-up */
.footer-signup p { margin-bottom: 10px; }
.footer-signup form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.footer-signup input {
  width: 256px;
  padding: 19.6px 28px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font: inherit;
  line-height: 16.8px;
  color: #000;
}
.footer-signup button {
  padding: 19.6px 28px;
  border: 0;
  background: var(--chrome-blue);
  color: #fff;
  font: inherit;
  font-size: max(16.4px, calc(14px + 0.3vw));
  line-height: 16.8px;
  letter-spacing: 0.01em;
  cursor: pointer;
}
.footer-signup button:hover { opacity: 0.8; }
.footer-signup output { flex-basis: 100%; font-size: 13.3px; }
.footer-signup output:empty { display: none; }

.footer hr {
  height: 1px;
  margin-block: 31px 25px;
  border: 0;
  background: var(--chrome-navy);
}

/* Link columns. Desktop follows Squarespace's 24-column grid:
 * Support 4 | About products 8 | (gap 1) | Find projects 4 | Contact 4 | logo 3 */
.footer-columns {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  column-gap: 11px;
  align-items: start;
}
.footer-support  { grid-column: 1 / span 4; }
.footer-products { grid-column: 5 / span 8; }
.footer-find     { grid-column: 14 / span 4; }
.footer-contact  { grid-column: 18 / span 4; }
.footer-logo     { grid-column: 22 / span 3; width: 100%; }
.footer-about    { display: none; }   /* phone-only variant of "About products" */

.footer-disclaimer { margin-block: 25px 0; opacity: 0.65; }

/* Tablet: the 24-column grid gets too tight for the headings, so use three columns. */
@media (min-width: 768px) and (max-width: 1099px) {
  .footer h3 { font-size: 26px; }
  .footer-columns {
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-areas:
      "support products find"
      "support products contact"
      "support products logo";
    column-gap: 24px;
  }
  .footer-support  { grid-area: support; }
  .footer-products { grid-area: products; }
  .footer-find     { grid-area: find; }
  .footer-contact  { grid-area: contact; margin-top: 20px; }
  .footer-logo     { grid-area: logo; max-width: 160px; margin-top: 20px; }
}

/* Phone: two columns of links, then the About list and a full-width logo. */
@media (max-width: 767px) {
  .footer { --chrome-gutter: 6vw; padding-top: 48px; padding-bottom: 23px; }
  .footer-signup form { flex-direction: column; align-items: flex-start; gap: 28px; margin-top: 56px; }
  .footer-signup input { width: 250px; }
  .footer hr { margin-block: 45px 57px; }

  .footer-columns {
    grid-template-columns: 1fr 1.2fr;
    grid-template-areas:
      "support contact"
      "support find"
      "about   about"
      "logo    logo";
    grid-template-rows: auto 1fr;
  }
  .footer-support  { grid-area: support; }
  .footer-contact  { grid-area: contact; }
  .footer-find     { grid-area: find; margin-top: 16px; }
  .footer-products { display: none; }
  .footer-about    { display: block; grid-area: about; margin-top: 46px; }
  .footer-about a  { color: var(--chrome-blue); }
  .footer-logo     { grid-area: logo; margin-top: 53px; }
  .footer-disclaimer { margin-top: 43px; }
}

/* ---------- 6. Page typography ---------- */

/* Squarespace's theme set the text style of everything inside the page. Content built
 * to sit in that theme (the analytics dashboard) opts in with class="site-theme". */
.site-theme {
  font-family: var(--chrome-font);
  font-size: var(--chrome-font-size);
  line-height: 1.59em;               /* em, not unitless: children inherit the px value */
  -webkit-font-smoothing: antialiased;
}
/* :where() keeps these at element-selector strength, so a page's own styles win. */
:where(.site-theme) :is(h1, h2, h3, h4) {
  margin: 2rem 0;
  font-family: var(--chrome-heading-font);
  font-weight: 800;
  letter-spacing: -0.02em;
}
:where(.site-theme) h1 { font-size: calc(14px + 4.1 * var(--chrome-u)); line-height: 1.087; }
:where(.site-theme) h2 { line-height: 1.1em; }
:where(.site-theme) h4 { font-size: calc(14px + var(--chrome-u)); line-height: 1.248; }
:where(.site-theme) p { margin: 14px 0; line-height: 1.59em; }
:where(.site-theme) :is(h1, h2, h3, h4, p) { overflow-wrap: break-word; }
:where(.site-theme) :is(input, button, select, textarea) { font-family: inherit; }
:where(.site-theme) a { color: var(--chrome-blue); }
.site-theme a:not([class]) { color: var(--chrome-blue); text-decoration: none; }

/* ---------- 7. Page sections ---------- */

/* A page's content goes in one or more <section class="page-section">. The first one
 * clears the fixed header. --tall is Squarespace's "medium" section: at least two thirds
 * of the screen high, with generous padding and its one child centred vertically. */
.page-section { box-sizing: border-box; }
.page-section:first-child { padding-top: var(--site-header-h, 104px); }
.page-section--tall {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 66vh;
  padding-block: 6.6vmax;
}
.page-section--tall:first-child { padding-top: calc(var(--site-header-h, 104px) + 6.6vmax); }

@media print {
  .header { position: static; }
  .header-burger-btn, .header-actions, .footer { display: none !important; }
}
