/* Layout shell: wrap, header, footer, bottom nav */

.wrap {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main {
  flex: 1 0 auto;
  position: relative;
  z-index: 20;
  width: 100%;
}

/* Pages with bottom nav need clearance on mobile */
body.has-bottom-nav main {
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 64px);
}

@media (min-width: 768px) {
  body.has-bottom-nav main {
    padding-bottom: 0;
  }
}

/* Header: full bar at rest, Dynamic Island only when scrolled */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  display: flex;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  background: var(--background);
  border-bottom: 1px solid var(--surface-variant);
  transition: background 0.3s ease, border-color 0.3s ease, padding 0.3s ease;
}

.site-header.is-scrolled {
  background: transparent;
  border-bottom-color: transparent;
  padding: 12px 16px 0;
}

.island {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding: 0.7rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  min-width: 0;
  transition:
    max-width 0.35s ease,
    padding 0.35s ease,
    border-radius 0.35s ease,
    background 0.35s ease,
    box-shadow 0.35s ease,
    border-color 0.35s ease;
}

@media (min-width: 768px) {
  .island {
    gap: 1rem;
    padding: 1rem var(--gutter);
  }
}

/* Island mode (after scroll) */
.site-header.is-scrolled .island,
.island.is-scrolled {
  max-width: min(920px, calc(100vw - 16px));
  padding: 0.45rem 0.55rem 0.45rem 0.85rem;
  background: color-mix(in srgb, var(--surface-container-lowest) 82%, transparent);
  border-color: color-mix(in srgb, var(--outline-variant) 70%, transparent);
  border-radius: var(--radius-pill);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 12px 32px rgba(28, 27, 27, 0.1),
    0 2px 8px rgba(28, 27, 27, 0.04);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

@media (min-width: 768px) {
  .site-header.is-scrolled .island,
  .island.is-scrolled {
    max-width: min(920px, calc(100vw - 32px));
    padding: 0.55rem 0.7rem 0.55rem 1.15rem;
  }
}

body {
  padding-top: 68px;
}

@media (min-width: 768px) {
  body {
    padding-top: 72px;
  }
}

.brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--on-surface);
  letter-spacing: -0.01em;
  flex-shrink: 1;
  min-width: 0;
  padding: 0.25rem 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .brand {
    font-size: 1.35rem;
    flex-shrink: 0;
  }
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.nav-desktop a {
  font-size: 0.9375rem;
  color: var(--on-surface-variant);
  transition: color 0.2s ease, background 0.2s ease;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.nav-desktop a:hover {
  color: var(--on-surface);
  background: color-mix(in srgb, var(--surface-container) 80%, transparent);
}

.nav-desktop a[aria-current="page"] {
  color: var(--on-surface);
  font-weight: 600;
  background: var(--surface-container);
}

/* Always visible: Open Source + Download Free — matched size */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-left: auto;
}

/* Shared control size (both buttons identical geometry) */
.header-actions .link-quiet,
.header-actions .btn,
.header-actions .btn.btn--caps,
.header-actions a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  text-decoration: none;
  flex: 0 0 auto;
  gap: 0;
}

.header-actions .link-quiet {
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-lowest);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.header-actions .link-quiet:hover {
  color: var(--on-surface);
  background: var(--surface-container);
  border-color: var(--on-surface);
}

.header-actions .btn,
.header-actions .btn.btn--caps,
.header-actions a.btn {
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--on-primary);
}

.header-actions .btn:hover,
.header-actions .btn.btn--caps:hover,
.header-actions a.btn:hover {
  background: var(--surface-tint);
  color: var(--on-primary);
}

@media (min-width: 900px) {
  .header-actions {
    gap: 0.5rem;
    margin-left: 0;
  }

  .header-actions .link-quiet,
  .header-actions .btn,
  .header-actions .btn.btn--caps,
  .header-actions a.btn {
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0 1rem;
    font-size: 0.8125rem;
  }
}

@media (min-width: 900px) {
  .nav-desktop {
    display: flex;
  }
}

/* ——— Bottom nav (mobile) ——— */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  background: var(--surface-container-low);
  border-top: 1px solid color-mix(in srgb, var(--outline-variant) 60%, transparent);
  justify-content: space-around;
  align-items: center;
  padding: 0.75rem 0.5rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--on-surface-variant);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-width: 72px;
  padding: 0.25rem;
}

.bottom-nav a .material-symbols-outlined {
  font-size: 22px;
}

.bottom-nav a[aria-current="page"] {
  color: var(--on-surface);
}

.bottom-nav a[aria-current="page"] .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

body.no-bottom-nav .bottom-nav {
  display: none;
}

/* ——— Footer ——— */
.site-footer {
  background: var(--surface-container-low);
  margin-top: auto;
  padding-block: 3rem;
  border-top: 1px solid transparent;
  position: relative;
  z-index: 20;
}

.site-footer--bordered {
  border-top-color: var(--outline-variant);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  text-align: center;
}

@media (min-width: 768px) {
  .site-footer__inner {
    flex-direction: row;
    text-align: left;
  }
}

.site-footer__brand {
  font-family: var(--font-display);
  font-size: var(--fs-headline-sm);
  font-weight: 500;
  color: var(--on-surface);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
}

.site-footer__links a {
  color: var(--on-surface-variant);
  font-size: var(--fs-body-md);
  transition: color 0.2s ease;
}

.site-footer__links a:hover {
  color: var(--on-surface);
}

.site-footer__copy {
  color: var(--on-surface-variant);
  font-size: var(--fs-body-md);
}

/* Stack / section helpers */
.section {
  padding-block: var(--stack-lg);
}

.section--tight {
  padding-block: var(--stack-md);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--stack-lg);
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: var(--stack-md);
}

.page-pad {
  padding-block: var(--stack-md);
}

@media (min-width: 768px) {
  .page-pad {
    padding-block: var(--stack-lg);
  }
}
