/* Dashboard klienta: kompaktowa identyfikacja konta i zawsze widoczna lista koszyka. */
.content > header {
  justify-content: flex-start;
  min-width: 0;
}

.client-summary {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 10px;
}

.client-summary #welcome,
.client-summary #meta {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-summary #welcome {
  color: #102035;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
}

.client-summary #meta {
  color: #6c7887;
  font-size: 11px;
  line-height: 1.3;
}

/*
 * The catalog shares the viewport with a fixed sidebar and cart. Viewport
 * breakpoints therefore do not describe the space that product cards really
 * have. Make categories and product rows respond to the catalog itself.
 */
@media (min-width: 761px) {
  .catalog {
    container-name: product-catalog;
    container-type: inline-size;
  }

  .catalog .category-tabs {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  }

  .catalog .category-tabs button {
    min-width: 0;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }

  @container product-catalog (max-width: 760px) {
    .catalog .product {
      grid-template-columns: 58px minmax(128px, 1fr) 76px minmax(112px, auto) !important;
      grid-template-rows: auto auto;
      gap: 8px 10px;
    }

    .catalog .product-thumb {
      grid-column: 1 !important;
      grid-row: 1 / 3 !important;
      width: 58px;
      height: 58px;
      align-self: center;
    }

    .catalog .product-info {
      grid-column: 2 / -1 !important;
      grid-row: 1 !important;
    }

    .catalog .product-info h3 {
      overflow-wrap: break-word;
      word-break: normal;
    }

    .catalog .product-price {
      grid-column: 2 !important;
      grid-row: 2 !important;
      justify-self: start;
    }

    .catalog .product > input {
      grid-column: 3 !important;
      grid-row: 2 !important;
      width: 76px;
    }

    .catalog .product > button {
      grid-column: 4 !important;
      grid-row: 2 !important;
      min-width: 112px;
      max-width: 180px;
      white-space: normal;
    }
  }

  @container product-catalog (max-width: 600px) {
    .catalog .catalog-head {
      display: grid;
      align-items: stretch;
      gap: 10px;
    }

    .catalog .catalog-head input {
      width: 100%;
      max-width: none;
      margin: 0;
    }
  }

  @container product-catalog (max-width: 540px) {
    .catalog .product {
      grid-template-columns: 52px minmax(0, 1fr) 72px !important;
      grid-template-rows: auto auto auto;
    }

    .catalog .product-thumb {
      grid-row: 1 / 4 !important;
      width: 52px;
      height: 58px;
    }

    .catalog .product-info {
      grid-column: 2 / -1 !important;
    }

    .catalog .product-price {
      grid-column: 2 !important;
    }

    .catalog .product > input {
      grid-column: 3 !important;
      width: 72px;
    }

    .catalog .product > button {
      grid-column: 2 / -1 !important;
      grid-row: 3 !important;
      width: 100%;
      max-width: none;
      min-height: 40px;
    }
  }

  @container product-catalog (max-width: 420px) {
    .catalog .product {
      grid-template-columns: 52px minmax(0, 1fr) !important;
      grid-template-rows: auto auto auto auto;
    }

    .catalog .product-thumb {
      grid-row: 1 / 3 !important;
    }

    .catalog .product-info,
    .catalog .product-price,
    .catalog .product > input,
    .catalog .product > button {
      grid-column: 2 !important;
      width: 100%;
    }

    .catalog .product-price {
      grid-row: 2 !important;
    }

    .catalog .product > input {
      grid-row: 3 !important;
    }

    .catalog .product > button {
      grid-row: 4 !important;
    }
  }
}

.cart-scroll-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 0;
  color: #526b62;
  font-size: 11px;
  font-weight: 700;
}

.cart-scroll-controls[hidden] {
  display: none;
}

.cart-scroll-controls > div {
  display: flex;
  gap: 6px;
}

.cart-scroll-controls button {
  display: grid;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid #b9d6ca;
  border-radius: 8px;
  background: #edf7f2;
  color: #15543e;
  font-size: 20px;
  line-height: 1;
}

.cart-scroll-controls button:hover:not(:disabled),
.cart-scroll-controls button:focus-visible {
  border-color: #4c9177;
  background: #dcefe7;
}

.cart-scroll-controls button:focus-visible,
.cart #cart-items:focus-visible {
  outline: 3px solid rgba(41, 116, 87, .25);
  outline-offset: 2px;
}

.cart #cart-items {
  scrollbar-width: auto;
  scrollbar-color: #587c6e #edf3f0;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.cart #cart-items::-webkit-scrollbar {
  width: 14px;
}

.cart #cart-items::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #edf3f0;
}

.cart #cart-items::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 3px solid #edf3f0;
  border-radius: 999px;
  background: #587c6e;
}

/* Każda ścieżka koszyka (zwykła, promocyjna i nagroda) używa tego samego
 * miniaturowego zdjęcia oraz tych samych kolumn. */
.cart .cart-row {
  grid-template-columns: 46px minmax(0, 1fr) 64px auto;
  gap: 8px;
}

.cart .cart-row-promotion {
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
}

.cart-product-thumb {
  display: grid;
  place-items: center;
  align-self: start;
  width: 46px;
  height: 52px;
  overflow: hidden;
  border: 1px solid #dbe7e2;
  border-radius: 8px;
  background: #f5f8f7;
}

.cart-product-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.cart-product-thumb.missing::after {
  content: "N";
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 7px;
  background: #e4efea;
  color: #4d7467;
  font-size: 12px;
  font-weight: 800;
}

.cart .cart-row > p {
  align-self: center;
}

.cart .cart-row > input {
  width: 64px;
}

.cart .cart-promo-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

@media (min-width: 901px) {
  .page {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .page > .cards {
    grid-column: 1 / -1;
  }

  .catalog,
  .cart {
    grid-row: 2;
  }

  .cart {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .cart #cart-items {
    flex: 1 1 240px;
    min-height: clamp(180px, 28vh, 310px);
    max-height: none;
    margin: 9px 0;
    padding: 2px 7px 2px 0;
    border-top: 1px solid #edf1ef;
    border-bottom: 1px solid #edf1ef;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .cart #promotion-status:not([hidden]) {
    flex: 0 1 auto;
    max-height: 184px;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .cart #promotion-status .promotion-carousel-nav {
    margin-bottom: 7px;
    padding-bottom: 6px;
  }

  .cart #promotion-status .promotion-head {
    gap: 5px 8px;
  }

  .cart #promotion-status progress.promotion-progress {
    margin: 8px 0 6px;
  }

  .cart #promotion-status .promotion-scope.promotion-scope-link {
    margin-top: 6px;
    padding-top: 7px;
  }
}

@media (min-width: 901px) and (max-height: 800px) {
  .cart #cart-items {
    min-height: 140px;
    max-height: min(34vh, 240px);
  }

  .cart #promotion-status:not([hidden]) {
    max-height: 142px;
    padding: 10px;
    overflow-y: auto;
  }

  .cart #promotion-status .promotion-scope.promotion-scope-link,
  .cart #promotion-status .promotion-carousel-note {
    display: none;
  }
}

@media (max-width: 900px) {
  .client-summary {
    width: 100%;
  }

  .client-summary #welcome {
    flex: 1 1 auto;
  }

  .client-summary #meta {
    flex: 0 1 auto;
  }

  .cart #cart-items {
    min-height: 180px;
    max-height: min(52vh, 440px);
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}

/*
 * Between the mobile breakpoint and a genuinely usable two-column desktop
 * width, place the cart below the catalog. Keeping a 360px cart beside the
 * catalog in this narrow range leaves too little room even for a stacked card.
 */
@media (min-width: 901px) and (max-width: 1100px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app > aside {
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .content {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .page {
    height: auto;
    min-height: calc(100vh - 42px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .catalog,
  .cart {
    grid-row: auto;
    height: auto;
  }

  .catalog {
    overflow: visible;
  }

  .products {
    height: min(55vh, 560px);
    min-height: 360px;
  }

  .cart {
    max-height: none;
    overflow: visible;
  }

  .cart #cart-items {
    flex: 0 1 auto;
    min-height: 180px;
    max-height: 420px;
  }
}

@media (max-width: 600px) {
  .client-summary #welcome {
    font-size: 14px;
  }

  .client-summary #meta {
    display: none;
  }
}

/* Na telefonie nazwa produktu dostaje cały pierwszy wiersz, a sterowanie
 * ilością drugi. Zapobiega to układaniu tekstu po jednej literze. */
@media (max-width: 480px) {
  .cart .cart-row,
  .cart .cart-row-promotion {
    grid-template-columns: 44px minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px 8px;
  }

  .cart-product-thumb {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 44px;
    height: 50px;
  }

  .cart .cart-row > p {
    grid-column: 2 / 4;
    grid-row: 1;
    width: 100%;
  }

  .cart .cart-row > input,
  .cart .cart-row > .cart-promo-quantity {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .cart .cart-row > button,
  .cart .cart-row > .cart-promo-actions {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }

  .cart .cart-row > input {
    width: 68px;
  }

  .cart .cart-row p,
  .cart .cart-row p strong,
  .cart .cart-row p small {
    overflow-wrap: anywhere;
    word-break: normal;
  }
}
