:root {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Noto Serif", Georgia, "Times New Roman", Times, "Liberation Serif", serif;
  --text-2: var(--text-secondary);
  --text-3: var(--text-tertiary);
  --shadow-btn: 0 6px 16px -8px rgba(0, 0, 0, .55);
}

[data-theme="light"] {
  --shadow-btn: 0 6px 16px -8px rgba(15, 23, 42, .14);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* The bar spans the window; content below stays at 1120px. */
.topbar-inner.container { max-width: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.mark {
  width: 28px;
  height: 28px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--accent-text);
}

.mark svg { width: 16px; height: 16px; display: block; }

/* The wordmark shortens on narrow phones, where the menu button and theme toggle leave no room for it. */
@media (max-width: 519px) {
  .brand-rest { display: none; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Menu button: opens the Projects drawer (js/nav.js), or follows its link to /projects/ without JS. */
.menu-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
}

/* Extends the hit area to 44px without changing the 40px look. */
.menu-btn::before {
  content: "";
  position: absolute;
  inset: -2px;
}

.menu-btn:hover { background: var(--surface); }

.menu-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

@media (max-width: 519px) {
  .menu-btn {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  /* Visually hidden, still the accessible name. */
  .menu-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.theme-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  cursor: pointer;
}

/* Extends the hit area to 44px without changing the 40px look. */
.theme-toggle::before {
  content: "";
  position: absolute;
  inset: -2px;
}

.theme-toggle:hover { background: var(--surface); }

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Projects drawer: built by js/nav.js. */
html.drawer-open body { overflow: hidden; }

dialog.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(360px, calc(100vw - 48px));
  height: 100%;
  max-height: none;
  max-width: none;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--hairline-strong);
  background: var(--bg);
  color: var(--text);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(.16, 1, .3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog.drawer[open] {
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: none; }

.drawer::backdrop {
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  transition: opacity 280ms;
}

.drawer.open::backdrop { opacity: 1; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}

.drawer-head h2 { font-size: 1.5rem; }

.drawer-close {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  cursor: pointer;
}

.drawer-close::before {
  content: "";
  position: absolute;
  inset: -2px;
}

.drawer-close:hover { background: var(--surface); }

.drawer-close svg {
  width: 20px;
  height: 20px;
}

/* Category / Platform switch: the thumb slides with data-view, no JS needed for the motion. */
.view-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 16px 20px 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--r-pill);
}

.view-switch::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: var(--card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  transition: transform 250ms cubic-bezier(.16, 1, .3, 1);
}

.view-switch[data-view="platform"]::before { transform: translateX(100%); }

.view-switch button {
  position: relative;
  z-index: 1;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: 600 .9rem var(--sans);
  border-radius: var(--r-pill);
  cursor: pointer;
}

.view-switch button[aria-pressed="true"] { color: var(--text); }

.drawer-groups {
  flex: 1;
  padding: 0 12px 16px;
}

/* layout.css pads every <section> by --section-y; the drawer's groups are sections. */
.drawer-group { padding-block: 0; }

.drawer-group h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px -12px 0;
  padding: 8px 20px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  font: 700 .8rem/1.4 var(--sans);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-text);
}

.drawer-group h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline-strong);
}

.drawer-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drawer-link {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
}

.drawer-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  line-height: 1.3;
}

.drawer-name svg {
  width: 12px;
  height: 12px;
  flex: none;
}

.drawer-meta {
  grid-column: 1;
  font: .8rem var(--sans);
  color: var(--text-3);
}

.drawer-link .src-badge {
  grid-column: 2;
  grid-row: 1 / span 2;
}

a.drawer-link:hover { background: var(--surface); }

.drawer-link[aria-current="page"] { background: var(--accent-muted); }

.drawer-link.is-soon { color: var(--text-2); }

.src-badge {
  font: 600 .72rem/1.5 var(--sans);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.src-open {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.src-closed {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--hairline-strong);
}

.drawer-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--hairline);
}

.drawer-foot .drawer-all {
  display: flex;
  width: 100%;
  font-family: var(--sans);
}

/* Footer */
.footer {
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
  padding-block: 20px;
}

.footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-2);
}

.footer a:hover { color: var(--text); }

/* OffBridge overrides for shared chrome */
.topbar { z-index: var(--z-nav); }

.brand {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0;
  gap: 12px;
}

.brand:hover { color: var(--text); }

.menu-btn:hover,
a.drawer-link:hover,
.brand:hover {
  text-decoration: none;
}

@media (max-width: 599px) {
  .brand-rest { display: none; }
}

@media (max-width: 359px) {
  .topbar-inner,
  .topbar-actions { gap: 6px; }
}

.topbar .osswitch { margin-left: 0; }
.topbar .osswitch button { height: 32px; }

.theme-toggle { color: var(--text); }
.theme-toggle:hover { border-color: var(--hairline-strong); }

.footer {
  background: var(--bg);
  padding: 0;
  font-family: var(--serif);
}
.footer-inner.container { max-width: 1120px; }
.footer-inner p { margin: 0; }
.footer a { text-decoration: underline; }

dialog.drawer { font-family: var(--serif); }

dialog.drawer .drawer-head h2 {
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

dialog.drawer .btn {
  min-height: 48px;
  font-weight: 700;
  letter-spacing: 0;
}

dialog.drawer .btn-primary {
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-btn);
}

dialog.drawer .btn-primary:hover { filter: brightness(1.06); }
dialog.drawer .btn-primary:active { transform: scale(.97); }
