/*
Theme Name: Wildflower
Theme URI: https://dev.wildflower.co.il
Author: Wildflower
Description: Custom FSE block theme for Wildflower TLV. Mobile-first, RTL-native, brand tokens in theme.json.
Version: 0.6.2
Requires at least: 6.6
Tested up to: 6.9
Requires PHP: 8.1
License: Proprietary
Text Domain: wildflower
Tags: full-site-editing, block-templates, block-styles, rtl-language-support
*/

:root {
  --wf-radius-sm: 12px;
  --wf-radius-md: 8px;
  --wf-radius-lg: 12px;
  --wf-radius-xl: 16px;
  --wf-radius-pill: 9999px;
  --wf-radius: 20px;

  --wf-shadow-sm: 0 1px 2px rgba(42, 42, 42, 0.06);
  --wf-shadow-md: 0 4px 12px rgba(42, 42, 42, 0.08);
  --wf-shadow-lg: 0 12px 32px rgba(42, 42, 42, 0.12);
  --wf-shadow-xl: 0 24px 48px rgba(42, 42, 42, 0.16);
  --wf-shadow: 0 6px 20px rgba(42, 42, 42, 0.06);
  --wf-shadow-hover: 0 12px 32px rgba(42, 42, 42, 0.10);

  --wf-motion-fast: 150ms;
  --wf-motion-base: 250ms;
  --wf-motion-slow: 400ms;
  --wf-ease: cubic-bezier(0.2, 0, 0, 1);

  /* Spec tokens (wildflower-product-card-spec §2) */
  --wf-primary: #8A5FAC;
  --wf-primary-soft: #AB92BF;
  --wf-primary-dark: #5E3D7E;
  --wf-mint: #CDF9F2;          /* reserved for future use (loyalty etc.) */
  --wf-banner-bg: #F2F4F7;     /* neutral gray banner surface */
  --wf-bg: #FFFCFA;
  --wf-text: #2A2A2A;
  --wf-text-muted: #6B6B6B;
  --wf-text-strike: #A6A6A6;
  --wf-sale: #B53A4A;
  --wf-warn: #C97A3F;
  --wf-divider: rgba(42, 42, 42, 0.08);

  --wf-banner-min-h: 64px;
}

html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* Buttons inherit theme.json tokens but get smooth transition */
.wp-block-button__link {
  transition: background-color var(--wf-motion-base) var(--wf-ease),
              transform var(--wf-motion-fast) var(--wf-ease),
              box-shadow var(--wf-motion-base) var(--wf-ease);
  box-shadow: var(--wf-shadow-sm);
}
.wp-block-button__link:hover { box-shadow: var(--wf-shadow-md); transform: translateY(-1px); }
.wp-block-button__link:active { transform: translateY(0); }

/* Style guide swatch helper */
.wf-swatch {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem; border-radius: var(--wf-radius-md);
  border: 1px solid var(--wp--preset--color--border);
  background: var(--wp--preset--color--surface);
  box-shadow: var(--wf-shadow-sm);
}
.wf-swatch__chip { height: 88px; border-radius: var(--wf-radius-sm); border: 1px solid rgba(0,0,0,0.05); }
.wf-swatch__name { font-weight: 600; font-size: 0.875rem; }
.wf-swatch__hex  { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.75rem; color: var(--wp--preset--color--text-muted); }

[dir="rtl"] .wf-swatch { text-align: right; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   wf-card · v2 · per wildflower-product-card-spec.md
   BEM, logical props, no !important, stretched-link pattern.
   ============================================================ */

.wf-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
@media (min-width: 768px)  { .wf-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1180px) { .wf-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; } }

.wf-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--wf-radius);
  overflow: hidden;
  color: var(--wf-text);
  box-shadow: var(--wf-shadow);
  isolation: isolate;
  transition: box-shadow var(--wf-motion-base) var(--wf-ease),
              transform var(--wf-motion-base) var(--wf-ease);
}
.wf-card:hover { box-shadow: var(--wf-shadow-hover); transform: translateY(-2px); }

/* === Stretched link (avoids nested <a>) === */
.wf-card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
  text-decoration: none;
  color: transparent;
  overflow: hidden;
  text-indent: -9999px;
}
.wf-card__link:focus-visible {
  outline: 2px solid var(--wf-primary);
  outline-offset: -2px;
  border-radius: var(--wf-radius);
}

/* Interactive overlays sit ABOVE the stretched link */
.wf-card__banner    { position: relative; z-index: 2; }
.wf-card__sizes,
.wf-card__quick-add { z-index: 4; }
.wf-card__oos-strip { z-index: 4; }

/* === Media === */
.wf-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: #F4EFEC;
  overflow: hidden;
}
.wf-card__media-inner {
  position: absolute;
  inset: 0;
  transition: opacity 280ms ease;
}
.wf-card__media-inner.is-fading { opacity: 0; }
.wf-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* === Badges === */
.wf-card__badges {
  position: absolute;
  inset-block-start: 12px;
  inset-inline: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}
.wf-card__badge {
  padding: 6px 12px;
  border-radius: var(--wf-radius-pill);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: var(--wf-primary);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.wf-card__badge--sale     { background: var(--wf-sale); }
.wf-card__badge--new      { background: var(--wf-primary); }
.wf-card__badge--featured { background: var(--wf-primary); }
.wf-card__badge--limited  { background: var(--wf-warn); }
.wf-card__badge--popular  { background: var(--wf-warn); }
.wf-card__badge--lowstock { background: var(--wf-warn); }

/* === OOS strip === */
.wf-card.is-oos .wf-card__media-inner { filter: grayscale(60%) opacity(0.7); }
.wf-card.is-oos .wf-card__badges,
.wf-card.is-oos .wf-card__quick-add { display: none; }
.wf-card__oos-strip {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(42, 42, 42, 0.85);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* === Sizes (bottom leading edge → right in RTL) === */
.wf-card__sizes {
  position: absolute;
  inset-block-end: 12px;
  inset-inline-start: 12px;
  display: flex;
  gap: 3px;
  padding: 3px 5px;
  border-radius: var(--wf-radius-pill);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.wf-card__size {
  padding: 2px 9px;
  border-radius: var(--wf-radius-pill);
  font-size: 11px;
  font-weight: 700;
  color: var(--wf-text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  min-height: 22px;
  transition: background var(--wf-motion-fast) var(--wf-ease),
              color var(--wf-motion-fast) var(--wf-ease);
}
.wf-card__size:not(.is-active):not([aria-pressed="true"]):hover {
  background: rgba(138, 95, 172, 0.12);
  color: var(--wf-primary-dark);
}
.wf-card__size.is-active,
.wf-card__size[aria-pressed="true"] {
  background: var(--wf-primary);
  color: #fff;
  font-weight: 800;
}
.wf-card__size:focus-visible { outline: 2px solid var(--wf-primary); outline-offset: 1px; }

/* === Quick add (opposite corner from sizes; simple products only) === */
.wf-card__quick-add {
  position: absolute;
  inset-block-end: 12px;
  inset-inline-end: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--wf-primary);
  color: #fff;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(138, 95, 172, 0.30);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--wf-motion-base) var(--wf-ease),
              transform var(--wf-motion-base) var(--wf-ease),
              background var(--wf-motion-fast) var(--wf-ease);
}
@media (hover: hover) and (pointer: fine) {
  .wf-card:hover .wf-card__quick-add { opacity: 1; transform: translateY(0); }
}
@media (hover: none) {
  .wf-card__quick-add { opacity: 1; transform: translateY(0); }
}
.wf-card__quick-add:hover { background: var(--wf-primary-dark); }
.wf-card__quick-add:focus-visible {
  opacity: 1; transform: translateY(0);
  outline: 2px solid #fff; outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--wf-primary);
}

/* === Body === */
.wf-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 14px 16px 16px;
}
.wf-card__title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--wf-text);
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === Price row (sliding with size) === */
.wf-card__price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  transition: opacity 200ms ease;
}
.wf-card__price-row.is-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .wf-card__media-inner,
  .wf-card__price-row { transition: none; }
}
.wf-card__price-main {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 4px;
}
.wf-card__from {
  display: block;
  text-align: start;
  font-size: 11px;
  line-height: 1.05;
  color: var(--wf-text-muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.wf-card__price-current {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  color: var(--wf-text);
}
.wf-card__discount-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-bottom: 3px;
}
.wf-card__price-original {
  font-size: 13px;
  text-decoration: line-through;
  color: var(--wf-text-strike);
  font-weight: 700;
}
.wf-card__discount-pct {
  font-size: 13px;
  color: var(--wf-sale);
  font-weight: 800;
}

/* === Banner slot (always reserves height for equal cards) === */
.wf-card__banner-slot {
  margin-top: auto;
  min-height: var(--wf-banner-min-h);
  display: flex;
  align-items: stretch;
}

/* === Banner (single visual, gray surface, no chevron) === */
.wf-card__banner {
  flex: 1;
  background: var(--wf-banner-bg);
  border-radius: var(--wf-radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--wf-text);
  transition: background var(--wf-motion-fast) var(--wf-ease);
}
.wf-card__banner:hover { background: #E7EAF0; }
.wf-card__banner:focus-visible { outline: 2px solid var(--wf-primary); outline-offset: 2px; }

.wf-card__banner-icon {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--wf-primary-dark);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}
.wf-card__banner-text { flex: 1; min-width: 0; line-height: 1.25; }
.wf-card__banner-label {
  display: block;
  font-size: 13px;
  color: var(--wf-primary-dark);
  font-weight: 800;
}
.wf-card__banner-target { color: var(--wf-text); }
.wf-card__banner-sub {
  display: block;
  font-size: 12px;
  color: var(--wf-text);
  font-weight: 800;
  margin-top: 1px;
}
.wf-card__banner-sub-discount {
  color: var(--wf-sale);
  margin-inline-start: 4px;
}

/* Mobile tightening per spec §9 */
@media (max-width: 480px) {
  .wf-card__title { font-size: 15px; }
  .wf-card__banner { padding: 10px 12px; font-size: 13px; }
  .wf-card__price-current { font-size: 22px; }
  .wf-card__body { padding: 12px 14px 14px; }
}

/* Style guide layout helpers */
.wf-sg-state-label {
  font-size: 0.75rem;
  color: var(--wf-text-muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
