/* ==========================================================================
   PRODUCT DETAIL — pop-out view and the Recommended for You panel.
   Same hairline system as everything else: black ground, porcelain type,
   1px rules, nothing rounded.
   ========================================================================== */

:root { --z-detail: 320; }

.detail {
  position: fixed;
  inset: 0;
  z-index: var(--z-detail);
  display: grid;
  place-items: center;
  padding: clamp(var(--sp-3), 3vw, var(--sp-6));
}

.detail__panel {
  position: relative;
  width: min(1040px, 100%);
  /* dvh follows the browser chrome as it hides and shows on a phone; vh does
     not, and overshoots on iOS. */
  max-height: calc(100vh - clamp(1.5rem, 6vw, 4rem));
  max-height: calc(100dvh - clamp(1.5rem, 6vw, 4rem));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: var(--rule-strong);
  opacity: 0;
  transform: translateY(12px) scale(0.99);
  transition: opacity var(--dur-base) var(--ease),
              transform var(--dur-base) var(--ease);
}

.detail.is-open .detail__panel { opacity: 1; transform: translateY(0) scale(1); }

@media (prefers-reduced-motion: reduce) {
  .detail__panel { transition: opacity var(--dur-fast) linear; transform: none; }
}

.detail__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6);
  border-bottom: var(--rule);
  flex: none;
}

.detail__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

/* flex: 1 and min-height: 0 are what make this scroll.
   Without them the body sizes to its content and overflows the panel instead
   of scrolling inside it — invisible on a tall screen, where the panel's
   max-height never binds, but on a phone in landscape the panel is capped at
   ~360px and the product detail simply could not be scrolled. A flex child
   will not shrink below its content unless min-height: 0 says it may. */
.detail__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* --- Product ---------------------------------------------------------------- */
.detail__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 760px) {
  .detail__grid { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr); }
}

.detail__media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-bottom: var(--rule);
}

@media (min-width: 760px) {
  .detail__media { border-bottom: 0; border-right: var(--rule); }
}

.detail__image { width: 100%; height: 100%; object-fit: cover; }

.detail__media .card__stock {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
}

/* The card's corner flag, carried through to the pop-out. */
.detail__media .card__badge {
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
}

/* --- More photos ------------------------------------------------------------
   Only rendered when a product actually has more than one. Sits over the foot
   of the image so it costs no layout, and scrolls sideways rather than
   shrinking the thumbnails to nothing. */
.shots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
}

.shots::-webkit-scrollbar { display: none; }

.shots__btn {
  display: block;
  width: 52px;
  height: 52px;
  padding: 0;
  border: var(--rule-width) solid var(--c-porcelain-30);
  opacity: 0.7;
  transition: opacity var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}

.shots__btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

.shots__btn:hover { opacity: 1; }

.shots__btn[aria-pressed="true"] {
  opacity: 1;
  border-color: var(--c-porcelain);
}

.detail__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: clamp(var(--sp-5), 3vw, var(--sp-7));
}

.detail__category {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.detail__title {
  font-size: var(--fs-h2);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: var(--tr-display);
  line-height: 1;
  outline: none;
}

.detail__price {
  font-family: var(--font-mono);
  font-size: var(--fs-lead);
  font-variant-numeric: tabular-nums;
  margin-top: var(--sp-2);
}

.detail__description {
  margin-top: var(--sp-3);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 46ch;
  text-wrap: pretty;
}

.detail__add { margin-top: var(--sp-5); }

.detail__close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: var(--rule);
  color: var(--text-muted);
  flex: none;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}

.detail__close:hover { color: var(--text); border-color: var(--rule-color-strong); }
.detail__close svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5; }

/* --------------------------------------------------------------------------
   Recommended for You
   -------------------------------------------------------------------------- */
.recs {
  padding: clamp(var(--sp-5), 3vw, var(--sp-7));
  border-top: var(--rule);
}

.recs__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.recs__title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--tr-tight);
}

.recs__badge {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

/* --- Loading ----------------------------------------------------------------
   The icon is a roast dial sweeping: the same mark as the product artwork. */
.recs__loading {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-6) 0;
  border-top: var(--rule);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.recs__spinner {
  position: relative;
  width: 18px;
  height: 18px;
  flex: none;
  border: var(--rule-width) solid var(--rule-color-strong);
  border-radius: 50%;
}

/* The needle. */
.recs__spinner::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--rule-width);
  height: 7px;
  background: var(--c-porcelain);
  transform-origin: top center;
  transform: translate(-50%, 0);
  animation: recs-sweep 1.1s linear infinite;
}

@keyframes recs-sweep {
  from { transform: translate(-50%, 0) rotate(0deg); }
  to   { transform: translate(-50%, 0) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .recs__spinner::after { animation-duration: 3s; }
}

.recs__empty {
  padding: var(--sp-6) 0;
  border-top: var(--rule);
  color: var(--text-muted);
}

/* --- Recommendation cards ------------------------------------------------- */
[data-recs] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 620px) {
  [data-recs]:not(:has(.recs__loading)):not(:has(.recs__empty)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.rec {
  display: flex;
  flex-direction: column;
  border-top: var(--rule);
  border-left: var(--rule);
  margin: 0 calc(var(--rule-width) * -1) 0 0;
  background: var(--bg);
  transition: background var(--dur-base) var(--ease);
}

.rec:first-child { border-left: 0; }

@media (max-width: 619px) {
  .rec { border-left: 0; }
}

.rec:hover { background: var(--bg-raised); }

.rec__open {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-5);
  text-align: left;
  width: 100%;
}

.rec__image {
  width: 72px;
  height: 90px;
  object-fit: cover;
  border: var(--rule);
  flex: none;
  opacity: 0.9;
  transition: opacity var(--dur-base) var(--ease);
}

.rec:hover .rec__image { opacity: 1; }

.rec__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.rec__category {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.rec__title {
  font-size: 1rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--tr-tight);
  line-height: 1.15;
}

/* The sentence Claude wrote — the reason this pairing exists. */
.rec__reason {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-wrap: pretty;
}

.rec__price {
  margin-top: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
}

.rec__add {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-5);
  border-top: var(--rule);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}

.rec__add:hover { background: var(--c-porcelain); color: var(--c-black); }
