/* Font: Vazirmatn (OFL 1.1, licence in fonts/OFL.txt), stored locally so the page works offline */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Black.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.7;
  color: #2d2a26;
  background-color: #fffaf5;
  overflow-wrap: break-word;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 700;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button,
input {
  font-family: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 16px;
}

.hidden-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Keyboard focus ===== */
/* :focus-visible shows the ring for the keyboard, not for every mouse click */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.carousel:focus-visible {
  outline: 3px solid #c2410c;
  outline-offset: 3px;
}

/* main only gets focus from the skip link, it does not need a ring around the whole page */
#main:focus {
  outline: none;
}

/* ===== Skip link ===== */
/* it waits above the page and comes down only when it gets keyboard focus */
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: 16px;
  z-index: 100;
  padding: 12px 20px;
  font-weight: 700;
  color: #ffffff;
  background-color: #2d2a26;
  border-radius: 0 0 12px 12px;
  white-space: nowrap;
}

/* a thick white ring inside the dark box and an orange ring outside it */
.skip-link:focus {
  top: 0;
  outline: 3px solid #ffffff;
  outline-offset: -7px;
  box-shadow: 0 0 0 4px #fdba74;
}

/* ===== Category colours (from categories.json) ===== */
.bg-fruits {
  background-color: #fde3dc;
}

.bg-dairy {
  background-color: #e2eefc;
}

.bg-bakery {
  background-color: #fff0cc;
}

.bg-pantry {
  background-color: #e3f1e7;
}

.bg-drinks {
  background-color: #e0f5ef;
}

.bg-protein {
  background-color: #fbe0e6;
}

.bg-snacks {
  background-color: #f1e6fb;
}

/* ===== Buttons ===== */
.button-main {
  display: inline-block;
  min-height: 44px;
  padding: 10px 24px;
  font-weight: 700;
  text-align: center;
  color: #ffffff;
  background-color: #c2410c;
  border-radius: 12px;
}

.button-main:hover {
  background-color: #9a3412;
}

.button-light {
  display: inline-block;
  min-height: 44px;
  padding: 10px 24px;
  font-weight: 700;
  text-align: center;
  color: #9a3412;
  background-color: #ffffff;
  border-radius: 12px;
}

.button-light:hover {
  background-color: #fff1e6;
}

/* the hero is orange, so an orange ring would disappear there */
.button-light:focus-visible {
  outline-color: #ffffff;
}

/* ===== Notice bar ===== */
.notice-bar {
  padding: 6px 16px;
  font-size: 13px;
  text-align: center;
  color: #ffffff;
  background-color: #c2410c;
}

/* ===== Header ===== */
/* sticky = it stays at the top while the page scrolls */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: #ffffff;
  border-bottom: 1px solid #f1e4d8;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-block: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 12px;
}

.logo svg {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.shop-name {
  font-size: 20px;
  font-weight: 900;
  color: #c2410c;
  white-space: nowrap;
}

.slogan {
  font-size: 12px;
  color: #6b625a;
  white-space: nowrap;
}

/* the search box takes all the free space in the middle */
.search-box {
  flex: 1;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 14px;
  color: #2d2a26;
  background-color: #fffaf5;
  border: 1px solid #f1e4d8;
  border-radius: 999px;
}

.search-box input::placeholder {
  color: #6b625a;
}

.cart-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #9a3412;
  background-color: #fff1e6;
  border: 1px solid #f1e4d8;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

.cart-button:hover {
  background-color: #ffe4d1;
}

.cart-count {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding-inline: 4px;
  font-size: 13px;
  color: #ffffff;
  background-color: #c2410c;
  border-radius: 999px;
}

/* the ☰ label and its checkbox are only for phones */
.menu-checkbox {
  display: none;
}

.menu-button {
  display: none;
}

/* ===== Main menu ===== */
.main-menu {
  border-top: 1px solid #f1e4d8;
}

.menu-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 28px;
  font-size: 14px;
}

.menu-list > li > a {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.menu-list > li > a:hover {
  color: #c2410c;
}

/* the mega menu is placed against this item */
.all-categories {
  position: relative;
}

.all-categories-button {
  min-height: 44px;
  padding: 0;
  font-size: inherit;
  font-weight: 700;
  color: #c2410c;
  background: none;
  border: none;
  cursor: pointer;
}

/* ===== All categories mega menu ===== */
/* absolute = opening it moves nothing else on the page */
.mega-menu {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  width: 420px;
  padding: 12px;
  background-color: #ffffff;
  border: 1px solid #f1e4d8;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 16px 32px rgba(45, 42, 38, 0.14);
  /* visibility: hidden = closed links can not be clicked and Tab skips them */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  /* only opacity and transform animate; visibility waits for the fade to finish */
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

/* mouse over it, or keyboard focus anywhere inside it, opens it */
/* visibility is not animated when opening, so the links can get focus at once */
.all-categories:hover .mega-menu,
.all-categories:focus-within .mega-menu {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 0.2s, transform 0.2s;
}

.mega-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  font-weight: 700;
  border-radius: 10px;
}

.mega-menu a:hover {
  background-color: #fff1e6;
}

.mega-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 20px;
  border-radius: 50%;
}

/* ===== Hero row ===== */
.hero-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-block: 24px 40px;
}

.hero {
  position: relative;
  /* a fixed min-height, so the box does not change size when the font loads
     (that would push a #fragment section out of place while the page scrolls to it) */
  min-height: 320px;
  padding: 40px;
  color: #ffffff;
  background-color: #c2410c;
  border-radius: 24px;
}

/* room on the end side so the text never runs under the watermelon */
.hero-text {
  padding-inline-end: 160px;
}

.hero h1 {
  margin-bottom: 12px;
  font-size: 38px;
  font-weight: 900;
  line-height: 1.3;
}

.hero p {
  max-width: 420px;
  margin-bottom: 24px;
}

.hero-emoji {
  position: absolute;
  bottom: 24px;
  inset-inline-end: 32px;
  font-size: 120px;
  line-height: 1;
}

.side-banner {
  position: relative;
  min-height: 320px;
  padding: 28px;
  background-color: #fdba74;
  border-radius: 24px;
}

.side-banner h2 {
  margin-bottom: 4px;
  font-size: 22px;
  font-weight: 900;
}

.side-emoji {
  display: block;
  margin-block: 12px;
  font-size: 64px;
  line-height: 1;
  text-align: end;
}

.side-banner .button-main {
  display: block;
}

/* ===== Section titles ===== */
.categories h2,
.section-head h2,
.aisles h2 {
  font-size: 22px;
  font-weight: 900;
}

/* ===== Categories ===== */
.categories {
  margin-bottom: 40px;
}

.categories h2 {
  margin-bottom: 16px;
}

/* desktop: one row of 7 */
.category-list {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* room for a name on two lines, so every box has the same height with any font */
  min-height: 150px;
  padding: 16px 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background-color: #ffffff;
  border: 1px solid #f1e4d8;
  border-radius: 16px;
}

.category-item:hover {
  border-color: #c2410c;
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  font-size: 30px;
  border-radius: 50%;
  transition: transform 0.2s;
}

/* animation 3: the icon grows a little */
.category-item:hover .category-icon,
.category-item:focus-visible .category-icon {
  transform: scale(1.12);
}

/* ===== Product sections and carousels ===== */
.product-section {
  margin-bottom: 40px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.carousel-buttons {
  display: flex;
  gap: 8px;
}

.carousel-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 18px;
  color: #9a3412;
  background-color: #ffffff;
  border: 1px solid #f1e4d8;
  border-radius: 50%;
}

.carousel-button:hover {
  background-color: #fff1e6;
}

/* in LTR the first card is on the left, so the arrows turn around */
[dir="ltr"] .carousel-button {
  transform: scaleX(-1);
}

/* scroll-snap stops the track at the start of a card, never in the middle */
.carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 12px 4px 20px;
  border-radius: 16px;
}

/* ===== Product card ===== */
.product-card {
  position: relative;
  flex: 0 0 auto;
  width: 200px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  padding: 10px;
  background-color: #ffffff;
  border: 1px solid #f1e4d8;
  border-radius: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

/* animation 2: the card goes up a little; transform does not move the cards beside it */
.product-card:hover,
.product-card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(45, 42, 38, 0.14);
}

.product-image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  font-size: 56px;
  line-height: 1;
  border-radius: 12px;
}

.discount-badge {
  position: absolute;
  top: 16px;
  inset-inline-start: 16px;
  z-index: 1;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background-color: #b91c1c;
  border-radius: 999px;
}

/* the body grows, so the price row always sits at the bottom of the card */
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 4px 0;
}

.product-name {
  font-size: 15px;
  line-height: 1.5;
}

.product-unit {
  margin-bottom: 8px;
  font-size: 13px;
  color: #6b625a;
}

.price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.price {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.old-price {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: #6b625a;
}

.new-price {
  color: #b91c1c;
}

.add-button {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  background-color: #c2410c;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.add-button:hover {
  background-color: #9a3412;
}

/* ===== Promo banners ===== */
.promo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 40px;
}

.promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 96px;
  padding: 16px 28px;
  border-radius: 20px;
}

.promo-breakfast {
  background-color: #e3f1e7;
}

.promo-bread {
  background-color: #fde3dc;
}

.promo-text {
  font-size: 18px;
  font-weight: 700;
}

.promo-emoji {
  font-size: 48px;
  line-height: 1;
}

.promo:hover .promo-text {
  color: #9a3412;
}

/* ===== Aisles ===== */
.aisles {
  margin-bottom: 48px;
}

.aisles h2 {
  margin-bottom: 16px;
}

.aisle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.aisle {
  padding: 20px;
  border-radius: 20px;
}

.aisle-emoji {
  display: block;
  margin-bottom: 8px;
  font-size: 40px;
  line-height: 1;
}

.aisle h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.aisle-list li {
  padding-block: 2px;
  padding-inline-start: 14px;
  border-inline-start: 3px solid #c2410c;
  margin-bottom: 6px;
}

/* ===== Footer ===== */
.footer {
  padding-block: 40px 20px;
  color: #f5ede6;
  background-color: #3a2a20;
}

.footer-columns {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer h2 {
  margin-bottom: 12px;
  font-size: 17px;
  color: #ffffff;
}

.footer p {
  margin-bottom: 8px;
}

.footer address {
  font-style: normal;
}

.footer ul li {
  margin-bottom: 6px;
}

.footer a {
  color: #fdba74;
}

.footer a:hover {
  text-decoration: underline;
}

/* an orange ring is too dark on the brown footer, so it is light orange here */
.footer a:focus-visible {
  outline-color: #fdba74;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 32px;
  padding-top: 16px;
  font-size: 13px;
  border-top: 1px solid #5c4636;
}

.footer-bottom p {
  margin: 0;
}

.to-top {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ===== You are here (URL fragment) ===== */
/* the header is sticky (118px on desktop), so a section must stop a little lower */
#main,
#categories,
#offers,
#dairy,
#fruits,
#bakery,
#pantry,
#drinks,
#protein,
#snacks,
#contact,
#offers-first,
#offers-last,
#dairy-first,
#dairy-last {
  scroll-margin-top: 136px;
}

.here-label {
  display: none;
  margin-inline-start: 8px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background-color: #c2410c;
  border-radius: 999px;
  vertical-align: middle;
}

.categories:target .here-label,
.product-section:target .here-label,
.aisle:target .here-label,
.footer:target .here-label {
  display: inline-block;
}

/* an orange ring around the section the link brought you to */
.categories:target,
.product-section:target,
.aisle:target {
  outline: 3px solid #c2410c;
  outline-offset: 8px;
  border-radius: 16px;
}

/* the footer is full width, so the ring is drawn inside it */
.footer:target {
  outline: 3px solid #fdba74;
  outline-offset: -8px;
}

/* ===== Carousel messages (loading, error, empty) ===== */
.carousel-message {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: #5c534a;
  background-color: #fff1e6;
  border-radius: 16px;
}

.carousel-error {
  color: #8a1c1c;
  background-color: #fdecea;
}

/* ===== Tablet (900px and down) ===== */
@media (max-width: 900px) {
  .hero-text {
    padding-inline-end: 0;
  }

  .hero-emoji {
    font-size: 80px;
    opacity: 0.35;
  }

  .aisle-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-columns {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Mobile menu (768px and down) ===== */
@media (max-width: 768px) {
  .header-row {
    gap: 12px;
  }

  /* the checkbox is still invisible (hidden-text) but it can now get focus and Space ticks it */
  .menu-checkbox {
    display: block;
  }

  .menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    font-size: 22px;
    color: #2d2a26;
    background-color: #ffffff;
    border: 1px solid #f1e4d8;
    border-radius: 12px;
    cursor: pointer;
  }

  .menu-button:hover {
    background-color: #fff1e6;
  }

  /* the real checkbox is invisible, so its focus ring is drawn on the ☰ label */
  .menu-checkbox:focus-visible ~ .header-row .menu-button {
    outline: 3px solid #c2410c;
    outline-offset: 3px;
  }

  .menu-checkbox:checked ~ .header-row .menu-button {
    color: #ffffff;
    background-color: #c2410c;
  }

  /* closed: display none, so its links are out of the Tab order too */
  .main-menu {
    display: none;
    position: absolute;
    top: 100%;
    inset-inline: 0;
    background-color: #ffffff;
    border-bottom: 1px solid #f1e4d8;
    box-shadow: 0 16px 32px rgba(45, 42, 38, 0.14);
  }

  /* the ~ selector reaches the menu because it comes after the checkbox */
  .menu-checkbox:checked ~ .main-menu {
    display: block;
  }

  .menu-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block: 8px;
    font-size: 15px;
  }

  .menu-list > li {
    border-bottom: 1px solid #f1e4d8;
  }

  .menu-list > li:last-child {
    border-bottom: none;
  }

  .all-categories-button {
    width: 100%;
    text-align: start;
  }

  /* the header is one row here (73px) */
  #main,
  #categories,
  #offers,
  #dairy,
  #fruits,
  #bakery,
  #pantry,
  #drinks,
  #protein,
  #snacks,
  #contact,
  #offers-first,
  #offers-last,
  #dairy-first,
  #dairy-last {
    scroll-margin-top: 88px;
  }

  /* on phones the mega menu covers the list under it, full width */
  .mega-menu {
    width: auto;
    inset-inline-end: 0;
  }
}

/* ===== Phones (600px and down) ===== */
@media (max-width: 600px) {
  /* row 1: logo, cart, ☰  -  row 2: the search box */
  .header-row {
    flex-wrap: wrap;
    gap: 8px;
    padding-block: 8px;
  }

  /* min-width: 0 lets the logo text shrink, so the ☰ never drops to a new row
     (the fallback font is wider for a moment while Vazirmatn loads) */
  .logo {
    flex: 1;
    gap: 8px;
    min-width: 0;
  }

  .logo-text {
    min-width: 0;
  }

  .shop-name,
  .slogan {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logo svg {
    width: 40px;
    height: 40px;
  }

  .shop-name {
    font-size: 16px;
  }

  .slogan {
    font-size: 11px;
  }

  .search-box {
    order: 1;
    flex: 0 0 100%;
  }

  .cart-button {
    gap: 6px;
    padding: 6px 8px;
  }

  /* only the icon and the number are shown; the words stay for screen readers */
  .cart-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .hero-row {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-block: 16px 32px;
  }

  .hero {
    min-height: 260px;
    padding: 28px 20px;
  }

  .hero h1 {
    font-size: 27px;
  }

  .hero-emoji {
    bottom: 16px;
    inset-inline-end: 16px;
    font-size: 64px;
  }

  .side-banner {
    min-height: 0;
    padding: 20px;
  }

  /* phones: 4 columns, so the 7 categories make two rows */
  .category-list {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .category-item {
    min-height: 124px;
    padding: 10px 4px;
    font-size: 12px;
  }

  .category-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  /* smaller titles, so «پیشنهاد ویژه امروز» and the two buttons fit in one row */
  .categories h2,
  .section-head h2,
  .aisles h2 {
    font-size: 18px;
  }

  .product-card {
    width: 160px;
    min-height: 290px;
  }

  .carousel-message {
    min-height: 290px;
  }

  .product-image {
    height: 100px;
    font-size: 48px;
  }

  .price {
    font-size: 14px;
  }

  .promo-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .promo {
    min-height: 80px;
    padding: 12px 20px;
  }

  .aisle-grid {
    grid-template-columns: 1fr;
  }

  .footer-columns {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  #main,
  #categories,
  #offers,
  #dairy,
  #fruits,
  #bakery,
  #pantry,
  #drinks,
  #protein,
  #snacks,
  #contact,
  #offers-first,
  #offers-last,
  #dairy-first,
  #dairy-last {
    /* the header is two rows on phones (113px) */
    scroll-margin-top: 128px;
  }
}

/* ===== Smooth scrolling ===== */
/* only for people who did not ask their system for less motion */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ===== Reduce motion ===== */
/* the user asked the system for less motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  .mega-menu,
  .all-categories:hover .mega-menu,
  .all-categories:focus-within .mega-menu,
  .product-card:hover,
  .product-card:focus-within,
  .category-item:hover .category-icon,
  .category-item:focus-visible .category-icon {
    transform: none;
  }
}

/* The Notyf toast (its own class name) is right-to-left and uses the page font */
.notyf__toast {
  direction: rtl;
  font-family: "Vazirmatn", Tahoma, sans-serif;
}
