/* The application shell: header, navigation, main, footer. */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- boot ---------- */

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 60vh;
  color: var(--text-muted);
}

.boot__spinner,
.state__spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.boot__text { margin: 0; }

/* ---------- header ---------- */

.app__header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-height: var(--header-height);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.brand__mark {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
}

.header__spacer { flex: 1 1 auto; }

.picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.picker__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  white-space: nowrap;
}

.theme-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.user__name {
  font-size: var(--text-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

/* ---------- navigation ---------- */

.app__nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-4);
  position: sticky;
  top: var(--header-height);
  z-index: 15;
  /* A row, so the view links and the global New task action share it and the action can be
     pushed to the end. */
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app__nav[hidden] { display: none; }

.nav__list {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  /* The links scroll if they must; the New task action never does, so it stays put. */
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav__link {
  display: inline-block;
  padding: var(--space-3) var(--space-4);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.nav__link:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.nav__link--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--weight-medium);
}

/* ---------- main ---------- */

.app__main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

.view__header { margin-bottom: var(--space-5); }
.view__title { margin-bottom: var(--space-1); }

.view__subtitle {
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0;
}

/* ---------- footer ---------- */

.app__footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer__text {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

@media (max-width: 40rem) {
  .app__header { gap: var(--space-2); }
  .picker__label { display: none; }
  .user__name { display: none; }
  .app__nav { top: auto; position: static; }
}

/* The global New task action. Pushed to the end of the navigation row so its position is
   the same on every view — that consistency is the whole point of making it global. */
.nav__actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }
.nav__new-task { white-space: nowrap; }
