/* ============================================================
   THE SITE BAR - self-contained, so any page can load it without
   pulling in the whole stylesheet and colliding with its own layout
   ============================================================ */

.topbar {
  --nav-bg:    #ffffff;
  --nav-text:  #2e3138;
  --nav-muted: #70767f;
  --nav-rule:  #dde5ee;
  --nav-accent:#2f5478;
  --nav-shell: 82.5rem;

  position: sticky; top: 0; z-index: 200;
  background: color-mix(in srgb, var(--nav-bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .35s ease;
  color: var(--nav-text);
  font-family: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.topbar.stuck { border-bottom-color: var(--nav-rule); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar {
    --nav-bg: #20232a; --nav-text: #e7eaef; --nav-muted: #9aa2ad;
    --nav-rule: #333d4a; --nav-accent: #8fb0cd;
  }
}
:root[data-theme="dark"] .topbar {
  --nav-bg: #20232a; --nav-text: #e7eaef; --nav-muted: #9aa2ad;
  --nav-rule: #333d4a; --nav-accent: #8fb0cd;
}

.topbar .wrap {
  position: relative;
  max-width: var(--nav-shell); margin: 0 auto; padding: 0 2.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; height: 4.5rem;
}
.topbar .mark {
  font-size: 1.04rem; font-weight: 600; letter-spacing: -.026em;
  color: inherit; text-decoration: none; white-space: nowrap;
  transition: opacity .18s ease;
}
.topbar .mark:hover { opacity: .6; text-decoration: none; }

.topbar .navlinks {
  display: flex; align-items: center; gap: 1.75rem;
  font-size: .88rem; color: var(--nav-muted);
}
.topbar .navlinks a {
  position: relative; padding: .2rem 0;
  color: inherit; text-decoration: none;
  transition: color .18s ease;
}
.topbar .navlinks a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform .35s cubic-bezier(.4,.05,.2,1);
}
.topbar .navlinks a:hover { color: var(--nav-text); text-decoration: none; }
.topbar .navlinks a:hover::after { transform: scaleX(1); transform-origin: left; }
.topbar .navlinks a.active { color: var(--nav-text); }
.topbar .navlinks a.active::after { transform: scaleX(1); background: var(--nav-accent); }

.topbar .themetoggle {
  width: 2.5rem; height: 2.5rem; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--nav-rule); border-radius: 999px;
  background: var(--nav-bg); color: var(--nav-text);
  cursor: pointer; padding: 0;
  transition: transform .35s cubic-bezier(.4,.05,.2,1), border-color .18s ease;
}
.topbar .themetoggle:hover { transform: translateY(-1px); border-color: var(--nav-accent); }
.topbar .themetoggle:active { transform: translateY(0) scale(.94); }
.topbar .themetoggle svg { display: block; overflow: visible; }
.topbar .themetoggle .sun  { transition: r .4s cubic-bezier(.4,.05,.2,1); }
.topbar .themetoggle .moon { transition: cx .4s cubic-bezier(.4,.05,.2,1); }
.topbar .themetoggle .rays { transition: opacity .3s ease, transform .4s cubic-bezier(.4,.05,.2,1); transform-origin: center; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar .themetoggle .sun  { r: 8px; }
  :root:not([data-theme="light"]) .topbar .themetoggle .moon { cx: 16px; }
  :root:not([data-theme="light"]) .topbar .themetoggle .rays { opacity: 0; transform: rotate(-45deg) scale(.4); }
}
:root[data-theme="dark"] .topbar .themetoggle .sun  { r: 8px; }
:root[data-theme="dark"] .topbar .themetoggle .moon { cx: 16px; }
:root[data-theme="dark"] .topbar .themetoggle .rays { opacity: 0; transform: rotate(-45deg) scale(.4); }

@media (max-width: 52rem) {
  .topbar .wrap {
    display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
    row-gap: .35rem; height: auto; padding-top: .7rem; padding-bottom: .7rem;
    padding-left: 1.35rem; padding-right: 1.35rem;
  }
  .topbar .mark { grid-column: 1; grid-row: 1; }
  /* the toggle is a child of .navlinks, so grid placement never reached it and
     it sat at the end of the links row; pin it to the right edge instead */
  .topbar .themetoggle { position: absolute; right: 1.35rem; top: 50%; transform: translateY(-50%); }
  .topbar .navlinks { grid-column: 1; grid-row: 2; gap: 1.1rem; font-size: .8rem; }
  .topbar .navlinks .hide-sm { display: inline; }
}
