/* Site shell: the header and footer on every page. Style them here only.
   Markup for the main pages comes from src/shell/ (npm run shell); Resources and
   Pitch Decks keep their own .site-header markup but take their styling from here. */

:root {
  --shell-max: 1120px;
  /* full-bleed bars whose content lines up with the 1120px page column */
  --shell-gutter: max(24px, calc((100% - var(--shell-max)) / 2 + 24px));
}

body > header,
body > footer {
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

/* ---------- header ---------- */
/* site.js opens the menu and dropdown via [hidden]; class display rules must not beat it */
body > header [hidden] {
  display: none !important;
}

body > header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 16px var(--shell-gutter);
  background: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 28px;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

:root[data-theme="dark"] .brand img {
  filter: invert(1);
}

nav.primary,
.site-header nav {
  display: flex;
  align-items: center;
}

.site-header nav {
  gap: 26px;
}

.navlink,
.site-header nav > a {
  color: var(--ink);
  text-decoration: none;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0;
  cursor: pointer;
}

.navlink {
  margin-left: 26px;
}

.navlink:hover,
.navlink[aria-current="page"],
.site-header nav > a:hover,
.site-header nav > a[aria-current="page"] {
  border-bottom-color: var(--ink);
}

.navlink.demo {
  color: var(--muted);
}

.navlink.demo:hover {
  color: var(--ink);
}

.dropdown {
  position: relative;
  margin-left: 28px;
}

.dropdown .navlink {
  margin-left: 0;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  min-width: 250px;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 6px;
  display: grid;
}

.dropdown-panel a {
  display: block;
  padding: 11px 14px;
  text-decoration: none;
  color: var(--ink);
}

.dropdown-panel a:hover {
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
}

.dropdown-panel strong {
  display: block;
  font-size: 14px;
}

.dropdown-panel span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

#theme-toggle {
  margin-left: 28px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.site-header #theme-toggle {
  margin-left: 0;
}

/* the icon follows data-theme, which is set before first paint */
.theme-icon {
  width: 18px;
  height: 18px;
  background-color: var(--ink);
  -webkit-mask: url("theme-moon.png") center / contain no-repeat;
  mask: url("theme-moon.png") center / contain no-repeat;
  transition: transform 0.15s ease;
}

:root[data-theme="dark"] .theme-icon {
  -webkit-mask-image: url("theme-sun.png");
  mask-image: url("theme-sun.png");
}

#theme-toggle:hover .theme-icon {
  transform: scale(1.1);
}

.nav-toggle {
  display: none;
}

/* ---------- footer ---------- */
body > footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 26px var(--shell-gutter) 38px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

body > footer a {
  color: var(--muted);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    margin-right: 12px;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  nav.primary {
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    margin-top: 10px;
  }

  nav.primary .navlink {
    margin-left: 0;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  .dropdown {
    position: static;
    margin-left: 0;
  }

  .dropdown-panel {
    position: static;
    min-width: 0;
    border: 0;
    padding: 0 0 8px 16px;
  }

  nav.primary #theme-toggle {
    margin: 12px 0 0;
  }
}

@media (max-width: 680px) {
  .site-header {
    grid-template-columns: 1fr auto;
    row-gap: 10px;
  }

  /* the short Resources / Pitch Decks nav fits as its own row, so no menu toggle is needed */
  .site-header nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    gap: 6px 22px;
  }

  .site-header nav > a {
    padding: 6px 0;
  }

  body > footer {
    flex-direction: column;
    align-items: flex-start;
  }

  /* wrapped footer links stack closely on phones; give each a 24px target (WCAG 2.5.8) */
  body > footer a {
    display: inline-block;
    padding-block: 5px;
  }
}
