html {
  overscroll-behavior: none;
}

/* Sidebar column width default. --sidebar-width-user is set on :root by the
   sidebar_resize Stimulus controller (document.documentElement) to persist a
   dragged width; it is read here so the cascade resolves to the user's value
   when present, falling back to the 260px default. The width only applies on
   desktop under body.sidebar (mobile + non-sidebar pages stay collapsed). */
:root {
  --sidebar-width-default: 260px;
}

body {
  --footer-height: calc((var(--block-space)) + 3.6em + var(--block-space));
  --navbar-height: 4.125em;
  --sidebar-width: 0px;

  display: grid;
  grid-template-areas:
    "sidebar nav"
    "sidebar main";
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: min-content 1fr;
  max-block-size: 100dvh;

  &.sidebar {
    @media (min-width: 100ch) {
      --sidebar-width: var(--sidebar-width-user, var(--sidebar-width-default));
    }
  }
}

/* The once.com badge now lives behind the left sidebar column, so it stays hidden. */
#app-logo {
  display: none;
}

#nav {
  grid-area: nav;
}

#main-content {
  align-content: start;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  grid-area: main;
  overflow: auto;
  position: relative;

  .sidebar & {
    justify-content: end;

    @media (min-width: 100ch) {
      border-inline-start: 1px solid var(--color-border-darker);
      margin-inline: 0;
    }
  }
}

#sidebar {
  grid-area: sidebar;
  position: relative;
  transition: transform 300ms ease;

  .sidebar & {
    background-color: var(--color-sidebar-bg);
    block-size: 100dvh;
    max-block-size: 100dvh;
    z-index: 3;

    @media (min-width: 100ch) {
      border-inline-end: 1px solid var(--color-border-dark);
    }

    @media (max-width: 100ch) {
      inset: 0 auto 0 0;
      inline-size: min(82vw, 320px);
      position: fixed;
      border-inline-end: 1px solid var(--color-border-dark);
      transform: translate(-100%);
    }
  }

  &.open {
    @media (max-width: 100ch) {
      transform: translate(0);
    }
  }
}

#footer {
  grid-area: footer;
}
