/* Site header & footer */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 0;
}

/* The tagline lives in the footer now; the header keeps the wordmark alone. */
.brand-text .subtitle {
  display: none;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
  max-width: var(--shell-max);
  min-height: 80px;
  margin-inline: auto;
  padding: 0 var(--gutter);
  position: relative;
}

.site-header__nav-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

/* Theme toggle */
.theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--rule-strong);
  color: var(--fg-0);
}

.theme-toggle__icon {
  display: none;
  width: 1.15rem;
  height: 1.15rem;
}

/* Show the icon for the action available: sun = switch to light (dark active),
   moon = switch to dark (light active). */
.theme-toggle__icon--sun { display: none; }
.theme-toggle__icon--moon { display: block; }

:root[data-theme="dark"] .theme-toggle__icon--sun { display: block; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: none; }

:root[data-theme="light"] .theme-toggle__icon--sun { display: none; }
:root[data-theme="light"] .theme-toggle__icon--moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle__icon--sun { display: block; }
  :root:not([data-theme]) .theme-toggle__icon--moon { display: none; }
}

.site-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
  color: var(--fg-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.site-nav-toggle:hover {
  border-color: var(--accent);
}

.site-nav-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-nav-toggle--open .site-nav-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-nav-toggle--open .site-nav-toggle__bar:nth-child(2) {
  opacity: 0;
}

.site-nav-toggle--open .site-nav-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.site-nav {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

/* On wide screens the theme toggle closes the row instead of opening it. */
@media (min-width: 768px) {
  .site-nav { order: -1; }
}

.site-nav a {
  color: var(--fg-4);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
  padding-block: var(--space-1);
}

.site-nav a:hover {
  color: var(--fg-0);
}

.site-nav a.is-active {
  color: var(--fg-0);
  border-bottom-color: var(--warm);
}

.site-nav a.site-nav__logout {
  color: var(--fg-5);
}

@media (max-width: 767px) {
  .site-header {
    align-items: center;
    min-height: 64px;
  }

  .site-header__nav-wrap { gap: var(--space-2); }

  .site-nav-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: min(16rem, calc(100vw - 2rem));
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-1) 0;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
  }

  .site-nav--open {
    display: flex;
  }

  .site-nav a {
    padding: var(--space-4) var(--space-5);
    font-size: 0.78rem;
    border-bottom: 1px solid var(--rule);
  }

  .site-nav a.is-active {
    border-bottom-color: var(--rule);
    box-shadow: inset 3px 0 0 var(--warm);
  }

  .site-nav a:last-child {
    border-bottom: none;
  }
}

body.site-nav-open {
  overflow: hidden;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  font-size: 0.82rem;
}

.lang-switch a {
  color: var(--fg-5);
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.lang-switch a.active {
  color: var(--fg-2);
  background: var(--bg-2);
  font-weight: 600;
}

.lang-switch__sep {
  color: var(--fg-5);
}

.login-header {
  text-align: center;
  padding: var(--space-7) var(--gutter) var(--space-6);
}

.login-header__brand {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}

.login-header__logo {
  display: block;
  margin: 0 auto 0.85rem;
  border-radius: 14px;
}

.login-header h1 {
  margin-bottom: 0.25rem;
}

.login-header__subtitle {
  margin-bottom: 0;
}

.site-footer {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding: var(--space-8) var(--gutter) var(--space-6);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
  gap: var(--space-7) var(--space-8);
  text-align: left;
}

.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 20rem;
}

.site-footer__wordmark {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--fg-0);
}

.site-footer__tagline {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--fg-4);
}

.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .site-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    padding-top: var(--space-7);
  }
}

.site-footer__login {
  font-size: 0.85rem;
  color: var(--fg-4);
  text-decoration: none;
  font-weight: 500;
}

.site-footer__login:hover {
  color: var(--fg-2);
}

.site-footer__links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3) var(--space-7);
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .site-footer__links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.site-footer__links a {
  font-size: 0.82rem;
  color: var(--fg-4);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--fg-2);
}

.site-footer__copyright {
  grid-column: 1 / -1;
  font-family: var(--sans);
  font-size: 0.69rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
}
