/* Page shell, header, and footer. */

body {
  display: flex;
  flex-direction: column;
  width: min(100% - 2.5rem, 960px);
  min-height: 100vh;
  margin-inline: auto;
  padding-top: 1.5rem;
}

body > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

body > header > .left {
  display: flex;
  align-items: center;
  min-width: 0;
}

body > header > .right {
  display: flex;
  align-items: center;
  margin-left: auto;
  min-width: 0;
}

body > header > .nav-menu > .nav-menu-label {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
}

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

.brand-mark {
  width: 1.6rem;
  height: 1.6rem;
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* the leading "O" carries the brand color */
.brand-name::first-letter {
  color: var(--brand-accent);
}

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
}

.links a,
.links .nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease;
}

.links a:hover,
.links .nav-button:hover {
  color: var(--text);
  background: var(--surface-raised);
  text-decoration: none;
}

.session {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.session .logout {
  margin: 0;
}

.session .nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  color: var(--primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}

.session .nav-button:hover {
  color: var(--primary-hover);
  background: var(--surface-raised);
  border-color: transparent;
}

/* the log-in call to action carries the accent color */
.session .login-link {
  color: var(--primary);
  font-weight: 600;
}

.session .login-link:hover {
  color: var(--primary-hover);
}

.session .username {
  display: inline-block;
  max-width: 18rem;
  padding: 0.25rem 0.6rem;
  overflow-wrap: anywhere;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.session .username:hover {
  color: var(--primary);
  border-color: var(--border-strong);
  text-decoration: none;
}

body > main {
  flex: 1;
  padding: 1.75rem 0 2.5rem;
}

body > footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding: 1.25rem 0 1.75rem;
  border-top: 1px solid var(--border);
}

body > footer .links {
  gap: 0.15rem;
}

body > footer .link {
  padding: 0.3rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

body > footer .link:hover {
  color: var(--text);
  background: var(--surface-raised);
  text-decoration: none;
}

body > footer .copyright {
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  body {
    width: 100%;
    padding: 1rem 1.25rem 0;
  }

  body > header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
  }

  /* top row: brand left, menu + account grouped right */
  body > header > .left {
    margin-right: auto;
  }

  body > header > .right {
    margin-left: 0;
  }

  /* "Menu" toggle (label acts on a hidden checkbox) */
  body > header > .nav-menu {
    position: relative;
  }

  body > header > .nav-menu > .nav-menu-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2rem;
    padding: 0.3rem 0.75rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
  }

  body > header > .nav-menu > .nav-menu-label::after {
    content: "\25BE";
    font-size: 0.8em;
    transition: transform 140ms ease;
  }

  body > header > .nav-menu > .nav-menu-toggle:checked ~ .nav-menu-label::after {
    transform: rotate(180deg);
  }

  /* dropdown panel */
  body > header > .nav-menu > .links {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    flex-direction: column;
    min-width: 12rem;
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    z-index: 30;
  }

  body > header > .nav-menu > .nav-menu-toggle:not(:checked) ~ .links {
    display: none;
  }

  body > header > .nav-menu > .links a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.25rem;
    padding: 0.45rem 0.75rem;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-align: left;
  }

  body > header > .nav-menu > .links a:hover {
    color: var(--text);
    background: var(--surface-raised);
  }

  .session .username {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .profile {
    flex-wrap: wrap;
    max-width: 100%;
  }

  .profile .username {
    max-width: 100%;
  }

  body > footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
