/* ==========================================================================
   CYO - CHOOSE YOUR PACKAGING
   The differentiating feature. Its job is to answer one question instantly:
   "what will my client actually receive?"

   Swatches, not a dropdown. A dropdown hides the gift's best feature.
   ========================================================================== */

.cyo {
  margin-top: var(--sp-4);
  border: 1px solid var(--gold);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, var(--gold-soft) 0%, var(--white) 62%);
  padding: var(--sp-4);
}

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

.cyo__title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: #6B5320;
  margin: 0;
}

.cyo__count { font-size: 0.8rem; color: #6B5320; opacity: .8; }

/* ---- Swatch rail ------------------------------------------------------ */

.swatches {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.swatch {
  flex: 0 0 auto;
  width: 88px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  text-align: center;
  scroll-snap-align: start;
}

.swatch__img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius-input);
  background: var(--cream-deep);
  border: 2px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 48, 31, .08);
  transition: border-color var(--dur-micro) var(--ease-brand),
              transform var(--dur-micro) var(--ease-brand);
}


/* The gold ring is the whole selection affordance - it must be unmissable */
.swatch[aria-pressed="true"] .swatch__img {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(200, 169, 106, .38);
}

.swatch__name {
  display: block;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--ink-mute);
  margin-top: var(--sp-2);
  /* one line only: a wrapping swatch label makes the rail jump */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch[aria-pressed="true"] .swatch__name { color: var(--tbs-green); font-weight: 700; }

.swatch__delta {
  display: block;
  font-size: 0.66rem;
  color: #6B5320;
  font-weight: 700;
}

/* ---- Live packaging panel ------------------------------------------- */

.cyo__panel {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px dashed rgba(200, 169, 106, .6);
}

.cyo__name {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--tbs-green);
  margin: 0 0 var(--sp-1);
}

.cyo__meta {
  font-size: 0.8rem;
  color: var(--ink-mute);
  margin: 0 0 var(--sp-2);
}

.cyo__desc {
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.55;
  margin: 0;
}

/* Text lines fade up on change - confirms the selection registered */
.cyo__panel.is-swapping .cyo__name,
.cyo__panel.is-swapping .cyo__meta,
.cyo__panel.is-swapping .cyo__desc { opacity: 0; transform: translateY(6px); }

.cyo__panel .cyo__name,
.cyo__panel .cyo__meta,
.cyo__panel .cyo__desc {
  transition: opacity var(--dur-component) var(--ease-brand),
              transform var(--dur-component) var(--ease-brand);
}

.cyo__panel .cyo__meta { transition-delay: 40ms; }
.cyo__panel .cyo__desc { transition-delay: 80ms; }

/* ---- View switcher (Front / Back / Packed / Open) ------------------- */

.views {
  display: flex;
  gap: var(--sp-1);
  background: var(--cream-deep);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: var(--sp-3);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.view-btn {
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 8px 14px;
  min-height: 36px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-brand),
              color var(--dur-micro) var(--ease-brand);
}


.view-btn[aria-pressed="true"] {
  background: var(--white);
  color: var(--tbs-green);
  box-shadow: 0 1px 3px rgba(0, 48, 31, .12);
}

/* ---- Flip stage ---------------------------------------------------- */
/* Front and back are two real faces of one object, so turning the box over is a
   genuine rotateY. Packed and Open are separate photographs, so they cross-fade
   instead - the motion should match the physical reality. */

.flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--dur-flip) var(--ease-brand);
}

.flip.is-flipped { transform: rotateY(180deg); }

.flip__face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity var(--dur-component) var(--ease-brand);
}

.flip__face--back { transform: rotateY(180deg); }

@media (prefers-reduced-motion: reduce) {
  .flip { transition: none; }
}

.stage__main--3d { perspective: 1400px; }


/* ---- Mobile ----------------------------------------------------------
   On a phone the customer had to scroll past the lede, the tax note and
   the CTA to reach the packaging chooser - the one decision this page
   exists to capture. Reordered so the choice sits directly under the
   price, and the marketing copy follows it.

   Everything defaults to order:10 so untouched children keep document
   order; only the blocks that belong above the fold are pulled forward.
   -------------------------------------------------------------------- */

@media (max-width: 767px) {
    .swatch {
        width: 76px;
    }

    .swatch__img {
        width: 72px;
        height: 72px;
    }

    .cyo {
        padding: var(--sp-3);
        margin-top: var(--sp-3);
    }

    .pdp-info {
        display: flex;
        flex-direction: column;
    }

        .pdp-info > * {
            order: 10;
        }

        .pdp-info > .pdp-info__eyebrow {
            order: 1;
        }

        .pdp-info > h1 {
            order: 2;
        }

        .pdp-info > .price-row {
            order: 3;
        }

        .pdp-info > .cyo {
            order: 4;
        }

        .pdp-info > .price-row + .price-note {
            order: 5;
        }

        .pdp-info > .pdp-info__lede {
            order: 6;
        }

    /* The packaging charge gets its own line, always. This is the rule that
     makes the desktop/mobile divergence impossible to reproduce again. */
    .price-row {
        flex-wrap: wrap;
    }

    .price-row__pack {
        flex: 1 0 100%;
        width: 100%;
        display: block;
    }

        .price-row__pack[hidden] {
            display: none;
        }

    /* Two paragraphs that say the same thing. One is enough on a phone. */
    .cyo > .cyo__meta {
        display: none;
    }

    .cyo__panel {
        margin-top: var(--sp-3);
        padding-top: var(--sp-3);
    }
}

/* ---- Sticky bar: what was chosen, not just what it costs -------------- */

.pdp-sticky__box {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink-mute);
    letter-spacing: .02em;
}

/* ---- Hover, gated ----------------------------------------------------- */
/* Ungated, a tapped swatch keeps the hover border after the finger lifts -
   so two swatches look chosen at once, which is precisely the confusion
   this feature exists to remove. */

@media (hover: hover) {
    .swatch:hover .swatch__img {
        border-color: rgba(200, 169, 106, .55);
    }

    .view-btn:hover {
        color: var(--tbs-green);
    }
}