/*
 * The hero phone — a faithful rebuild of the design's "Ad Phone" component.
 *
 * The design authors it at 236×454 and drops it into a 472×828 well at
 * scale(2), so every value below is in the 236-wide coordinate space and the
 * whole thing is scaled once at the end. Editing in design units is what keeps
 * it comparable to the source file.
 *
 * Four phases on a loop, matching the design's own sequence and timings
 * (2000 / 260 / 2200 / 5200 ms):
 *   0  live camera
 *   1  shutter flash
 *   2  recognising — scan line sweeps, ingredient chips appear
 *   3  nutrition sheet slides up, ingredient list scrolls
 */

.phone-well {
  width: 472px;
  height: 828px;
  flex: none;
  overflow: hidden;
  position: relative;
  max-width: 100%;
}
.phone-scale {
  position: absolute;
  left: 0;
  top: 0;
  width: 236px;
  height: 454px;
  transform: scale(2);
  transform-origin: top left;
}

.ad {
  width: 236px;
  height: 454px;
  border-radius: 38px;
  background: #111113;
  padding: 8px;
  box-sizing: border-box;
  position: relative;
  font-family: 'MarkGEO', system-ui, sans-serif;
}
.ad-notch {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 20px;
  border-radius: 10px;
  background: #000;
  z-index: 8;
}
.ad-screen {
  height: 100%;
  border-radius: 31px;
  overflow: hidden;
  background: #1c1c1e;
  position: relative;
}

/* ── phase 0: live camera ─────────────────────────────────────────────── */

.ad-cam,
.ad-camdish,
.ad-vignette,
.ad-chrome {
  opacity: 1;
  transition: opacity 0.4s ease;
}
.ad[data-phase='1'] .ad-cam,
.ad[data-phase='2'] .ad-cam,
.ad[data-phase='3'] .ad-cam,
.ad[data-phase='1'] .ad-camdish,
.ad[data-phase='2'] .ad-camdish,
.ad[data-phase='3'] .ad-camdish,
.ad[data-phase='1'] .ad-vignette,
.ad[data-phase='2'] .ad-vignette,
.ad[data-phase='3'] .ad-vignette,
.ad[data-phase='1'] .ad-chrome,
.ad[data-phase='2'] .ad-chrome,
.ad[data-phase='3'] .ad-chrome {
  opacity: 0;
}

.ad-cam {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #c9bda9 0%, #9b8f7e 46%, #6e6357 100%);
}
.ad-camdish {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: 168px;
  height: 168px;
  border-radius: 84px;
  object-fit: cover;
}
.ad-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    rgba(0, 0, 0, 0.3),
    rgba(0, 0, 0, 0) 26%,
    rgba(0, 0, 0, 0) 62%,
    rgba(0, 0, 0, 0.34)
  );
  pointer-events: none;
}
.ad-chrome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.ad-toprow {
  position: relative;
  padding: 44px 16px 0;
  display: flex;
  justify-content: space-between;
}
.ad-pill {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
}
.ad-pill svg {
  width: 15px;
  height: 15px;
  fill: #fff;
}
.ad-bottom {
  position: relative;
  padding: 0 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ad-modes {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 5px;
}
.ad-mode-on {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border-radius: 14px;
  padding: 6px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-size: 11px;
  color: #1c1c1e;
}
.ad-mode-on svg {
  width: 13px;
  height: 13px;
  fill: #4caf50;
}
.ad-mode-off {
  flex: 1;
  display: flex;
  justify-content: center;
}
.ad-mode-off svg {
  width: 14px;
  height: 14px;
  fill: rgba(60, 60, 67, 0.6);
}
.ad-shutter {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45);
  transform: scale(1);
  transition: transform 0.18s ease;
}
.ad[data-phase='1'] .ad-shutter {
  transform: scale(0.86);
}

/* framing brackets */
.ad-frame {
  position: absolute;
  left: 34px;
  right: 34px;
  top: 30%;
  height: 150px;
  pointer-events: none;
  transform: scale(1);
  transition: transform 0.22s ease;
}
.ad[data-phase='1'] .ad-frame {
  transform: scale(0.94);
}
.ad-frame i {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(255, 255, 255, 0.85);
  border-style: solid;
  border-width: 0;
}
.ad-frame .tl {
  left: 0;
  top: 0;
  border-left-width: 3px;
  border-top-width: 3px;
  border-radius: 8px 0 0 0;
}
.ad-frame .tr {
  right: 0;
  top: 0;
  border-right-width: 3px;
  border-top-width: 3px;
  border-radius: 0 8px 0 0;
}
.ad-frame .bl {
  left: 0;
  bottom: 0;
  border-left-width: 3px;
  border-bottom-width: 3px;
  border-radius: 0 0 0 8px;
}
.ad-frame .br {
  right: 0;
  bottom: 0;
  border-right-width: 3px;
  border-bottom-width: 3px;
  border-radius: 0 0 8px 0;
}

/* ── phase 1+: the captured shot ──────────────────────────────────────── */

.ad-shot,
.ad-shotgrad,
.ad-shotbar {
  opacity: 0;
  transition: opacity 0.45s ease;
}
.ad[data-phase='1'] .ad-shot,
.ad[data-phase='2'] .ad-shot,
.ad[data-phase='3'] .ad-shot,
.ad[data-phase='1'] .ad-shotgrad,
.ad[data-phase='2'] .ad-shotgrad,
.ad[data-phase='3'] .ad-shotgrad,
.ad[data-phase='1'] .ad-shotbar,
.ad[data-phase='2'] .ad-shotbar,
.ad[data-phase='3'] .ad-shotbar {
  opacity: 1;
}
.ad-shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ad-shotgrad {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 120px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.ad-shotbar {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ad-round {
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-round svg {
  width: 12px;
  height: 12px;
  fill: #1c1c1e;
}
.ad-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}
.ad[data-phase='1'] .ad-flash {
  opacity: 1;
}

/* ── phase 2: recognising ─────────────────────────────────────────────── */

.ad-scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: linear-gradient(
    rgba(76, 175, 80, 0) 0%,
    rgba(76, 175, 80, 0.95) 60%,
    rgba(255, 255, 255, 0.9) 100%
  );
  box-shadow: 0 0 18px rgba(76, 175, 80, 0.9);
  opacity: 0;
  transform: translateY(0);
  transition: transform 0s, opacity 0.3s ease;
  pointer-events: none;
}
.ad[data-phase='2'] .ad-scanline {
  opacity: 1;
  transform: translateY(438px);
  transition: transform 2s linear, opacity 0.3s ease;
}
.ad-scanchip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 76px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 12px;
  padding: 5px 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-size: 8.5px;
  color: #fff;
}
.ad-scanchip svg {
  width: 11px;
  height: 11px;
  fill: #8be78f;
}
.ad[data-phase='2'] .ad-scanchip {
  opacity: 1;
}
.ad-chip {
  position: absolute;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 8px;
  color: #1c1c1e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.ad[data-phase='2'] .ad-chip,
.ad[data-phase='3'] .ad-chip {
  opacity: 1;
}
.ad-chip.c1 {
  left: 22px;
  top: 30%;
}
.ad-chip.c2 {
  right: 20px;
  top: 40%;
}
.ad-chip.c3 {
  left: 64px;
  top: 56%;
}

/* ── phase 3: nutrition sheet ─────────────────────────────────────────── */

.ad-sheet > * {
  flex: none;
}
.ad-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 77%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(360px);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.ad[data-phase='3'] .ad-sheet {
  transform: translateY(0);
}
.ad-grab {
  padding: 8px 0 4px;
  display: flex;
  justify-content: center;
}
.ad-grab i {
  width: 34px;
  height: 3px;
  border-radius: 2px;
  background: rgba(60, 60, 67, 0.22);
}
.ad-meta {
  padding: 2px 12px 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ad-meta svg {
  width: 13px;
  height: 13px;
  fill: #1c1c1e;
}
.ad-time {
  line-height: 1.2;
  background: #f2f2f7;
  border-radius: 9px;
  padding: 3px 8px;
  font-size: 8px;
  color: rgba(60, 60, 67, 0.7);
}
.ad-title {
  padding: 6px 12px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ad-title b {
  flex: 1;
  font-family: 'MarkGEOCAPS', sans-serif;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.2;
  color: #000;
  text-wrap: pretty;
}
.ad-portion {
  line-height: 1.2;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #ececf0;
  border-radius: 9px;
  padding: 5px 9px;
  font-size: 10px;
  color: #000;
}
.ad-portion svg {
  width: 9px;
  height: 9px;
  fill: #000;
}
.ad-nums {
  padding: 8px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ad-kcal {
  background: #fff;
  border: 1px solid #ececf0;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.ad-kcal svg {
  width: 16px;
  height: 16px;
  fill: #1c1c1e;
}
.ad-kcal .lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ad-kcal .lbl {
  line-height: 1.2;
  font-size: 8px;
  color: rgba(60, 60, 67, 0.6);
}
.ad-kcal .val {
  font-family: 'MarkGEOCAPS', sans-serif;
  font-size: 20px;
  line-height: 1;
  color: #000;
}
.ad-macros {
  display: flex;
  gap: 6px;
}
.ad-macro {
  flex: 1;
  background: #fff;
  border: 1px solid #ececf0;
  border-radius: 10px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ad-macro .top {
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 7.5px;
  color: rgba(60, 60, 67, 0.6);
}
.ad-macro .top svg {
  width: 10px;
  height: 10px;
}
.ad-macro .g {
  line-height: 1.2;
  font-size: 11px;
  font-weight: 600;
  color: #000;
}
.ad-dots {
  padding: 8px 0 6px;
  display: flex;
  justify-content: center;
  gap: 5px;
}
.ad-dots i {
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: rgba(60, 60, 67, 0.25);
}
.ad-dots i:first-child {
  background: #1c1c1e;
}
.ad-ingr-head {
  padding: 0 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ad-ingr-head {
  line-height: 1.2;
}
.ad-ingr-head b {
  font-family: 'MarkGEOCAPS', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: #000;
}
.ad-ingr-head span {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 8.5px;
  color: rgba(60, 60, 67, 0.6);
}
.ad-ingr-head svg {
  width: 10px;
  height: 10px;
  fill: rgba(60, 60, 67, 0.6);
}
.ad-ingr-clip {
  /* basis 0 so it takes the LEFTOVER of the sheet, shrinkable, with a floor.
     `1 0 auto` was wrong: auto basis meant the window grew to fit all eight
     rows (239px), pushing the sheet to 493px inside its 337px frame, so
     overflow:hidden cut off the list and the buttons below it. */
  flex: 1 1 0;
  min-height: 94px;
  overflow: hidden;
  padding: 0 12px;
}
.ad-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  transform: translateY(0);
  transition: transform 0s;
}
.ad[data-phase='3'] .ad-list {
  transform: translateY(-92px);
  transition: transform 3.6s linear 1.6s;
}
.ad-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #f2f2f7;
  border-radius: 9px;
  padding: 7px 9px;
}
.ad-item {
  line-height: 1.2;
}
.ad-item .nm {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 9px;
  color: #000;
  white-space: nowrap;
}
.ad-item .nm b {
  font-family: 'MarkGEOCAPS', sans-serif;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ad-item .nm i {
  flex: none;
  font-style: normal;
  color: rgba(60, 60, 67, 0.5);
}
.ad-item .qty {
  font-size: 8.5px;
  color: rgba(60, 60, 67, 0.5);
  flex: none;
}
.ad-cta {
  padding: 8px 12px 12px;
  display: flex;
  gap: 7px;
  background: linear-gradient(rgba(255, 255, 255, 0) 0%, #fff 40%);
}
.ad-cta .ghost,
.ad-cta .solid {
  line-height: 1.2;
}
.ad-cta .ghost {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #e2e2e7;
  border-radius: 999px;
  padding: 9px 0;
  font-size: 9.5px;
  color: #000;
}
.ad-cta .ghost svg {
  width: 11px;
  height: 11px;
  fill: #000;
}
.ad-cta .solid {
  flex: 1;
  text-align: center;
  background: #1c1c1e;
  border-radius: 999px;
  padding: 9px 0;
  font-family: 'MarkGEOCAPS', sans-serif;
  font-size: 9.5px;
  color: #fff;
}

/* Smaller viewports: scale the whole well down rather than reflow the phone,
   which is authored at a fixed size. */
@media (max-width: 1100px) {
  .phone-well {
    width: 378px;
    height: 662px;
  }
  .phone-scale {
    transform: scale(1.6);
  }
}
@media (max-width: 760px) {
  .phone-well {
    width: 283px;
    height: 500px;
    margin: 0 auto;
  }
  .phone-scale {
    transform: scale(1.2);
  }
}

/* Someone who has asked for less motion gets the finished result, not a loop. */
@media (prefers-reduced-motion: reduce) {
  .ad *,
  .ad {
    transition: none !important;
  }
}
