/* ==========================================================================
   HEADER + MENU GŁÓWNE
   Czysty CSS3, mobile-first. Plik jest niezależny od frameworka —
   można go przenieść do dowolnego projektu razem z header.js i markupem.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Zmienne
   -------------------------------------------------------------------------- */
:root {
  --c-yellow: #ffc400; /* akcent główny                        */
  --c-yellow-dark: #e0ac00; /* akcent w stanie :active / obrys      */
  --c-ink: #1a1a1a; /* tekst główny — kontrast 16:1 na bieli */
  --c-ink-soft: #4a4a4a; /* tekst drugorzędny — kontrast 8.5:1   */
  --c-white: #ffffff;
  --c-border: #ebebeb;

  /* Żółty nigdy nie służy jako kolor tekstu na bieli (kontrast ~1.7:1).
     Występuje wyłącznie jako tło, podkreślenie albo znacznik. */

  --header-h: 72px; /* telefony                             */
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-menu: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-drawer: -8px 0 32px rgba(0, 0, 0, 0.12);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.3s;
}

@media (min-width: 640px) {
  :root {
    --header-h: 80px; /* tablety i desktop */
  }
}

/* --------------------------------------------------------------------------
   2. Reset w zakresie potrzebnym dla headera
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* kotwice nie chowają się pod przyklejonym headerem */
  scroll-padding-top: var(--header-h);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--c-ink);
  background: var(--c-white);
}

/* blokada przewijania pod otwartą szufladą */
body.is-nav-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   3. Skip link — pierwszy element w tabulacji, widoczny dopiero przy fokusie
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 1000;
  padding: 12px 20px;
  background: var(--c-yellow);
  color: var(--c-ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: 4px;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 8px;
}

/* --------------------------------------------------------------------------
   4. Fokus klawiaturowy — własny, spójny w całym headerze
   -------------------------------------------------------------------------- */
.site-header :focus-visible {
  outline: 3px solid var(--c-yellow-dark);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   5. Belka headera
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  /* Musi być WYŻEJ niż .nav-overlay (105). Header tworzy własny kontekst
     nakładania, więc z-index szuflady w środku liczy się tylko względem
     rodzeństwa wewnątrz headera — nie względem overlaya na zewnątrz. */
  z-index: 120;
  background: var(--c-white);
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.25s var(--ease);
}

/* mocniejszy cień dopiero po odjechaniu od góry strony */
.site-header.is-scrolled {
  box-shadow: var(--shadow-menu);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 640px) {
  .header__inner {
    padding: 0 24px;
  }
}

@media (min-width: 1024px) {
  .header__inner {
    padding: 0 32px;
    gap: 40px;
  }
}

/* --------------------------------------------------------------------------
   6. Logo
   -------------------------------------------------------------------------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--c-ink);
}

.logo__mark {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.logo__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo__name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.logo__tagline {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-ink-soft);
}

/* na najmniejszych ekranach zostaje sam sygnet */
@media (max-width: 400px) {
  .logo__text {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   7. Nawigacja — MOBILE (szuflada wysuwana z prawej)
   -------------------------------------------------------------------------- */
.nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(86vw, 380px);
  z-index: 110;

  display: flex;
  flex-direction: column;
  padding: calc(var(--header-h) + 16px) 0 32px;
  overflow-y: auto;
  overscroll-behavior: contain;

  background: var(--c-white);
  box-shadow: var(--shadow-drawer);

  /* zamknięta: poza ekranem i poza kolejnością tabulacji */
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform var(--dur) var(--ease),
    visibility 0s linear var(--dur);
}

.nav.is-open {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform var(--dur) var(--ease),
    visibility 0s linear 0s;
}

.nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__item {
  border-bottom: 1px solid var(--c-border);
}

/* wspólny wygląd pozycji: link i przycisk dropdownu wyglądają identycznie */
.nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;

  padding: 18px 24px;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--c-ink);
  text-align: left;
  text-decoration: none;

  background: none;
  border: 0;
  cursor: pointer;

  transition:
    background-color 0.18s var(--ease),
    color 0.18s var(--ease);
}

.nav__link:hover {
  background-color: #fff8e0; /* rozbielony akcent — czytelny pod tekstem */
}

/* aktywna podstrona: żółty pasek przy krawędzi + pogrubienie */
.nav__link.is-active {
  font-weight: 800;
  box-shadow: inset 4px 0 0 var(--c-yellow);
  background-color: #fffbee;
}

/* strzałka dropdownu */
.nav__chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  transition: transform var(--dur) var(--ease);
}

.nav__item.is-open > .nav__link .nav__chevron {
  transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   8. Dropdown — MOBILE (akordeon)
   Animacja przez grid-template-rows 0fr → 1fr: płynna i bez zgadywania
   docelowej wysokości, w odróżnieniu od max-height z magiczną liczbą.
   -------------------------------------------------------------------------- */
.dropdown {
  display: grid;
  grid-template-rows: 0fr;
  background-color: #fafafa;
  transition: grid-template-rows var(--dur) var(--ease);
}

.nav__item.is-open > .dropdown {
  grid-template-rows: 1fr;
}

.dropdown__list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 0; /* warunek konieczny animacji 0fr → 1fr */
  overflow: hidden;
}

.dropdown__link {
  display: block;
  padding: 14px 24px 14px 40px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--c-ink-soft);
  text-decoration: none;
  transition:
    background-color 0.18s var(--ease),
    color 0.18s var(--ease);
}

.dropdown__link:hover {
  background-color: #fff8e0;
  color: var(--c-ink);
}

.dropdown__link.is-active {
  font-weight: 700;
  color: var(--c-ink);
  box-shadow: inset 4px 0 0 var(--c-yellow);
}

/* --------------------------------------------------------------------------
   9. Ikony społecznościowe
   -------------------------------------------------------------------------- */
.social {
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  margin: 24px 0 0;
  padding: 0 24px;
}

.social__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; /* minimalny cel dotykowy wg WCAG 2.5.5 */
  height: 44px;
  color: var(--c-ink);
  border: 1px solid var(--c-border);
  border-radius: 50%;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.social__link svg {
  width: 20px;
  height: 20px;
}

.social__link:hover {
  background-color: var(--c-yellow);
  border-color: var(--c-yellow);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   10. Hamburger — kreski przechodzą w X (transform, nie podmiana ikony)
   -------------------------------------------------------------------------- */
.burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -8px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  z-index: 120;
}

.burger__box {
  position: relative;
  display: block;
  width: 24px;
  height: 16px;
}

.burger__line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background-color: var(--c-ink);
  transition:
    transform var(--dur) var(--ease),
    opacity 0.15s var(--ease);
}

.burger__line:nth-child(1) {
  top: 0;
}
.burger__line:nth-child(2) {
  top: 7px;
}
.burger__line:nth-child(3) {
  top: 14px;
}

.burger[aria-expanded="true"] .burger__line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.burger[aria-expanded="true"] .burger__line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.burger[aria-expanded="true"] .burger__line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   11. Przyciemnienie tła pod szufladą
   -------------------------------------------------------------------------- */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 105;
  background-color: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--dur) var(--ease),
    visibility 0s linear var(--dur);
}

.nav-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--dur) var(--ease),
    visibility 0s linear 0s;
}

/* ==========================================================================
   12. DESKTOP — od 1024px menu wraca do belki
   ========================================================================== */
@media (min-width: 1024px) {
  .burger,
  .nav-overlay {
    display: none;
  }

  .nav {
    position: static;
    width: auto;
    padding: 0;
    overflow: visible;

    flex-direction: row;
    align-items: center;
    gap: 32px;

    background: none;
    box-shadow: none;

    /* stany szuflady nie obowiązują na desktopie */
    transform: none;
    visibility: visible;
    transition: none;
  }

  .nav__list {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .nav__item {
    position: relative; /* układ odniesienia dla dropdownu */
    border-bottom: 0;
  }

  .nav__link {
    position: relative;
    width: auto;
    padding: 10px 14px;
    font-size: 0.9375rem;
    border-radius: 6px;
  }

  /* podkreślenie wjeżdżające od środka */
  .nav__link::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 2px;
    height: 3px;
    border-radius: 2px;
    background-color: var(--c-yellow);
    transform: scaleX(0);
    transition: transform 0.22s var(--ease);
  }

  .nav__link:hover::after,
  .nav__item.is-open > .nav__link::after {
    transform: scaleX(1);
  }

  .nav__link.is-active {
    box-shadow: none;
    background-color: transparent;
  }

  .nav__link.is-active::after {
    transform: scaleX(1);
  }

  /* ---- dropdown jako panel nad treścią ---- */
  .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;

    display: block;
    min-width: 240px;
    padding: 8px;

    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: var(--shadow-menu);

    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition:
      opacity 0.22s var(--ease),
      transform 0.22s var(--ease),
      visibility 0s linear 0.22s;
  }

  /* otwarcie: najechaniem, fokusem klawiatury albo kliknięciem */
  .nav__item--dropdown:hover > .dropdown,
  .nav__item--dropdown:focus-within > .dropdown,
  .nav__item.is-open > .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition:
      opacity 0.22s var(--ease),
      transform 0.22s var(--ease),
      visibility 0s linear 0s;
  }

  .dropdown__list {
    overflow: visible;
  }

  .dropdown__link {
    padding: 11px 14px;
    border-radius: 6px;
    font-size: 0.9375rem;
  }

  .dropdown__link.is-active {
    box-shadow: none;
    background-color: #fff8e0;
  }

  .social {
    margin: 0;
    padding: 0;
    padding-left: 24px;
    border-left: 1px solid var(--c-border);
  }

  .social__link {
    width: 40px;
    height: 40px;
  }
}

/* ==========================================================================
   13. Redukcja ruchu — wszystko natychmiast
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
