/*
 * Schild — wspólna powłoka („jedna skóra”, 2026-11-17).
 * Te same reguły nawigacji dla konsoli (templates/fragments/shell.html) i aplikacji
 * (web/src/components/AppShell.tsx — plik trafia do bundla przez web/src/styles/app.css).
 * Telefon: dolny pasek Dziś · Zadania · [+] · Cele · Życie. Komputer (≥ 900 px): boczny panel.
 * Wymaga tokens.css. Zero stylów inline (CSP konsoli: style-src 'self').
 *
 * Kontrakt znaczników:
 *   <nav class="shell-nav" aria-label="…">          aplikacja: jedyny element nawigacji
 *     <div class="shell-nav__head">                   tylko panel boczny
 *       <span class="shell-nav__account"><span class="avatar">J</span>
 *       <span class="account__name">Imię</span></span>
 *     </div>
 *     <div class="shell-nav__tabs">                   5 pozycji w tej kolejności:
 *       <a class="nav__link">ikona <span>Dziś</span></a>, Zadania,
 *       <button|a class="nav__link nav__link--add"><span class="nav__add-icon">ikona plus</span>
 *         <span class="shell-nav__add-text">Dodaj zadanie</span></button|a>, Cele, Życie
 *     </div>
 *     <div class="shell-nav__more">                   tylko panel boczny
 *       <p class="shell-nav__heading">Więcej</p> + zwykłe <a class="nav__link nav__link--item
 *       nav__link--quiet"> (pełne przeładowanie strony)
 *     </div>
 *   </nav>
 *   Konsola: w <aside class="sidebar"> zakładki mają klasę shell-nav__tabs shell-nav__tabs--side
 *   (widoczne od 900 px), a dolny pasek to osobne <nav class="shell-nav shell-nav--bar">.
 *   Ikona to <svg class="icon">; aktywna pozycja ma aria-current="page".
 */

/* ==========================================================================
   Konto i marka
   ========================================================================== */

.account__trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.account__trigger:hover,
.account[open] > .account__trigger {
  background: var(--surface-3);
}

.account__trigger .icon {
  width: 14px;
  height: 14px;
  color: var(--fg-muted);
}

.account__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--fg);
}

.brand:hover {
  text-decoration: none;
}

/* Tarcza Schild narysowana w CSS (bez obrazka): czerwony kwadrat z zaokrąglonym dołem. */
.brand__mark {
  width: 20px;
  height: 22px;
  background: var(--accent);
  border-radius: 4px 4px 10px 10px;
}

.brand__cursor {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-weight: 400;
  text-align: left;
}

.nav__link:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.nav__link .icon {
  width: 20px;
  height: 20px;
  color: var(--fg-muted);
  stroke-width: 1.6;
}

.nav__link[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--nav-active-fg);
  font-weight: 500;
}

.nav__link[aria-current="page"] .icon {
  color: var(--nav-active-fg);
}

.nav__link--add {
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 2px;
}

.nav__add-icon {
  width: 22px;
  height: 22px;
  margin-left: -1px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav__add-icon .icon,
.nav__link--add .nav__add-icon .icon {
  width: 16px;
  height: 16px;
  color: var(--on-accent);
  stroke-width: 2.4;
}

.nav__search[hidden] {
  display: none;
}

.nav__kbd {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.nav__group {
  margin-top: var(--space-4);
}

.nav__label {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
}

.nav__label:hover {
  background: var(--surface-3);
}

.nav__label-link {
  color: inherit;
}

.nav__label-link[aria-current="page"] {
  color: var(--nav-active-fg);
}

.nav__chevron {
  opacity: 0;
  color: var(--fg-subtle);
  transition: transform var(--duration-fast) var(--ease-out), opacity var(--duration-fast);
}

.nav__chevron .icon {
  width: 16px;
  height: 16px;
}

.nav__label:hover .nav__chevron,
.nav__label:focus-visible .nav__chevron {
  opacity: 1;
}

.nav__group:not([open]) .nav__chevron {
  transform: rotate(-90deg);
  opacity: 1;
}

.nav__link--item {
  min-height: 32px;
}

.nav__link--quiet {
  color: var(--fg-muted);
}

.nav__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.nav__dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin: 0 5px;
  border-radius: 50%;
  background: var(--control);
}


.nav__link .icon,
.account__trigger .icon {
  flex-shrink: 0;
}

/* ==========================================================================
   Nawigacja aplikacji: dolny pasek (telefon) i boczny panel (komputer)
   ========================================================================== */

.shell-nav__tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.shell-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) 0 var(--space-2);
}

.shell-nav__account {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 4px 8px;
  font-weight: 600;
}

.shell-nav__more {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: var(--space-4);
}

.shell-nav__heading {
  margin: 0;
  padding: 4px 8px;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* Dotyk: każda pozycja nawigacji ma co najmniej 44 px. */
@media (pointer: coarse) {
  .nav__link,
  .nav__link--item,
  .nav__label {
    min-height: var(--touch);
  }
}

@media (min-width: 900px) {
  .shell-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: var(--space-2) var(--space-3) var(--space-5);
    background: var(--surface-1);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Konsola ma własny panel boczny; jej dolny pasek istnieje tylko na telefonie. */
  .shell-nav--bar {
    display: none;
  }

  /* „Dodaj zadanie” stoi w panelu na górze, choć w kodzie jest trzecie (środek paska). */
  .shell-nav__tabs .nav__link--add {
    order: -1;
  }

  /* Treść obok panelu; pasek dolny nie istnieje, więc tylko zwykły odstęp na dole. */
  .shell-main {
    margin-left: var(--sidebar-w);
    padding-bottom: var(--space-6);
  }
}

@media (max-width: 899px) {
  .shell-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg);
    border-top: 1px solid var(--border);
  }

  .shell-nav__head,
  .shell-nav__more,
  .shell-nav__tabs--side {
    display: none;
  }

  .shell-nav .shell-nav__tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    gap: 0;
    max-width: 640px;
    height: var(--nav-h);
    margin: 0 auto;
    padding: 6px 6px 0;
  }

  .shell-nav .nav__link {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 0;
    border-radius: var(--radius-lg);
    background: none;
    color: var(--fg-subtle);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-align: center;
  }

  .shell-nav .nav__link .icon {
    width: 24px;
    height: 24px;
    color: currentColor;
  }

  .shell-nav .nav__link[aria-current="page"] {
    background: none;
    color: var(--nav-active-fg);
  }

  .shell-nav .nav__link--add {
    justify-self: center;
    width: 56px;
    height: 56px;
    min-height: 56px;
    margin: -20px 0 0;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow-fab);
  }

  .shell-nav .nav__link--add .nav__add-icon {
    width: auto;
    height: auto;
    margin: 0;
    background: none;
  }

  .shell-nav .nav__link--add .nav__add-icon .icon {
    width: 26px;
    height: 26px;
  }

  /* Tekst przycisku [+] zostaje dla czytników ekranu, znika z ekranu. */
  .shell-nav .shell-nav__add-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .shell-main {
    padding-bottom: calc(var(--nav-h) + 36px + env(safe-area-inset-bottom, 0px));
  }
}
