/* ============================================================
   Favoritter: hjerteknapper, teller i headeren og skuff fra høyre.
   ============================================================ */

/* Hjertet: tomt omriss, fylt rødt når objektet er lagret. */
.fav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: color .15s, border-color .15s, background-color .15s, transform .15s;
}
.fav-btn:hover { color: var(--sold); border-color: var(--sold); }
.fav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fav-btn .heart { transition: transform .2s ease, fill .15s; }
.fav-btn.is-on { color: var(--sold); border-color: var(--sold); }
.fav-btn.is-on .heart { fill: currentColor; }
.fav-btn.pop .heart { animation: fav-pop .35s ease; }
@keyframes fav-pop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Produktsiden: firkantet knapp til høyre for kjøpsknappen, samme høyde. */
.pdp .buy-row { display: flex; gap: 8px; align-items: stretch; }
.pdp .buy-row .buy-form { flex: 1; min-width: 0; }
.fav-btn-pdp { flex: none; width: 56px; min-height: 56px; border-radius: var(--r); }
.fav-btn-pdp .heart { width: 22px; height: 22px; }
.pdp .buy-row:not(:has(.buy-form)) .fav-btn-pdp { width: auto; padding: 0 18px; }

/* Produktkort: rund knapp øverst til høyre på bildet. */
.fav-btn-card {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 34px; height: 34px; border-radius: 50%; border-color: transparent;
  background: rgba(255,255,255,.92); box-shadow: 0 1px 3px rgba(20,23,28,.14);
}
.fav-btn-card .heart { width: 17px; height: 17px; }
.fav-btn-card.is-on { border-color: transparent; }

/* Header */
.tool-fav .count { display: none; }
.tool-fav.has-items .count { display: inline-flex; background: var(--sold); }
.tool-fav .heart { width: 17px; height: 17px; }
/* Tekstene i headeren skjules visuelt når plassen blir trang, men leses fortsatt av skjermlesere. */
@media (max-width: 1100px) {
  .tool-fav .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 720px) {
  .header-tools .tool .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .header-tools { gap: 0; }
  .header-tools .tool { padding: 8px; gap: 4px; }
}

/* Skuffen */
.fav-scrim {
  position: fixed; inset: 0; background: rgba(20,23,28,.42); z-index: 90;
  opacity: 0; transition: opacity .2s ease;
}
.fav-scrim.open { opacity: 1; }
.fav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(408px, 100%); z-index: 100;
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-3);
  transform: translateX(100%); transition: transform .24s cubic-bezier(.3,.7,.3,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fav-drawer.open { transform: translateX(0); }
.fav-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.fav-head h2 { font-family: var(--f-display); font-size: 17px; font-weight: 600; margin: 0; }
.fav-head-count { color: var(--muted); font-weight: 400; }
.fav-head .x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); padding: 4px 6px; border-radius: 3px; }
.fav-head .x:hover { background: var(--surface-2); color: var(--ink); }
.fav-body { flex: 1; overflow-y: auto; padding: 4px 18px; }
.fav-empty { margin: 24px 0; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.fav-list { list-style: none; margin: 0; padding: 0; }
.fav-item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.fav-img { display: block; width: 72px; height: 72px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--surface); }
.fav-img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.fav-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.fav-name { font-family: var(--f-display); font-size: 14.5px; font-weight: 500; line-height: 1.3; color: var(--ink); }
.fav-name:hover { color: var(--accent); }
.fav-meta { font-size: 12px; color: var(--muted); }
.fav-price { font-size: 14px; font-weight: 700; color: var(--ink); }
.fav-price .amount { color: inherit; }
.fav-price del { font-weight: 400; color: var(--muted); margin-right: 4px; }
.fav-price ins { text-decoration: none; }
.fav-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.fav-add {
  display: inline-flex; align-items: center; padding: 7px 12px; border-radius: var(--r);
  background: var(--accent); color: #fff !important; font-size: 12.5px; font-weight: 700;
}
.fav-add:hover { background: var(--accent-hi); }
.fav-drawer .added_to_cart { display: none; }
.fav-sold { font-size: 12.5px; font-weight: 600; color: var(--sold); }
.fav-remove { background: none; border: 0; padding: 0; font-size: 12.5px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.fav-remove:hover { color: var(--sold); }
.fav-note { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .fav-btn, .fav-btn .heart, .fav-drawer, .fav-scrim { transition: none; }
  .fav-btn.pop .heart { animation: none; }
}

/* Skeleton mens favorittene hentes */
.fav-skel .skel-row { grid-template-columns: 72px minmax(0, 1fr); gap: 14px; padding: 16px 0; }
.fav-skel .skel-img { width: 72px; height: 72px; }
