/* ============================================================
   Live tiles for the mimmu case (assets/js/mimmu-live.js)
   ============================================================
   Every tile is a .cp-media box whose size the case grid decides. Inside it,
   `.ml` is a container; 1em is 1/40 of the tile width, so a tile designed at
   600px reads 15px and scales with the column instead of with the viewport.
   Colours are the app's own tokens (mimmu_design_system.md) and nothing else:
   the tiles must look like the product, not like the portfolio.
   ------------------------------------------------------------ */

.cp-media--live {
  position: relative;
  container-type: size;
  background: #FFF6F4;
  overflow: hidden;
}

/* the generic .cp-media img rules stretch every <img> over the box; live
   tiles lay their own images out */
.cp-media--live img,
.cp-section-media-row .cp-media--live img,
.cp-overview-bottom--stacked .cp-media--live img {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  object-fit: initial;
  display: block;
}

.ml {
  --bg: #FFF6F4;
  --surface: #FFFFFF;
  --ink: #1E1E25;
  --ink-2: #4A4A55;
  --ink-3: #707079;
  --line: #F0E6E2;
  --blush: #FE759E;
  --blush-soft: #FFE4EC;
  --blush-deep: #E84F7E;
  --lime: #C3FF8E;
  --lime-deep: #9CE65A;
  --coral: #FFB5B0;
  --error: #C93E3E;
  --shadow-card: 0 0.26em 1.3em -0.13em rgba(254, 117, 158, 0.08), 0 0.13em 0.4em -0.06em rgba(30, 30, 37, 0.04);
  --shadow-elev: 0 0.5em 2.1em -0.26em rgba(254, 117, 158, 0.16), 0 0.26em 0.8em -0.13em rgba(30, 30, 37, 0.06);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  position: absolute;
  inset: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: calc(100cqw / 40);
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.ml *,
.ml *::before,
.ml *::after { box-sizing: border-box; }

.ml svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
/* the chart is the one SVG that is a drawing, not an icon */
.ml svg.ml-chart-svg { width: 100%; height: auto; stroke: none; fill: none; }

:where(.ml) button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ml h3, .ml h4 { margin: 0; font-weight: 500; }
.ml p { margin: 0; }

/* ---- shared atoms ---- */
.ml-ib {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5em;
  height: 2.5em;
  border-radius: 999px;
  color: var(--ink);
  font-size: 1em;
}
.ml-ib svg { width: 1.2em; height: 1.2em; }
.ml-ib--soft { background: var(--bg); color: var(--ink-2); }

.ml-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 2.3em;
  padding: 0 1em;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.86em;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
  transition: background 0.22s var(--ease-out), color 0.22s var(--ease-out), transform 0.22s var(--ease-spring);
}
.ml-chip:active { transform: scale(0.96); }
.ml-chip.is-on { background: var(--ink); color: var(--surface); }

.ml-price { display: inline-flex; align-items: baseline; gap: 0.1em; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ml-price i { font-style: normal; font-weight: 400; font-size: 0.72em; }
.ml-price b { font-weight: 500; font-size: 1.05em; letter-spacing: -0.01em; }
.ml-price--sm b { font-size: 1.15em; }
.ml-price--lg i { font-size: 1.2em; }
.ml-price--lg b { font-size: 2.2em; font-weight: 600; letter-spacing: -0.02em; }

.ml-deal {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  height: 2.1em;
  padding: 0 0.9em;
  border-radius: 1.2em;
  background: linear-gradient(180deg, #C3FF8E 0%, rgba(195, 255, 142, 0.55) 100%);
  box-shadow: 0 0.13em 0.65em rgba(195, 255, 142, 0.3);
  color: var(--ink);
  font-size: 0.82em;
  font-weight: 500;
  white-space: nowrap;
}
.ml-deal svg { width: 1em; height: 1em; }

.ml-card {
  background: var(--surface);
  border-radius: 1.5em;
  box-shadow: var(--shadow-card);
}

.ml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  width: 100%;
  height: 3.2em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 500;
  font-size: 0.95em;
  transition: transform 0.22s var(--ease-spring), background 0.22s;
}
.ml-btn:hover { background: #2a2730; }
.ml-btn:active { transform: scale(0.97); }
.ml-btn svg { width: 1.2em; height: 1.2em; }

.ml-link { color: var(--ink-2); font-size: 0.85em; font-weight: 500; text-decoration: underline; text-underline-offset: 0.2em; }

.ml-sub { color: var(--ink-3); font-size: 0.86em; line-height: 1.4; }
.ml-label { display: block; color: var(--ink-3); font-size: 0.7em; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }

/* ============================================================
   1. Phone — the real home, framed
   ============================================================
   The screen holds a same-origin iframe of the static home copy at its
   native 390px, scaled down by mimmu-live.js to the screen's width. */
.ml-phone { display: flex; justify-content: center; align-items: flex-end; }

.ml-device {
  position: relative;
  width: 21.5em;
  height: calc(100% - 2.2em);
  margin-top: 2.2em;
  padding: 0.55em 0.55em 0;
  border-radius: 3.4em 3.4em 0 0;
  background: #17161a;
  box-shadow: 0 2em 4em -1.5em rgba(30, 30, 37, 0.45), inset 0 0 0 0.12em #3a393f;
}
.ml-device::before {
  content: '';
  position: absolute;
  top: 1.05em;
  left: 50%;
  width: 5.6em;
  height: 1.5em;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #0b0b0d;
  z-index: 3;
}

.ml-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 2.9em 2.9em 0 0;
  background: var(--bg);
}

.ml-home {
  position: absolute;
  top: 0;
  left: 0;
  width: 390px;
  height: 100%;
  border: 0;
  transform-origin: 0 0;
  background: var(--bg);
}

.ml-status { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 0.9em 1.6em 0; font-size: 0.78em; font-weight: 600; pointer-events: none; }
.ml-status-r { display: inline-flex; gap: 0.25em; }
.ml-status-r i { width: 0.5em; height: 0.5em; border-radius: 50%; background: var(--ink); }

/* ============================================================
   2. Price alert
   ============================================================ */
.ml-alert { font-size: calc(100cqw / 27); display: flex; flex-direction: column; justify-content: center; padding: 1.6em 1.4em; background: radial-gradient(120% 90% at 100% 0%, #FFE4EC 0%, #FFF6F4 55%); }
.ml-alert .ml-card { padding: 1.4em 1.3em; }
.ml-alert-head { display: flex; align-items: center; justify-content: space-between; }
.ml-bellbox { display: inline-flex; align-items: center; justify-content: center; width: 3em; height: 3em; border-radius: 1.1em; background: var(--bg); color: var(--blush); }
.ml-bellbox svg { width: 1.6em; height: 1.6em; }
.ml-alert h3 { margin-top: 1.1em; font-size: 1.25em; }
.ml-alert .ml-sub { margin-top: 0.3em; }
.ml-prod { display: flex; align-items: center; gap: 0.8em; margin-top: 1.1em; padding: 0.7em; border-radius: 1.1em; background: var(--bg); }
.ml-prod img { width: 3.2em !important; height: 3.2em !important; object-fit: contain !important; border-radius: 0.8em; background: #fff; padding: 0.2em; }
.ml-prod b { display: block; font-weight: 500; font-size: 0.86em; line-height: 1.2; }
.ml-prod span { color: var(--ink-3); font-size: 0.74em; }
.ml-alert .ml-label { margin: 1.2em 0 0.5em 0.2em; }
.ml-stepper { display: flex; align-items: center; gap: 0.6em; }
.ml-stepper button { display: inline-flex; align-items: center; justify-content: center; width: 3em; height: 3em; border-radius: 1em; background: var(--bg); color: var(--ink-2); transition: transform 0.22s var(--ease-spring), background 0.15s; }
.ml-stepper button:hover { background: var(--blush-soft); }
.ml-stepper button:active { transform: scale(0.9); }
.ml-stepper button svg { width: 1.1em; height: 1.1em; }
.ml-amount { display: flex; align-items: baseline; gap: 0.3em; flex: 1; height: 3em; padding: 0 1em; border-radius: 1em; border: 1px solid var(--line); background: var(--surface); font-variant-numeric: tabular-nums; }
.ml-amount span { align-self: center; color: var(--ink-3); font-size: 0.8em; font-weight: 500; }
.ml-amount output { align-self: center; font-size: 1.3em; font-weight: 500; letter-spacing: -0.01em; }
.ml-amount output.is-tick { animation: ml-tick 0.3s var(--ease-spring); }
@keyframes ml-tick { 0% { transform: translateY(0.25em); opacity: 0.4; } 100% { transform: none; opacity: 1; } }
.ml-alert .ml-btn { margin-top: 1.2em; }

.ml-alert-done { text-align: center; }
.ml-alert-done.is-in { animation: ml-pop 0.45s var(--ease-spring); }
@keyframes ml-pop { 0% { transform: scale(0.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
.ml-done-check { display: inline-flex; align-items: center; justify-content: center; width: 3.4em; height: 3.4em; border-radius: 50%; background: var(--lime); color: var(--ink); }
.ml-done-check svg { width: 1.6em; height: 1.6em; stroke-width: 2; }
.ml-alert-done h3 { margin-top: 0.8em; }
.ml-alert-done .ml-sub { margin-top: 0.4em; }
.ml-alert-done .ml-sub b { color: var(--ink); font-weight: 500; }
.ml-alert-done .ml-link { margin-top: 1.2em; }

.ml-push { position: absolute; top: 1.2em; left: 1.2em; right: 1.2em; z-index: 2; transform: translateY(-140%); opacity: 0; transition: transform 0.55s var(--ease-spring), opacity 0.3s; pointer-events: none; }
.ml-push.is-in { transform: none; opacity: 1; }
.ml-push-card { display: flex; gap: 0.7em; align-items: flex-start; padding: 0.8em 0.9em; border-radius: 1.3em; background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(1em); border: 1px solid rgba(255, 255, 255, 0.8); box-shadow: var(--shadow-elev); }
.ml-push-card img { width: 2.4em !important; height: 2.4em !important; border-radius: 0.7em; }
.ml-push-app { display: flex; justify-content: space-between; font-size: 0.74em; }
.ml-push-app b { font-weight: 600; }
.ml-push-app em { font-style: normal; color: var(--ink-3); }
.ml-push-card p { font-size: 0.86em; line-height: 1.3; }
.ml-push-card > div { flex: 1; min-width: 0; }

/* ============================================================
   3. Price history
   ============================================================ */
.ml-history { display: flex; align-items: center; padding: 1.6em; }
.ml-history .ml-card { width: 100%; padding: 1.4em 1.5em 1.5em; }
.ml-hist-head { display: flex; align-items: center; justify-content: space-between; }
.ml-hist-head h3 { font-size: 1.1em; }
.ml-chart { margin-top: 0.8em; }
.ml-chart-svg { display: block; width: 100%; height: auto; aspect-ratio: 600 / 220; overflow: visible; }
.ml-chart-line { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; }
.cp-media--live.in .ml-chart-line { animation: ml-draw 1.6s var(--ease-out) forwards; }
@keyframes ml-draw { to { stroke-dashoffset: 0; } }
.ml-chart-area { opacity: 0; }
.cp-media--live.in .ml-chart-area { animation: ml-fade 0.8s 0.9s forwards; }
@keyframes ml-fade { to { opacity: 1; } }
.ml-chart-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; opacity: 0; }
.cp-media--live.in .ml-chart-dot { animation: ml-fade 0.4s 1.4s forwards; }
.ml-chart-dot--min { stroke: var(--lime-deep); }
.ml-chart-dot--now { fill: var(--blush); stroke: var(--surface); }
.ml-periods { display: flex; gap: 0.5em; margin-top: 1em; }
.ml-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6em; margin-top: 1em; }
.ml-stats div { padding: 0.7em 0.9em; border-radius: 1em; background: var(--bg); }
.ml-stats span { display: block; color: var(--ink-3); font-size: 0.7em; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.ml-stats b { display: block; margin-top: 0.1em; font-weight: 500; font-size: 1em; font-variant-numeric: tabular-nums; }
.ml-verdict { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; flex-wrap: wrap; margin-top: 1em; }
.ml-verdict .ml-deal b { font-weight: 500; }
.ml-verdict-diff { color: var(--ink-2); font-size: 0.82em; }

/* ============================================================
   4. Architecture
   ============================================================ */
.ml-arch { font-size: calc(100cqw / 66); display: flex; flex-direction: column; justify-content: center; padding: 2em 2.2em; }
.ml-arch-row { display: grid; grid-template-columns: 1fr 3.2em 1fr 3.2em 1fr 3.2em 1fr 3.2em 1fr; align-items: center; }
.ml-node { padding: 1.1em 1.1em 1.2em; border-radius: 1.3em; background: var(--surface); box-shadow: var(--shadow-card); min-height: 7.6em; display: flex; flex-direction: column; gap: 0.35em; }
.ml-node b { font-weight: 500; font-size: 0.98em; letter-spacing: -0.005em; }
.ml-node span { color: var(--ink-3); font-size: 0.74em; line-height: 1.35; }
.ml-node--src { background: linear-gradient(160deg, #FFE4EC, #FFF6F4); }
.ml-node--db { background: var(--ink); color: var(--surface); }
.ml-node--db span { color: rgba(255, 255, 255, 0.6); }
.ml-node--user { background: linear-gradient(135deg, #FFCFC9 0%, #FFB5B0 50%, #F49EB0 100%); }
.ml-node--user span { color: var(--ink-2); }
.ml-wire { position: relative; height: 2px; background: rgba(30, 30, 37, 0.14); }
.ml-wire i { position: absolute; top: 50%; left: 0; width: 0.55em; height: 0.55em; margin-top: -0.275em; border-radius: 50%; background: var(--blush); animation: ml-flow 2.4s linear infinite; animation-delay: calc(var(--i) * 0.4s); }
.ml-wire i:nth-child(2) { animation-delay: calc(var(--i) * 0.4s + 0.8s); }
.ml-wire i:nth-child(3) { animation-delay: calc(var(--i) * 0.4s + 1.6s); }
@keyframes ml-flow { 0% { left: -0.3em; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 0.25em); opacity: 0; } }
.ml-arch-foot { display: flex; justify-content: space-between; gap: 1.5em; flex-wrap: wrap; margin-top: 1.6em; padding-top: 1.1em; border-top: 1px solid rgba(30, 30, 37, 0.1); color: var(--ink-2); font-size: 0.8em; }
.ml-arch-foot b { color: var(--ink); font-weight: 600; }

/* ============================================================
   5. Tokens
   ============================================================ */
.ml-tokens { font-size: calc(100cqw / 28); padding: 1.4em; display: flex; flex-direction: column; gap: 1em; justify-content: center; }
.ml-tok-swatches { display: flex; justify-content: space-between; gap: 0.4em; }
.ml-sw { display: flex; flex-direction: column; align-items: center; gap: 0.25em; }
.ml-sw i { width: 2.6em; height: 2.6em; border-radius: 0.9em; box-shadow: inset 0 0 0 1px rgba(30, 30, 37, 0.08); }
.ml-sw b { font-size: 0.68em; font-weight: 500; }
.ml-sw span { color: var(--ink-3); font-size: 0.58em; font-variant-numeric: tabular-nums; }
.ml-tok-type { display: flex; flex-direction: column; gap: 0.15em; padding: 1em 1.1em; border-radius: 1.2em; background: var(--surface); box-shadow: var(--shadow-card); }
.ml-tok-h1 { font-size: 1.15em; font-weight: 400; letter-spacing: -0.01em; }
.ml-tok-h1 b { font-weight: 500; }
.ml-tok-body { color: var(--ink-3); font-size: 0.7em; }
.ml-tok-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.7em; }
.ml-tok-radius { display: flex; align-items: center; gap: 0.6em; padding: 0.7em; border-radius: 1.2em; background: var(--surface); box-shadow: var(--shadow-card); }
.ml-tok-radius i { width: 2.4em; height: 2.4em; border-radius: 0.9em; border: 2px solid var(--blush); border-right-color: transparent; border-bottom-color: transparent; }
.ml-tok-radius span { font-size: 1.1em; font-weight: 500; }
.ml-tok-radius small { color: var(--ink-3); font-size: 0.6em; margin-left: 0.1em; }
.ml-tok-shadow { display: flex; align-items: center; padding: 0.7em 0.9em; border-radius: 1.2em; background: var(--surface); box-shadow: var(--shadow-elev); color: var(--ink-2); font-size: 0.72em; }
.ml-tok-contrast { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4em; }
.ml-tok-contrast li { display: flex; align-items: center; gap: 0.6em; font-size: 0.74em; color: var(--ink-2); }
.ml-tok-contrast i { display: inline-flex; align-items: center; justify-content: center; width: 2.2em; height: 2.2em; border-radius: 0.7em; font-style: normal; font-weight: 600; font-size: 0.9em; }
.ml-tok-contrast b { margin-left: auto; color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.ml-tok-foot { color: var(--ink-3); font-size: 0.64em; line-height: 1.4; }

/* ---- motion preference ---- */
@media (prefers-reduced-motion: reduce) {
  .ml-wire i { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; opacity: 1 !important; }
  .ml-chart-line { stroke-dashoffset: 0; animation: none; }
  .ml-chart-area, .ml-chart-dot { opacity: 1; animation: none; }
}

/* ---- narrow screens: the grid stacks its two columns and the side tile no
   longer inherits a height from its neighbour, so each live tile brings its
   own ratio ---- */
@media (max-width: 640px) {
  .cp-section-media-row .cp-section-side .cp-media--live,
  .cp-section-media-row .cp-section-copy .cp-media--live,
  .cp-overview-bottom--stacked .cp-section-side .cp-media--live,
  .cp-overview-bottom--stacked .cp-section-copy .cp-media--live {
    height: auto !important;
    aspect-ratio: var(--live-ratio, 4 / 5) !important;
  }
  .cp-media--live[data-live="alert"] { --live-ratio: 4 / 5; }
  .cp-media--live[data-live="tokens"] { --live-ratio: 4 / 5; }
  .cp-media--live[data-live="history"] { --live-ratio: 1 / 1; }
  .cp-media--live[data-live="phone"] { --live-ratio: 4 / 5; }
  .cp-section-media-full .cp-media--live[data-live="arch"] { aspect-ratio: 4 / 5 !important; }
  /* at phone width the architecture reads top-down */
  .ml-arch { font-size: calc(100cqw / 30); padding: 1.4em; }
  .ml-arch-row { grid-template-columns: 1fr; gap: 0.5em; }
  .ml-wire { height: 1.6em; width: 2px; margin: 0 auto; }
  .ml-wire i { left: 50%; top: 0; margin: 0 0 0 -0.275em; animation-name: ml-flow-v; }
  @keyframes ml-flow-v { 0% { top: -0.3em; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 0.25em); opacity: 0; } }
  .ml-node { min-height: 0; padding: 0.8em 0.9em; }
  .ml-arch-foot { flex-direction: column; gap: 0.4em; }
}
