/* LAYOUT: top bar, side menu and page column.
   The menu stays on screen while the page scrolls, so every section can be reached from anywhere. */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font: 400 1.15rem/1 var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: uppercase;
}
.brand-logo {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 22%;
  box-shadow: 0 0 0 1px var(--line); /* a thin ring, so the white photo doesn't melt into a light page */
}

/* Top bar (phones). It stays at the top of the screen while the page scrolls. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  animation: enterDown 1.1s var(--ease-out) 0.3s both;
}
.topbar .brand-logo { animation: enterPop 1s var(--ease-pop) 0.9s both; }
.menu-btn {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  font: 400 0.75rem var(--mono);
  transition: border-color 0.15s;
}
.menu-btn:hover { border-color: var(--faint); }

/* Side menu. Fixed to the screen: on phones it fills the whole screen under the top bar, on computers
   it runs down the left edge. */
.sidebar {
  position: fixed;
  inset: 3.5rem 0 auto;
  z-index: 20;
  display: none;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.sidebar.open { display: block; }
.sidebar > .brand { display: none; }
.status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font: 400 0.75rem var(--mono);
}
.status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #2fbf71;
  animation: statusPulse 2.2s ease-out infinite;
}
@keyframes statusPulse {
  from { box-shadow: 0 0 0 0 rgb(47 191 113 / 0.55); }
  to { box-shadow: 0 0 0 7px rgb(47 191 113 / 0); }
}
#nav { display: grid; gap: 0.15rem; }
#nav a {
  padding: 0.3rem 0;
  color: var(--muted);
  font: 400 0.8rem var(--mono);
  text-decoration: none;
  transition: color 0.15s;
}
#nav a:hover, #nav a.active { color: var(--ink); }
#nav a.active::before { content: "› "; color: var(--accent); }

/* Colour mode switch */
.theme-switch {
  display: flex;
  gap: 0.1rem;
  width: fit-content;
  margin-top: 1rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.theme-switch button {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 1.8rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--soft); color: var(--ink); }
.theme-switch .icon { width: 1.05rem; height: 1.05rem; }

/* The page is one long column of sections. The first screen is full width, and each section after it
   sits in its own centred column (see .block in css/sections.css). */
main { padding: 0; }

/* Phones: the open menu covers the page, so its links are big enough to tap, the colour switch sits at
   the bottom, and the page behind it doesn't scroll. */
@media (max-width: 1023px) {
  .sidebar { inset: 3.5rem 0 0; flex-direction: column; overflow-y: auto; padding: 1.5rem 1.25rem; border-bottom: 0; }
  .sidebar.open { display: flex; }
  .menu-open { overflow: hidden; }
  .menu-open .tour-pill { display: none; } /* it would cover the colour switch */
  .sidebar .status { margin-bottom: 1.25rem; }
  .sidebar #nav a { padding: 0.65rem 0; font-size: 1.15rem; }
  .sidebar .theme-switch { margin-top: auto; }
}

/* Computers: the side menu replaces the top bar */
@media (min-width: 1024px) {
  .topbar { display: none; }
  .sidebar {
    inset: 0 auto auto 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    padding: 2rem 1.5rem;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
  .sidebar { background: color-mix(in srgb, var(--paper) 72%, transparent); backdrop-filter: blur(8px); animation: enterSlide 1.2s var(--ease-out) 0.35s both; }
  .sidebar .brand-logo { animation: enterPop 1s var(--ease-pop) 0.9s both; }
  .sidebar > .brand { display: flex; margin-bottom: 0.9rem; }
  .status { margin-bottom: 1.5rem; }
  .theme-switch { margin-top: auto; }

  /* Each section is centred in the space to the right of the menu, so the menu never covers it.
     --col is the section's width, set in css/sections.css. */
  main > .block {
    max-width: min(var(--col), 100% - var(--sidebar));
    margin-left: calc(var(--sidebar) + max(0px, (100% - var(--sidebar) - var(--col)) / 2));
  }
}
