/* =========================================================
   IDEA — prototype (from Figma page « B2 — 20 entre rangées »)
   Every value below is the Figma value in px on a 375 px wide
   screen, multiplied by --u so the layout scales to the phone.
   InDesign → Figma : ÷ 3 (35 pt → 11.67 px, 42 pt → 14 px).
   ========================================================= */

@font-face {
  font-family: "Unica 77";
  src: url("../fonts/Unica77LL-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.phone {
  container-type: size;
  overflow: hidden;
  background: #fff;
  color: #000;
  font-family: "Unica 77", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.phone > * {
  font-size: var(--size);
  line-height: var(--lead);
  --u: calc(min(100cqw, 430px) / 375);
  /* 1 design px. The design is 375 wide; capped at 430 px on desktop */


  /* tokens = Figma variables */
  --text-primary: #000;
  --text-secondary: #7f7f7f;   /* InDesign: 50 % tint of black */
  --surface-paper: #fff;
  --veil: rgba(0, 0, 0, .5);

  /* type = text style IDEA/Body */
  --size: calc(11.6667 * var(--u));  /* 35 pt / 3 */
  --lead: calc(14 * var(--u));       /* 42 pt / 3 */
  --cap:  calc(8.47 * var(--u));     /* Unica cap height 0.726 em */

  /* grid */
  --m: calc(10 * var(--u));          /* margin / gutter */
  --col: calc(172.5 * var(--u));     /* column */
  --w: calc(375 * var(--u));         /* screen */

  /* recurring vertical values */
  --cap-top: calc(10.28 * var(--u)); /* 10 + ascent 8.75 − cap 8.47 : top of the caps */
  --next-line: calc(5.53 * var(--u));/* 14 − cap : baseline → caps of next line */
  --row-gap: calc(20 * var(--u));    /* last baseline → next image (2 × 10) */

  /* motion : one curve for every eased movement (pages, digits, feedback) */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --page-motion: 1300ms;             /* every page change : catalog → choice → product → catalog */
  --feedback-in: 250ms;              /* label + colour of the price : in */
  --feedback-out: 600ms;             /* label + colour of the price : out, together */
  --price-down: #743ea7;             /* violet while the price goes down */
  --price-up: #00ad0b;               /* green while the price goes up */
}

.phone * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #fff; }

body {
  width: 100%;
  margin: 0;
  background: #fff;
  color: #000;
  font-family: "Unica 77", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; text-align: left; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- text = Figma « leading trim : cap height »
   the box goes from the top of the capitals to the last baseline,
   so every spacing is measured exactly like in Figma            */
.t {
  display: block;
  font-size: var(--size);
  line-height: var(--lead);
  text-box: trim-both cap alphabetic;
}
@supports not (text-box: trim-both cap alphabetic) {
  /* fallback for older browsers (Unica hhea metrics) */
  .t { margin-top: calc(-3.03 * var(--u)); margin-bottom: calc(-2.5 * var(--u)); }
}
.muted { color: var(--text-secondary); }

/* The catalog scrolls inside the phone frame. */
.catalog { height: 100%; overflow-y: auto; overscroll-behavior-y: contain; }

/* ---------- header (catalog : 56.75 high, fixed) */
.header {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  background: var(--surface-paper);
  z-index: 10;
}
.header--catalog { height: calc(56.75 * var(--u)); }
.header--product { height: calc(70.75 * var(--u)); }

.topbar {
  position: absolute;
  top: var(--cap-top);                       /* baseline 18.75 */
  left: var(--m);
  right: var(--m);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.nav {
  position: absolute;
  top: calc(38.28 * var(--u));               /* baseline 46.75 */
  left: var(--m);
  display: flex;
  gap: var(--size);                          /* 1 em space, like InDesign */
}

/* ---------- grid */
.grid {
  padding: calc(56.75 * var(--u)) var(--m) 0;
  display: grid;
  grid-template-columns: var(--col) var(--col);
  column-gap: var(--m);
  row-gap: 0;
  align-items: start;
}
.card { display: block; width: var(--col); border: 0; background: transparent; color: inherit; font: inherit; text-align: left; appearance: none; }
.card:disabled { opacity: 1; cursor: default; }
.card:focus-visible { outline: 2px solid #000; outline-offset: 2px; }
.card__cover {
  width: var(--col);
  height: calc(259 * var(--u));
  object-fit: cover;
}
.card__info {
  padding-top: var(--cap-top);               /* image → caps of the title : 10.28 */
  padding-bottom: var(--row-gap);            /* last baseline → next image : 20 */
}
.card__info .price { margin-top: var(--next-line); }
.card[data-link] { cursor: pointer; }

/* ---------- footer (10 + ascent / 14 / 10) */
.footer {
  padding: var(--cap-top) var(--m) var(--m);
  text-align: center;
}

/* ---------- first load : wait for all image assets */
.asset-loader {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(10 * var(--u));
  padding: var(--m);
  background: var(--surface-paper);
  text-align: center;
}
.asset-loader progress {
  width: min(100%, calc(200 * var(--u)));
  accent-color: var(--color-ink);
}
.asset-loader button {
  border: 0;
  background: none;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- 2 — choice */
.choice {
  position: absolute;
  inset: 0;
  background: var(--surface-paper);
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  will-change: transform;
  backface-visibility: hidden;
}
.choice.is-page-entering { transform: translateY(100%); }
.choice__header {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  height: calc(56.75 * var(--u));
}
.choice__title {
  position: absolute;
  top: calc(38.28 * var(--u));
  left: var(--m);
  font-weight: 400;
}
/* block = cover 259 + 10.28 + 8.47 + 5.53 + 8.47 + 10 under the last baseline = 301.75,
   centred on the screen axis (Figma « 2 — Choice / V1 » : 406 on 812), whatever the phone height */
.choice__grid {
  position: absolute;
  top: 50%;
  left: var(--m);
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: var(--col) var(--col);
  column-gap: var(--m);
  align-items: start;
}
.choice__card {
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}
.choice__card img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}
.choice__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: var(--cap-top);               /* image → caps : 10.28 */
  padding-bottom: var(--m);                  /* 10 under the last baseline */
}
.choice__info .price { margin-top: var(--next-line); }

/* ---------- 3 — product */
.product {
  position: absolute;
  inset: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  background: var(--surface-paper);
  z-index: 30;
  overflow: hidden;
  will-change: transform;
  backface-visibility: hidden;
}
.product.is-returning {                     /* last page change : same speed and curve as the first two (--page-motion, --ease) */
  transform: translate(-50%, -100%);
  transition-duration: var(--page-motion);
  transition-timing-function: var(--ease);
}
.product.is-page-entering {
  transform: translate(-50%, 100%);
}
@media (prefers-reduced-motion: no-preference) {
  .choice, .product { transition: transform var(--page-motion) var(--ease); }
}
.header--product { position: absolute; transform: none; left: 0; }
.product__title {
  position: absolute;
  top: calc(38.28 * var(--u));               /* baseline 46.75 */
  left: var(--m);
  font-weight: 400;
}
.product__delta {                           /* « Imperfection found » / « Rare detail found » (Figma « …qualité_liuui ») */
  position: absolute;
  bottom: calc(var(--m) + 36.59 * var(--u)); /* baseline 765 on 812, as in Figma */
  left: var(--m);
  z-index: 2;
  margin: 0;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(calc(4 * var(--u)));
  pointer-events: none;
}
.product__delta.is-visible { opacity: 1; transform: translateY(0); }
.product__delta.is-exiting { opacity: 0; transform: translateY(0); }
/* the large price is violet while it goes down, green while it goes up ;
   when the digits stop, the colour and the label leave together */
.product__amount.is-price-down { color: var(--price-down); }
.product__amount.is-price-up   { color: var(--price-up); }
@media (prefers-reduced-motion: no-preference) {
  .product__delta { transition: opacity var(--feedback-out) var(--ease), transform var(--feedback-out) var(--ease); }
  .product__delta.is-visible { transition-duration: var(--feedback-in); }
  .product__amount { transition: color var(--feedback-out) var(--ease); }
  .product__amount.is-price-up, .product__amount.is-price-down { transition-duration: var(--feedback-in); }
}
.product__price {
  position: absolute;
  top: calc(52.28 * var(--u));               /* baseline 60.75 */
  left: var(--m);
}

/* slideshow : one screen per image, image 355 wide on the margins,
   centred on the screen axis (406 / 812) → 20 between two images */
.slider {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.slider::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 var(--w);
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  padding: 0 var(--m);
}
.slide img {
  width: calc(355 * var(--u));
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.slide img {
  -webkit-touch-callout: none;               /* no iOS « save image » menu on long press */
  touch-action: pan-x;
}

/* finger loupe : 200 Ø, magnification ×4, above the finger */
.loupe {
  position: absolute;
  width: calc(200 * var(--u));
  height: calc(200 * var(--u));
  border-radius: 50%;
  background-color: var(--surface-paper);
  background-repeat: no-repeat;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
}
.slider.is-zooming { overflow-x: hidden; }

/* defects found : 50 Ø, 5 apart, right margin, under Cart (0) (Figma : x 315, y 56.75) */
/* the column goes down the whole page, as long as there is room
   (stops 10 above the caps of the large price, the bottom block) — rows computed in app.js.
   No more room → new column on the left, 5 apart, starting again at the top */
.found {
  position: absolute;
  top: calc(56.75 * var(--u));
  right: var(--m);
  display: grid;
  grid-template-rows: repeat(var(--rows, 13), calc(50 * var(--u)));
  grid-auto-flow: column;
  grid-auto-columns: calc(50 * var(--u));
  direction: rtl;
  gap: calc(5 * var(--u));
  z-index: 15;
  pointer-events: none;
}
.found span {
  display: block;
  overflow: hidden;
  width: calc(50 * var(--u));
  height: calc(50 * var(--u));
  border-radius: 50%;
  background-color: var(--surface-paper);
  background-repeat: no-repeat;
  opacity: 1;
}
@media (prefers-reduced-motion: no-preference) {
  .found span { transition: opacity 150ms ease; }
}

/* the canvas picture inside the flying loupe and the 50 px circles */
.pic { display: block; width: 100%; height: 100%; border-radius: 50%; }

/* debug : add ?zones to the URL to see the defect zones */
.zone {
  position: absolute;
  border: 0.5px solid rgb(255, 0, 242);
  border-radius: 50%;
  pointer-events: none;
}

/* bottom line : baseline 10 from the bottom */
.product__amount,
.product__add,
.product__counter {
  position: absolute;
  bottom: var(--m);
  z-index: 2;
}
/* price : 105 pt / auto 126 pt → 35 / 42, same baseline as the counter */
.product__amount {
  left: var(--m);
  bottom: var(--m);
  font-size: calc(35 * var(--u));
  line-height: calc(42 * var(--u));
}
@supports not (text-box: trim-both cap alphabetic) {
  .product__amount { margin-top: calc(-9.08 * var(--u)); margin-bottom: calc(-7.51 * var(--u)); }
  .product__add { margin-bottom: calc(-7.51 * var(--u)); }
}

/* rolling digits (like Revolut) : each digit is a window one line high,
   a vertical strip of digits slides behind it. The typography doesn't change. */
.roll {
  display: inline-block;
  position: relative;
  height: calc(42 * var(--u));               /* one line */
  clip-path: inset(0);                       /* clip without changing the baseline */
  vertical-align: baseline;
  transition: width .5s var(--ease);
  overflow: visible;
}
.roll__ghost { visibility: hidden; }          /* gives the line its baseline */
.roll__strip {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.roll__strip span { display: block; height: calc(42 * var(--u)); }
.roll__strip span:nth-child(10n + 11) { position: relative; top: calc(1 * var(--u)); }
.roll__strip.is-moving { transition: transform .5s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .roll, .roll__strip.is-moving, .product { transition: none; }
}
.product__add {
  right: var(--m);                           /* same baseline as the large price (Figma : 802) */
  display: block;
  padding: 0;
  white-space: nowrap;
}
.product__add::before {                      /* invisible 44 px tap area, the text stays on the baseline */
  content: '';
  position: absolute;
  right: calc(-1 * var(--m));
  bottom: calc(-1 * var(--m));
  width: max(100% + 2 * var(--m), 44px);
  height: 44px;
}
.product__counter {
  right: var(--m);
  text-align: right;
  bottom: auto;
  z-index: 16;
}


/* ---------- 4 — checkout : fixed circle, details sweep through its window */
.recap { display: none; }
.product.is-recap .found,
.product.is-recap .product__amount,
.product.is-recap .product__delta,
.product.is-recap .product__add,
.product.is-recap .product__counter { display: none; }
.product.is-recap .recap {
  display: block;
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  z-index: 8;                                 /* keep the product header above the circle */
  will-change: transform;
}
.recap__track {
  position: absolute;
  inset: 0;
  width: var(--w);
  height: 100cqh;
}
.recap__circles {
  position: absolute;
  inset: 0;
  transition: opacity 180ms ease;
}
/* The circle is a fixed mask; its image layers slide vertically through it. */
.recap__circle {
  position: absolute;
  top: calc(50cqh - 177.5 * var(--u));
  left: var(--m);
  width: calc(355 * var(--u));
  height: calc(355 * var(--u));
  margin: 0;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--surface-paper);
}
.recap__detail {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  will-change: transform;
}
/* confirmation block : « Added to cart », left margin, centred on the screen axis */
.recap__end {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  width: var(--w);
  position: absolute;
  inset: 0;
  height: 100cqh;
  margin: 0;
  padding: 0 var(--m);
  background: var(--surface-paper);
  clip-path: inset(100% 0 0);
  transition: none;
}
.product.is-confirmed .recap__end { clip-path: inset(0); }
#end-label {                                /* « Added to cart » : half of IDEA/Price (35 / 42 ÷ 2) */
  font-size: calc(17.5 * var(--u));
  line-height: calc(21 * var(--u));
}
@supports not (text-box: trim-both cap alphabetic) {
  #end-label { margin-top: calc(-4.54 * var(--u)); margin-bottom: calc(-3.755 * var(--u)); }
}
@media (prefers-reduced-motion: reduce) {
  .product.is-returning { transition: none; }
  .recap__end { transition: none; }
}

.phone .view[hidden] { display: none !important; }
.recap__end { color: inherit; }
.product__add { appearance: none; border: 0; background: none; color: inherit; font: inherit; text-align: right; cursor: pointer; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
