/* ==========================================================================
   OstuGrupp — Quick View (Kiirvaade) + Recently Viewed (Hiljuti vaadatud)
   Uses the design tokens from main.css. Self-enqueued by inc/quick-view.php
   and inc/recently-viewed.php.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card trigger — "Kiirvaade" quick-view pill

   Per the card DOM contract the quick-view trigger lives INSIDE
   .product-card__actions > .product-card__tools, side by side with the compare
   pill, BELOW the primary green "Lisa korvi". Both tools are small, equal-width
   ghost/outline buttons (slate, hover green). woocommerce.css scopes the shared
   look via .product-card__tools so the two pills are byte-identical there; this
   file just sets the trigger's own base style.

   IMPORTANT: the trigger is NOT absolutely positioned and carries no on-image
   overlay — it is a normal flow element inside the tools row. The matching small
   ghost style below is the fallback for any legacy layout where the trigger is a
   bare card child (no .product-card__tools wrapper). */
.product-card { position: relative; }

.ostu-qv-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 33px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--slate);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
/* Legacy bare-child layout (no tools wrapper): keep side gutters + bottom margin
   so the lone pill still aligns inside the card. Inside .product-card__tools the
   woocommerce.css scope resets these to a full-width flex child. */
.product-card > .ostu-qv-trigger { margin: 0 14px 14px; }
.ostu-qv-trigger__icon { display: inline-flex; color: currentColor; transition: color .18s ease; }
.ostu-qv-trigger__icon svg { width: 15px; height: 15px; }
.ostu-qv-trigger__label { line-height: 1; }

.ostu-qv-trigger:hover,
.ostu-qv-trigger:focus-visible {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.ostu-qv-trigger:hover .ostu-qv-trigger__icon,
.ostu-qv-trigger:focus-visible .ostu-qv-trigger__icon { color: var(--green); }
.ostu-qv-trigger:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Modal — overlay + dialog
   -------------------------------------------------------------------------- */
.ostu-qv {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ostu-qv[hidden] { display: none; }
/* Phones: trim the outer gutter so the dialog gets more usable width, and cap
   its height to the visual viewport so the close button + content stay reachable
   above the browser chrome / bottom nav. */
@media (max-width: 600px) {
  .ostu-qv { padding: 12px; align-items: flex-start; padding-top: max(12px, env(safe-area-inset-top)); }
}

.ostu-qv__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .25s ease;
}
.ostu-qv.is-open .ostu-qv__overlay { opacity: 1; }

.ostu-qv__dialog {
  position: relative;
  width: 100%;
  max-width: 920px;
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: 0 30px 80px -24px rgba(15, 23, 42, .45);
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transition: opacity .25s ease, transform .25s ease;
}
.ostu-qv.is-open .ostu-qv__dialog { opacity: 1; transform: translateY(0) scale(1); }

.ostu-qv__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--slate);
  box-shadow: var(--shadow-card);
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.ostu-qv__close:hover {
  background: var(--slate-dark);
  color: #fff;
  border-color: var(--slate-dark);
  transform: rotate(90deg);
}

/* Loading state */
.ostu-qv__loading,
.ostu-qv__content > .ostu-qv__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 40px;
}
.ostu-qv__spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  animation: ostu-qv-spin .7s linear infinite;
}
@keyframes ostu-qv-spin { to { transform: rotate(360deg); } }

.ostu-qv__error {
  padding: 48px 32px;
  text-align: center;
  color: var(--slate-600);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   In-modal product layout
   -------------------------------------------------------------------------- */
.ostu-qv-product {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 720px) {
  .ostu-qv-product { grid-template-columns: 1.05fr 1fr; }
}

.ostu-qv-product__gallery {
  background: var(--muted);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ostu-qv-product__stage {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ostu-qv-product__stage img,
.ostu-qv-product__main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 18px;
}
.ostu-qv-product__sale {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.ostu-qv-product__thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ostu-qv-product__thumb {
  width: 60px;
  height: 60px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
}
.ostu-qv-product__thumb img { width: 100%; height: 100%; object-fit: contain; }
.ostu-qv-product__thumb:hover { transform: translateY(-2px); }
.ostu-qv-product__thumb.is-active { border-color: var(--green); box-shadow: 0 0 0 2px rgba(5, 150, 105, .25); }

.ostu-qv-product__summary {
  padding: 32px 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Phones: trim the generous desktop gutters so the title/price/excerpt and the
   buy button get more readable width and aren't cramped. */
@media (max-width: 600px) {
  .ostu-qv-product__gallery { padding: 18px 18px 14px; gap: 12px; }
  .ostu-qv-product__summary { padding: 20px 18px 24px; gap: 12px; }
  .ostu-qv-product__title { font-size: clamp(20px, 5.5vw, 24px); padding-right: 40px; }
  .ostu-qv-product__price { font-size: 23px; }
}
.ostu-qv-product__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.2;
  color: var(--slate-dark);
  margin: 0;
  padding-right: 44px; /* clear the close button on narrow stacks */
}
.ostu-qv-product__rating { font-size: 14px; }
/* Same token as woocommerce.css — quick view used to keep the old 2.15:1 amber. */
.ostu-qv-product__rating .star-rating span::before { color: var(--rating, #b45309); }

.ostu-qv-product__price {
  font-size: 26px;
  font-weight: 700;
  color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
}
.ostu-qv-product__price del { color: var(--slate-500); font-size: 18px; font-weight: 500; opacity: .7; margin-right: 8px; }
.ostu-qv-product__price ins { text-decoration: none; color: var(--green-dark); }

.ostu-qv-product__excerpt {
  color: var(--slate-600);
  font-size: 15px;
  line-height: 1.7;
}
.ostu-qv-product__excerpt p { margin: 0 0 8px; }
.ostu-qv-product__excerpt :last-child { margin-bottom: 0; }

.ostu-qv-product__stock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate);
}
.ostu-qv-product__stock-dot { width: 9px; height: 9px; border-radius: 50%; }
.ostu-qv-product__stock-dot--in { background: var(--green); box-shadow: 0 0 0 3px rgba(5, 150, 105, .15); }
.ostu-qv-product__stock-dot--out { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .15); }

.ostu-qv-product__buy {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* The WC add-to-cart button rendered inside the modal */
.ostu-qv-product__buy .button,
.ostu-qv-product__buy a.add_to_cart_button,
.ostu-qv-product__buy a.added_to_cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow-green);
  transition: background .2s ease, transform .2s ease;
}
.ostu-qv-product__buy .button:hover { background: var(--green-dark); transform: translateY(-2px); }
.ostu-qv-product__buy .added_to_cart { background: var(--slate-dark); box-shadow: none; }
.ostu-qv-product__buy .btn-primary.ostu-qv-product__view { min-height: 52px; }

.ostu-qv-product__permalink {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
  align-self: flex-start;
}
.ostu-qv-product__permalink:hover { color: var(--green); text-decoration: underline; }

/* Lock background scroll while the modal is open. */
body.ostu-qv-open { overflow: hidden; }

/* --------------------------------------------------------------------------
   Recently Viewed (Hiljuti vaadatud) rail
   -------------------------------------------------------------------------- */
.ostu-rv-rail {
  grid-column: 1 / -1;
  margin-top: 48px;
  padding-top: 8px;
}
.ostu-rv-rail__head { margin-bottom: 18px; }
.ostu-rv-rail__title {
  font-size: clamp(22px, 3vw, 28px);
  margin: 0;
}
/* The [products] shortcode already emits ul.products → inherits grid + .product-card. */
.ostu-rv-rail ul.products { margin-top: 4px; }
