/* ============================================================================
 * Favourites — hearts on item cards, the Favourites pop-up, the toast.
 * Own file on purpose: iteams.css differs between development and master, so
 * editing it would stop this commit cherry-picking cleanly.
 * Loaded by header_v2.php only while Favourites_model::ENABLED is true.
 * ========================================================================== */

:root {
  --fav-red: #e0245e;
  --fav-ink: #1a1a1a;
  --fav-muted: #6b6b6b;
  --fav-line: #ececec;
  --fav-surface: #ffffff;
}

/* ---- heart on the menu card ---------------------------------------------- */

/* The card (.iteam_menu, already position:relative in iteams.css / iteams-v2.css) is the
   positioning context. Top-right over the image, where the original design put it
   (.favourateIcon in iteams.css). 44px hit area, 30px disc. */
.fav-heart {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 4;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fav-heart svg {
  width: 30px;
  height: 30px;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.16);
  overflow: visible;
}

.fav-heart path {
  fill: none;
  stroke: var(--fav-ink);
  stroke-width: 1.6;
  stroke-linejoin: round;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.fav-heart--on path { fill: var(--fav-red); stroke: var(--fav-red); }
.fav-heart--on svg { animation: favPop 0.28s ease-out; }

.fav-heart:focus-visible svg { outline: 2px solid var(--fav-ink); outline-offset: 2px; }

@keyframes favPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* A card without an image has the name running to the right edge: keep it clear of the heart. */
.iteam_menu:not(:has(.item_img)) > .fav-heart ~ .iteam_name .menu_title { padding-right: 40px; }

/* ---- pop-up -------------------------------------------------------------- */

html.fav-open { overflow: hidden; }

.fav-dialog[hidden] { display: none !important; }

/* Above the storefront's fixed mobile header (.mobile-v, z-index 9991), which otherwise sits over
   the top of the sheet. The item pop-ups never stack on this: tapping a favourite closes it first. */
.fav-dialog { position: fixed; inset: 0; z-index: 10000; }

.fav-dialog__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }

.fav-dialog__box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--fav-surface);
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(16, 24, 40, 0.24);
  overflow: hidden;
}

.fav-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 12px 20px;
  border-bottom: 1px solid var(--fav-line);
}

.fav-dialog__title { margin: 0; font-size: 20px; font-weight: 700; color: var(--fav-ink); }

.fav-dialog__close {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: var(--fav-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fav-dialog__close:hover { background: #f3f3f4; }
.fav-dialog__close:focus:not(:focus-visible) { outline: none; }
.fav-dialog__close:focus-visible { outline: 2px solid var(--fav-ink); outline-offset: 2px; }

.fav-dialog__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 0 20px; }

/* Mobile: full-height sheet from the bottom. */
@media (max-width: 767px) {
  .fav-dialog__box {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-height: 92vh;
    height: 92vh;
    border-radius: 16px 16px 0 0;
    animation: favSheetIn 0.22s ease-out;
  }
}

@keyframes favSheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- rows ---------------------------------------------------------------- */

.fav-list { list-style: none; margin: 0; padding: 0 8px; }

.fav-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--fav-line);
}
.fav-row:last-child { border-bottom: 0; }

.fav-row__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 12px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 12px;
}
button.fav-row__main:hover { background: #f7f7f8; }
button.fav-row__main:focus-visible { outline: 2px solid var(--fav-ink); outline-offset: -2px; }

.fav-row__img {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f3f4;
}

.fav-row__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.fav-row__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--fav-ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-row__price { font-size: 14px; font-weight: 600; color: var(--fav-ink); }

.fav-row__add {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e5e5e5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--fav-ink);
  background: #fff;
}

/* In the pop-up the heart sits in the row, not on top of a card. */
.fav-row .fav-heart { position: static; flex: 0 0 44px; }

/* Not available right now: greyed, not tappable, still removable. */
.fav-row--off .fav-row__main { cursor: default; }
.fav-row--off .fav-row__img { filter: grayscale(1); opacity: 0.55; }
.fav-row--off .fav-row__name { color: var(--fav-muted); }
.fav-row__state { font-size: 13px; color: var(--fav-muted); }

.fav-subhead {
  margin: 20px 20px 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fav-muted);
}

.fav-note { margin: 12px 20px 0; font-size: 13px; color: var(--fav-muted); }

/* ---- empty and loading ---------------------------------------------------- */

.fav-empty { padding: 48px 24px; text-align: center; color: var(--fav-muted); }
.fav-empty svg { color: var(--fav-red); margin-bottom: 12px; }
.fav-empty__title { margin: 0 0 6px; font-size: 17px; font-weight: 700; color: var(--fav-ink); }
.fav-empty__text { margin: 0; font-size: 14px; }

.fav-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--fav-muted);
  font-size: 14px;
}

.fav-spin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(26, 26, 26, 0.15);
  border-top-color: var(--fav-ink);
  animation: favSpin 0.7s linear infinite;
}
@keyframes favSpin { to { transform: rotate(360deg); } }

/* ---- load failure -------------------------------------------------------- */

.fav-error { padding: 40px 24px; text-align: center; }
.fav-error__text { margin: 0 0 16px; font-size: 15px; color: var(--fav-ink); }
.fav-error__retry {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--fav-ink);
  border-radius: 22px;
  background: #fff;
  color: var(--fav-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.fav-error__retry:focus-visible { outline: 2px solid var(--fav-ink); outline-offset: 2px; }

/* ---- toast --------------------------------------------------------------- */

.fav-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10001;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--fav-ink);
  color: #fff;
  font-size: 14px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fav-toast--show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .fav-heart--on svg,
  .fav-dialog__box { animation: none; }
  .fav-toast { transition: none; }
}
