/* ==========================================================
   RESPONSIVE CSS – Mobile First Breakpoints
   xs  < 480px
   sm  >= 480px
   md  >= 768px
   lg  >= 1024px
   xl  >= 1440px
   2xl >= 1920px
========================================================== */

/* ============================
   XL (>= 1440px)
============================ */
@media (min-width: 1440px) {
  :root {
    --tile-h: 310px;
  }

  .gallery__item img {
    height: 340px;
  }

  #map {
    height: 560px;
  }

  .contact__inner {
    grid-template-columns: 1fr 400px;
  }
}

/* ============================
   2XL (>= 1920px)
============================ */
@media (min-width: 1920px) {
  :root {
    --tile-h: 380px;
  }

  .history,
  .ecology,
  .career,
  .gallery,
  .map-section,
  .contact,
  .contact-groups {
    padding-top: 7rem;
    padding-bottom: 7rem;
  }

  .history {
    padding-bottom: 0;
  }

  .categories {
    padding-top: 7rem;
  }

  .gallery__item img {
    height: 420px;
  }

  #map {
    height: 660px;
  }

  .history__svg {
    height: 680px;
  }

  .contact__inner {
    grid-template-columns: 1fr 480px;
  }
}

/* ============================
   LARGE (1024px – 1199px)
============================ */
@media (max-width: 1199px) {
  .categories__grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 200px);
  }

  .cat-tile--featured {
    grid-row: span 1;
    grid-column: span 1;
  }

  .cat-tile:hover .cat-tile__body {
    transform: translateY(calc(-1 * (200px - 3rem - 100%)));
  }

  .contact__inner {
    grid-template-columns: 1fr 280px;
  }
}

/* ============================
   MEDIUM (768px – 1023px)
============================ */
@media (max-width: 1023px) {

  /* Career */
  .career__accordion {
    grid-template-columns: 1fr;
  }

  /* Kontakt – 1-col accordion + center card */
  .kontakt__accordion {
    grid-template-columns: 1fr;
  }

  .csr-hero__photo--card {
    justify-content: center;
  }

  /* Header — RED on mobile */
  .header {
    background-color: #d2313a;
  }

  .header.scrolled {
    background-color: #d2313a;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  }

  .header__logo {
    width: auto;
    flex-shrink: 1;
  }

  .header__logo img {
    display: block;
    width: auto;
    height: auto;
    max-height: 26px;
    max-width: none;
  }

  .hamburger__line {
    background-color: var(--color-white);
  }

  /* Header nav panel */
  .header__nav {
    position: fixed;
    top: var(--header-height);
    right: -100%;
    width: min(340px, 85vw);
    height: calc(100vh - var(--header-height));
    background-color: #b12931;
    padding: 2rem 2rem 2.5rem;
    overflow-y: auto;
    transition: right var(--transition);
    z-index: 999;
  }

  .header__nav.open {
    right: 0;
  }

  .header__nav-list {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
  }

  .header__nav-list li {
    width: 100%;
    border-bottom: none;
    text-align: right;
  }

  .header__nav-link {
    display: block;
    padding: 0.75rem 0;
    font-size: 1.125rem;
    font-weight: var(--font-medium);
    color: var(--color-white);
    text-transform: none;
    letter-spacing: 0;
    text-align: right;
    width: 100%;
  }

  .header__nav-link:hover {
    color: rgba(255,255,255,0.7);
  }

  .header__nav-link::after {
    display: none;
  }

  /* Active nav link — white pill */
  .header__nav-link.active {
    display: inline-block;
    background-color: var(--color-white);
    color: var(--color-red);
    font-weight: var(--font-bold);
    border-radius: 8px;
    padding: 0.625rem 1.25rem;
    margin-bottom: 0.25rem;
    width: auto;
  }

  .header__nav-link.active:hover {
    color: var(--color-red-dark);
    background-color: var(--color-white);
  }

  /* CTA buttons inside mobile nav */
  .header__nav-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.3);
  }

  .header__nav-cta .btn {
    display: block;
    background-color: var(--color-white);
    color: var(--color-red);
    font-weight: var(--font-bold);
    font-size: 0.9375rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: none;
    border-radius: 8px;
    padding: 0.875rem 2rem;
    min-width: 200px;
    text-align: center;
  }

  .header__nav-cta .btn:hover {
    background-color: var(--color-bg-light);
    color: var(--color-red-dark);
  }

  .header__cta {
    display: none;
  }

  .header__hamburger {
    display: flex;
  }

  /* Hero */
  .hero {
    background: var(--color-white);
    min-height: auto;
  }

  /* CSR Hero — stack vertically on tablet */
  .csr-hero {
    background: var(--color-white);
    height: auto;
    padding-bottom: 0;
  }

  .csr-hero__content {
    max-width: 100%;
    height: auto;
    padding: calc(var(--header-height) + 2rem) 0 2.5rem;
  }

  .hero-ext-links {
    flex-wrap: wrap;
  }

  .csr-hero__photo {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    height: 280px;
    overflow: hidden;
  }

  /* Awards grid */
  .awards__grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* CSR Ecology */
  .csr-ecology__main {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero__collage {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    height: 320px;
    width: 100%;
    z-index: auto;
  }

  .hero__left {
    max-width: 100%;
    padding: 3rem 1.5rem 3rem 0;
  }

  .hero__cta-text {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }

  /* Category grid */
  .categories__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 220px);
  }

  .cat-tile:hover .cat-tile__body {
    transform: translateY(calc(-1 * (220px - 3rem - 100%)));
  }

  /* History */
  .history__cards {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .history__cards .history__card:last-child {
    grid-column: 1 / -1;
    max-width: 380px;
    margin: 0 auto;
  }

  /* Ecology */
  .ecology__inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 2rem;
  }

  .ecology__content {
    grid-column: auto;
    grid-row: auto;
    padding-bottom: 0;
  }

  .ecology__image {
    grid-column: auto;
    grid-row: auto;
    order: -1;
  }

  .ecology__cards {
    grid-column: auto;
    grid-row: auto;
    margin-top: 0;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .ecology__card {
    aspect-ratio: auto;
    min-height: 0;
  }

  .ecology__image img {
    height: 320px;
    width: 100%;
  }

  /* Gallery */
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Contact */
  .contact__inner {
    grid-template-columns: 1fr;
  }

  .contact__panel {
    min-height: auto;
  }

  /* Footer */
  .footer {
    justify-content: center;
    flex-wrap: wrap;
  }
  .footer__bottom {
    display: flex;
    width: 100%;
    align-items: stretch;
  }
  .footer__logo {
    position: static;
    transform: none;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    padding: 1rem 1.5rem;
    background-color: var(--color-white);
    order: -1;
  }
  .footer__main {
    width: auto;
    flex: 2;
    justify-content: center;
    text-align: center;
    padding: 1.25rem 1.5rem;
  }
  .footer__panel {
    min-width: unset;
    flex: 1;
    justify-content: center;
    padding: 1.25rem 1rem;
  }
}

/* ============================
   SMALL (480px – 767px)
============================ */
@media (max-width: 767px) {

  :root {
    --header-height: 68px;
  }

  /* Section spacing */
  .history,
  .ecology,
  .career,
  .gallery,
  .map-section,
  .contact {
    padding: 3.5rem 0;
  }

  /* Hero */
  .hero__title {
    font-size: 1.625rem;
  }

  /* Page hero */
  .page-hero {
    padding: calc(var(--header-height) + 2rem) 0 2rem;
  }

  .page-hero__title {
    font-size: 1.5rem;
  }

  .hero__left {
    padding: 2.5rem 1rem 2.5rem 0;
    gap: 1.25rem;
  }

  .hero__right {
    min-height: 320px;
  }

  /* Category grid */
  .categories__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 180px);
  }

  /* Keep content anchored at bottom — no slide-up on small tiles */
  .cat-tile:hover .cat-tile__body {
    transform: none;
  }

  .cat-tile:hover .cat-tile__desc {
    max-height: 7rem;
  }

  .cat-tile__title {
    font-size: 0.875rem;
    line-height: 1.2;
  }

  .cat-tile__body {
    bottom: 0.75rem;
    left: 0;
    right: 0;
    padding: 0.4rem 0.75rem 0;
  }

  .cat-tile__sublabel {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    white-space: normal;
    line-height: 1.2;
    margin-bottom: 0.2rem;
  }

  /* CSR Ecology gallery strip */
  .csr-ecology__gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .csr-ecology__gallery-item {
    height: 170px;
  }

  .csr-ecology__gallery-label {
    font-size: 1.25rem;
  }

  /* Awards */
  .awards__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* History */
  .history__cards {
    grid-template-columns: 1fr;
  }

  .history__cards .history__card:last-child {
    grid-column: auto;
    max-width: 100%;
    margin: 0;
  }

  /* Ecology cards */
  .ecology__cards {
    grid-template-columns: 1fr;
  }

  /* Gallery */
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gallery__item img {
    height: 180px;
  }

  /* Contact form columns */
  .contact__columns {
    grid-template-columns: 1fr;
  }

  .contact__form {
    padding: 1.5rem;
  }

  /* Map */
  #map {
    height: 360px;
  }

  /* Accordion */
  .accordion__header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .accordion__company {
    min-width: unset;
  }

  /* Footer — logo on top, then copyright (2/3) + icons (1/3) in one row */
  .footer {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .footer__logo {
    position: static;
    transform: none;
    width: 100%;
    flex: none;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    padding: 1rem 1.5rem;
    background-color: var(--color-white);
    order: -1;
  }
  .footer__bottom {
    display: flex;
    width: 100%;
    align-items: stretch;
  }
  .footer__main {
    flex: 2;
    width: auto;
    padding: 1rem 1.25rem;
    justify-content: flex-start;
    align-items: center;
    text-align: left;
  }
  .footer__panel {
    flex: 1;
    width: auto;
    justify-content: center;
    padding: 1rem 1.25rem;
  }

  /* Back to top */
  .back-to-top {
    display: none !important;
  }
}

/* ============================
   EXTRA SMALL (< 480px)
============================ */
@media (max-width: 479px) {

  :root {
    --header-height: 64px;
  }

  .container {
    padding: 0 1rem;
  }

  /* Category grid */
  .categories__grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, 200px);
  }

  .cat-tile__body {
    bottom: 0.75rem;
    left: 0;
    right: 0;
    padding: 0.4rem 0.75rem 0;
  }

  .cat-tile__sublabel {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    white-space: normal;
    line-height: 1.2;
    margin-bottom: 0.2rem;
  }

  /* Keep content anchored at bottom — no slide-up on extra small tiles */
  .cat-tile:hover .cat-tile__body {
    transform: none;
  }

  .cat-tile:hover .cat-tile__desc {
    max-height: 5rem;
    line-height: 1.3;
  }

  .cat-tile__title {
    font-size: 0.75rem;
    line-height: 1.2;
  }

  /* CSR Ecology carousel */
  .csr-ecology__carousel-img {
    height: 220px;
  }

  /* Awards */
  .awards__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 110px;
  }

  /* Section titles */
  .section-title {
    font-size: 1.5rem;
  }

  /* Page hero */
  .page-hero {
    padding: calc(var(--header-height) + 1.5rem) 0 1.5rem;
  }

  .page-hero__title {
    font-size: 1.25rem;
    padding-left: 0.75rem;
  }

  /* Hero */
  .hero__title {
    font-size: 1.375rem;
  }

  .hero__social {
    display: none;
  }

  .hero__left {
    padding: 2rem 0;
  }

  /* History cards 1-col */
  .history__cards {
    grid-template-columns: 1fr;
  }

  /* Gallery: 1 col */
  .gallery__grid {
    grid-template-columns: 1fr;
  }

  .gallery__item img {
    height: 220px;
  }

  /* Buttons full width on very small */
  .btn--lg {
    width: 100%;
    justify-content: center;
  }

  /* Contact panel */
  .contact__panel-inner {
    padding: 2rem 1.5rem;
  }
}

/* ============================
   O NAS – responsive
============================ */
@media (max-width: 767px) {
  .timeline {
    padding-top: 3rem;
  }
}

/* ============================
   HURT PALIW – responsive
============================ */
@media (max-width: 1023px) {
  .platnosci,
  .swimmer {
    grid-template-columns: 1fr;
  }

  .platnosci__img,
  .swimmer__img {
    height: 320px;
  }

  .platnosci__content,
  .swimmer__content {
    padding: 3rem 2rem;
  }

  .pracownicy {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .pracownicy__text {
    padding: 3rem 2rem;
  }

  .pracownicy__img {
    height: 320px;
  }

  .formularz__inner {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .formularz__meta {
    align-items: flex-start;
  }

  .formularz__title {
    text-align: left;
  }

  .formularz__divider,
  .referencje__divider,
  .tabor__divider {
    margin-left: 0;
  }
}

@media (max-width: 767px) {
  .hurt-gallery {
    grid-template-columns: 1fr;
  }

  .hurt-gallery__item {
    aspect-ratio: 16 / 9;
  }

  .tabor {
    padding: 3rem 0;
  }

  .tabor__title {
    text-align: left;
  }

  .referencje {
    padding: 3rem 0 2rem;
  }

  .referencje__title {
    text-align: left;
  }

  .formularz__row {
    grid-template-columns: 1fr;
  }

  .formularz {
    padding: 3rem 0 2rem;
  }
}

/* ============================
   PRINT
============================ */
@media print {
  .header,
  .header__hamburger,
  .back-to-top,
  .nav-overlay,
  #map {
    display: none !important;
  }

  body {
    padding-top: 0;
  }

  .hero {
    min-height: auto;
    padding-top: 2rem;
  }
}

/* ============================
   BUILDING CAROUSEL — mobile
============================ */
@media (max-width: 599px) {
  .building-carousel {
    margin: 0 -1rem;
    padding: 0 2.5rem;
  }

  .building-carousel__arrow {
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
  }

  .building-carousel__arrow--prev { left: 0.5rem; }
  .building-carousel__arrow--next { right: 0.5rem; }

  .building-lightbox__arrow {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .building-lightbox__arrow--prev { left: 0.5rem; }
  .building-lightbox__arrow--next { right: 0.5rem; }
}
