/* =========================================================================
   RESPONSIVE NAVIGATION & TABLET SHELL (nav.css)
   KeepNclean by Akipa V2 — UI/UX Step 3 (1C)
   Standards: WCAG 2.1 AA & Apple Human Interface Guidelines (HIG)
   Breakpoints: 768px (iPad portrait) & 1024px (iPad landscape / Desktop)
   ========================================================================= */

/* Nav Root Container */
.responsive-nav,
.section-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  padding: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: relative;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Touch Target Standards (Apple HIG: min 44x44px, min 8px spacing) */
.nav-item,
.responsive-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 44px;
  min-width: 44px;
  padding: 0.65rem 1rem;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  /* Long compound word truncation rules (Zimmerverteilung, Abwesenheitsanträge) */
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast, 160ms ease-out),
              background var(--transition-fast, 160ms ease-out),
              box-shadow var(--transition-fast, 160ms ease-out);
}

.nav-item:hover,
.responsive-nav-item:hover {
  color: var(--color-brand);
  background: var(--color-brand-soft);
}

/* Active Nav State */
.nav-item.is-active,
.responsive-nav-item.is-active {
  color: var(--color-brand);
  background: var(--color-surface-subtle);
  font-weight: 800;
}

.nav-item.is-active::after,
.responsive-nav-item.is-active::after {
  content: '';
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0;
  height: 3px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--color-brand);
}

/* Keyboard Focus Ring */
.nav-item:focus-visible,
.responsive-nav-item:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
}

/* Mobile Hamburger Toggle Button (Hidden on tablet/desktop) */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
  transition: background var(--transition-fast, 160ms ease-out),
              border-color var(--transition-fast, 160ms ease-out);
}

.nav-toggle:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-brand);
}

/* Nav Menu List Container */
.nav-menu-list {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  min-width: 0;
}

/* =========================================================================
   BREAKPOINT 1: DESKTOP & LARGE TABLETS (>= 1024px)
   ========================================================================= */
@media (min-width: 1024px) {
  .nav-menu-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }
}

/* =========================================================================
   BREAKPOINT 2: TABLET PORTRAIT (< 1024px down to 768px)
   ========================================================================= */
@media (min-width: 768px) and (max-width: 1023px) {
  .responsive-nav,
  .section-nav {
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item,
  .responsive-nav-item {
    max-width: 180px;
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* =========================================================================
   BREAKPOINT 3: MOBILE & COMPACT VIEWPORTS (< 768px)
   Drawer / Accordion Menu with Zero-Overflow Ellipsis
   ========================================================================= */
@media (max-width: 767px) {
  .nav-toggle {
    display: inline-flex;
  }

  .responsive-nav,
  .section-nav {
    flex-direction: column;
    align-items: stretch;
    border-bottom: none;
  }

  .nav-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0;
  }

  .nav-menu-list {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px; /* Touch target separation */
    width: 100%;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
  }

  /* Drawer open state triggered by aria-expanded="true" or .is-open class */
  .nav-menu-list.is-open,
  .nav-toggle[aria-expanded="true"] ~ .nav-menu-list,
  .nav-header-mobile:has(.nav-toggle[aria-expanded="true"]) + .nav-menu-list {
    display: flex;
  }

  .nav-item,
  .responsive-nav-item {
    width: 100%;
    min-width: 44px;
    min-height: 44px;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    /* Long German word truncation: */
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-item.is-active,
  .responsive-nav-item.is-active {
    background: var(--color-brand-soft);
    border-color: var(--color-brand);
  }

  .nav-item.is-active::after,
  .responsive-nav-item.is-active::after {
    left: 0;
    top: 0;
    bottom: 0;
    right: auto;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
  }
}
