/* FineFood header + catalog component
   Requires global variables from main stylesheet:
   --red, --red-dark, --red-soft, --green, --green-dark,
   --green-soft, --orange, --cream, --ink, --muted, --line,
   --white, --shadow

   Also expects the global .wrap rule to remain in the main stylesheet.
*/

/* Top line */
.topline {
  height: 34px;
  background: #302d2b;
  color: #fff;
  font-size: 13px;
}

.topline .wrap {
  height: 100%;
  display: flex;
  align-items: center;
}

.topline strong {
  color: #f3d363;
}

.topline nav {
  margin-left: auto;
  display: flex;
  gap: 25px;
}

.topline a {
  color: #ddd6d0;
  text-decoration: none;
  font-size: 13px;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-main {
  height: 94px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.logo {
  width: 143px;
  height: 70px;
  display: grid;
  place-items: center;
  flex: 0 0 143px;
}

.logo img {
  width: 126px;
  height: 68px;
  object-fit: contain;
}

/* Catalog button */
.catalog-btn {
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 20px #e9332b22;
  transition: 0.2s;
}

.catalog-btn:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
}

.catalog-btn i,
.catalog-btn i:before,
.catalog-btn i:after {
  width: 17px;
  height: 2px;
  background: currentColor;
  display: block;
  border-radius: 2px;
}

.catalog-btn i {
  position: relative;
}

.catalog-btn i:before,
.catalog-btn i:after {
  content: "";
  position: absolute;
  left: 0;
}

.catalog-btn i:before {
  top: -6px;
}

.catalog-btn i:after {
  top: 6px;
}

.catalog-btn[aria-expanded="true"] {
  background: var(--red-dark);
  box-shadow: 0 0 0 4px var(--red-soft);
}

/* Search */
.search {
  height: 50px;
  flex: 1;
  border: 2px solid #e7e1da;
  border-radius: 12px;
  display: flex;
  align-items: center;
  background: #fff;
  transition: 0.2s;
}

.search:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.search input {
  border: 0;
  outline: 0;
  min-width: 0;
  flex: 1;
  padding: 0 16px;
  font-size: 16px;
}

.search button {
  width: 50px;
  height: 46px;
  border: 0;
  border-radius: 0 9px 9px 0;
  background: var(--green);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
}

/* Header links */
.header-link {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  border-radius: 10px;
  padding: 0 9px;
  transition: 0.2s;
}

.header-link:hover {
  background: var(--cream);
}

.header-link .icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--cream);
  display: grid;
  place-items: center;
  font-size: 17px;
}

.header-link small,
.header-link b {
  display: block;
  white-space: nowrap;
}

.header-link small {
  color: var(--muted);
  font-size: 12px;
}

.header-link b {
  font-size: 14px;
}

/* Mini cart */
.cart {
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  box-shadow: 0 8px 22px #7fb91f24;
  transition: 0.2s;
  text-decoration: none;
}

.cart:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.cart-icon {
  font-size: 21px;
  position: relative;
}

.cart-count {
  position: absolute;
  right: -9px;
  top: -8px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--red);
  font-size: 10px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

.cart b,
.cart small {
  display: block;
  text-align: left;
}

.cart small {
  font-size: 12px;
  color: #ebffd0;
}

.cart b {
  font-size: 14px;
}

/* Catalog overlay */
.catalog-overlay {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: #231f2070;
  opacity: 0;
  visibility: hidden;
  transition: 0.2s;
  backdrop-filter: blur(1px);
}

.catalog-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Catalog menu */
.catalog-menu {
  position: fixed;
  z-index: 45;
  top: 120px;
  left: max(24px, calc((100vw - min(1370px, calc(100vw - 48px))) / 2 + 169px));
  width: 440px;
  max-height: calc(100dvh - 142px);
  display: flex;
  flex-direction: column;
  border: 1px solid #eee6df;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 26px 75px #2d1e1740;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: 0.2s;
  overflow: hidden;
}

.catalog-menu.open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.catalog-menu:before {
  content: "";
  position: absolute;
  top: -9px;
  left: 42px;
  width: 18px;
  height: 18px;
  background: #fff;
  transform: rotate(45deg);
  border-left: 1px solid #eee6df;
  border-top: 1px solid #eee6df;
}

.catalog-menu-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(115deg, #fff7f4, #fff);
}

.catalog-menu-head i {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 20px;
  font-weight: 800;
}

.catalog-menu-head h2 {
  margin: 0;
  font-size: 18px;
}

.catalog-menu-head p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.catalog-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: #f7f3ee;
  color: var(--ink);
  font-size: 21px;
  cursor: pointer;
}

.catalog-list {
  padding: 7px;
  overflow: auto;
  overscroll-behavior: contain;
}

.catalog-item {
  min-height: 50px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: 0.16s;
}

.catalog-item:hover,
.catalog-item:focus-visible {
  background: var(--red-soft);
  color: var(--red);
  outline: 0;
}

.catalog-item .cat-pic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #f8f5ef;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--red);
  font-size: 16px;
  font-weight: 800;
}

.catalog-item .cat-pic img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.catalog-item b {
  font-size: 13px;
  line-height: 1.25;
}

.catalog-item small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.catalog-item em {
  font-style: normal;
  color: #aaa;
  font-size: 20px;
}

.catalog-toolbar {
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.catalog-item.all {
  background: var(--green-soft);
  color: var(--green-dark);
  margin-bottom: 5px;
}

.catalog-item.all .cat-pic {
  background: #fff;
  color: var(--green-dark);
}

.catalog-parent {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.catalog-parent em {
  transition: 0.18s;
}

.catalog-parent[aria-expanded="true"] {
  background: var(--red-soft);
  color: var(--red);
}

.catalog-parent[aria-expanded="true"] em {
  transform: rotate(180deg);
}

.catalog-branch {
  border-radius: 10px;
  overflow: hidden;
}

.subcat-list {
  display: none;
  margin: 0 7px 5px 55px;
  padding: 3px 0 6px 12px;
  border-left: 2px solid #f0ded8;
}

.catalog-branch.open .subcat-list {
  display: grid;
}

.subcat-list a {
  min-height: 35px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  color: #5e5751;
  text-decoration: none;
  font-size: 11px;
  font-weight: 650;
}

.subcat-list a:first-child {
  color: var(--red);
  font-weight: 800;
}

.subcat-list a span {
  margin-left: auto;
  color: #aaa;
}

.subcat-list a:hover,
.subcat-list a:focus-visible {
  background: #f8f4ef;
  color: var(--red);
  outline: 0;
}

.catalog-row {
  min-height: 56px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 9px;
  padding: 4px 4px 4px 10px;
  border-radius: 10px;
  transition: 0.16s;
}

.catalog-row:hover,
.catalog-branch.open > .catalog-row {
  background: var(--red-soft);
}

.catalog-row > .cat-pic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #f8f5ef;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.catalog-row > .cat-pic img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.catalog-main {
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  border-radius: 7px;
}

.catalog-main b {
  font-size: 14px;
  line-height: 1.22;
}

.catalog-main small {
  margin-top: 3px;
  color: #6f665e;
  font-size: 11px;
  font-weight: 650;
}

.catalog-main:hover b,
.catalog-main:focus-visible b {
  color: var(--red);
}

.catalog-main:focus-visible {
  outline: 2px solid #e9332b55;
  outline-offset: 2px;
}

.catalog-expand {
  width: 38px;
  height: 42px;
  border: 0;
  border-left: 1px solid #eee6df;
  background: transparent;
  color: #80756d;
  font-size: 19px;
  cursor: pointer;
  border-radius: 0 8px 8px 0;
}

.catalog-expand:hover,
.catalog-expand:focus-visible {
  background: #fff;
  color: var(--red);
  outline: 0;
}

.catalog-expand span {
  display: block;
  transition: 0.18s;
}

.catalog-expand[aria-expanded="true"] span {
  transform: rotate(180deg);
}

.catalog-side {
  display: none;
}

.catalog-side-kicker {
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.catalog-side h3 {
  margin: 7px 0 16px;
  font-size: 20px;
  line-height: 1.25;
}

.catalog-side-links {
  display: grid;
  gap: 4px;
}

.catalog-side-links a {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  color: #4e4741;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.catalog-side-links a:first-child {
  background: var(--green-soft);
  color: var(--green-dark);
}

.catalog-side-links a:hover,
.catalog-side-links a:focus-visible {
  background: var(--red-soft);
  color: var(--red);
  outline: 0;
}

.catalog-side-links a span {
  margin-left: auto;
  color: #aaa;
}

body.catalog-open {
  overflow: hidden;
}

/* Desktop catalog flyout */
@media (min-width: 1024px) {
  .catalog-menu {
    overflow: visible;
  }

  .catalog-toolbar {
    border-radius: 16px 16px 0 0;
  }

  .catalog-list {
    background: #fff;
    border-radius: 0 0 16px 16px;
  }

  .catalog-branch .subcat-list,
  .catalog-branch.open .subcat-list {
    display: none;
  }

  .catalog-side {
    position: absolute;
    left: calc(100% + 12px);
    top: 0;
    width: 340px;
    max-height: min(520px, calc(100dvh - 140px));
    overflow: auto;
    padding: 22px;
    border: 1px solid #eee6df;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 26px 75px #2d1e1738;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: 0.18s;
  }

  .catalog-side.open {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .catalog-side:before {
    content: "";
    position: absolute;
    left: -7px;
    top: 75px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-left: 1px solid #eee6df;
    border-bottom: 1px solid #eee6df;
    transform: rotate(45deg);
  }
}

/* <= 1279 */
@media (max-width: 1279px) {
  .header-main {
    gap: 12px;
  }

  .logo {
    width: 112px;
    flex-basis: 112px;
  }

  .logo img {
    width: 106px;
  }

  .catalog-btn {
    padding: 0 13px;
  }

  .header-main > .header-link:nth-of-type(2) {
    display: none;
  }

  .header-link {
    padding: 0 5px;
  }
}

/* <= 1023 */
@media (max-width: 1023px) {
  .topline nav a:not(:last-child) {
    display: none;
  }

  .header {
    position: relative;
  }

  .header-main {
    height: auto;
    min-height: 146px;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: 76px 52px;
    gap: 8px 12px;
    padding: 6px 0 12px;
  }

  .logo {
    grid-column: 1;
    width: 112px;
  }

  .catalog-btn {
    grid-column: 2;
    justify-self: start;
  }

  .header-main > .header-link:first-of-type {
    display: flex;
    grid-column: 3;
  }

  .header-main > .header-link:nth-of-type(2) {
    display: flex;
    grid-column: 3;
  }

  .cart {
    grid-column: 4;
  }

  .search {
    grid-row: 2;
    grid-column: 1/-1;
  }

  .catalog-menu {
    top: 91px;
    left: 138px;
  }
}

/* <= 767 */
@media (max-width: 767px) {
  .topline {
    height: 30px;
  }

  .topline .wrap {
    justify-content: center;
  }

  .topline span {
    font-size: 11px;
    white-space: nowrap;
  }

  .topline nav {
    display: none;
  }

  .header-main {
    min-height: 130px;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: 66px 48px;
    gap: 8px;
  }

  .logo {
    width: 94px;
    flex-basis: auto;
  }

  .logo img {
    width: 92px;
    height: 62px;
  }

  .catalog-btn {
    grid-column: 2;
    height: 44px;
    padding: 0 12px;
    font-size: 13px;
  }

  .catalog-btn i {
    display: none;
  }

  .header-main > .header-link:nth-of-type(2) {
    display: none;
  }

  .header-main > .header-link:nth-of-type(3) {
    display: flex;
    grid-column: 3;
    grid-row: 1;
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .header-link span:last-child {
    display: none;
  }

  .header-link .icon {
    width: 44px;
    height: 44px;
  }

  .cart {
    grid-column: 4;
    width: 46px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .cart > span:last-child {
    display: none;
  }

  .cart-icon {
    font-size: 19px;
  }

  .search {
    height: 48px;
  }

  .search input {
    font-size: 14px;
    padding: 0 12px;
  }

  .search button {
    height: 44px;
    width: 45px;
  }

  .catalog-menu {
    inset: auto 8px 8px 8px;
    width: auto;
    max-height: 78dvh;
    border-radius: 17px;
    transform: translateY(100%);
  }

  .catalog-menu.open {
    transform: none;
  }

  .catalog-menu:before {
    display: none;
  }

  .catalog-menu-head {
    padding: 15px 15px 12px;
  }

  .catalog-list {
    padding: 6px;
  }

  .catalog-item {
    min-height: 53px;
  }

  .catalog-menu-foot {
    padding-bottom: max(11px, env(safe-area-inset-bottom));
  }
}

/* <= 420 */
@media (max-width: 420px) {
  .header-main {
    grid-template-columns: 83px 1fr 44px 46px;
    gap: 6px;
  }

  .logo {
    width: 83px;
  }

  .logo img {
    width: 82px;
  }

  .catalog-btn {
    padding: 0 9px;
    font-size: 12px;
  }

  .topline span {
    font-size: 10px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .topline *,
  .header *,
  .catalog-overlay,
  .catalog-menu,
  .catalog-menu * {
    transition: none !important;
    animation: none !important;
  }
}
