/* Kexo landing-page interactive demo — phone frame + mini app.
   Scoped under .kexo-demo so it can't leak into landing styles.
   Tokens mirror the iOS app look (dark bg, cream cards, green accent). */

.kexo-demo {
  --kd-bg: #0e0e10;
  --kd-surface: #19191a;
  --kd-raised: #212123;
  --kd-border: rgba(255, 255, 255, 0.08);
  --kd-text: #eeece9;
  --kd-text-2: #9e9a95;
  --kd-text-3: #807b76;
  --kd-green: #17f28c;
  --kd-green-dark: #0c9457;
  --kd-negative: #f43f5e;
  --kd-cream: #f5f3f0;
  --kd-cream-text: #1a1a1a;
  --kd-cream-muted: #636363;
  --kd-protein: #f4652e;
  --kd-carbs: #2382f2;
  --kd-fat: #14a05f;
  --kd-fiber: #e8c518;
  --kd-radius: 16px;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

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

/* :where() keeps the reset at zero specificity so single-class component
   styles (.kd-tab, .kd-chip, .kd-add-btn, …) can override it. */
:where(.kexo-demo) :where(button) {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.kexo-demo button:focus-visible,
.kexo-demo input:focus-visible {
  outline: 2px solid var(--kd-green);
  outline-offset: 2px;
}

/* ---------- phone frame ---------- */
.kd-phone {
  width: min(375px, 100%);
  height: 700px;
  max-height: 82vh;
  min-height: 540px;
  margin: 0 auto;
  background: var(--kd-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 44px;
  box-shadow:
    0 0 0 10px #1c1c1e,
    0 0 0 11px rgba(255, 255, 255, 0.08),
    0 40px 80px -24px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---------- app header ---------- */
.kd-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 18px 16px 6px;
}
.kd-logo {
  height: 18px;
  width: auto;
  display: block;
}

/* ---------- day summary ---------- */
.kd-summary {
  flex-shrink: 0;
  padding: 2px 16px 8px;
}
.kd-kcal-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.kd-kcal-num {
  font-family: "SF Pro Rounded", ui-rounded, Nunito, system-ui, sans-serif;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--kd-green);
  transition: color 0.3s ease;
}
.kd-kcal-num.kd-over { color: var(--kd-negative); }
.kd-kcal-label { font-size: 12px; font-weight: 600; color: var(--kd-text-2); }
.kd-progress {
  margin-top: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--kd-surface);
  overflow: hidden;
}
/* Fill animates via transform: scaleX() set from JS — never width. */
.kd-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--kd-green);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}
.kd-progress-fill.kd-over { background: var(--kd-negative); }
.kd-sub-line {
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--kd-text-3);
}

/* macro card — cream card with 4 progress rings, like the app's day view */
.kd-macro-card {
  margin-top: 9px;
  background: var(--kd-cream);
  border-radius: 16px;
  padding: 10px 6px 8px;
  display: flex;
}
.kd-ring {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.kd-ring svg {
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
  margin-bottom: 3px;
}
.kd-ring circle {
  fill: none;
  stroke-width: 4;
}
.kd-ring .kd-ring-bg { stroke: rgba(0, 0, 0, 0.1); }
.kd-ring .kd-ring-fill {
  stroke: var(--kd-ring-color, #999);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.kd-ring b {
  font-family: "SF Pro Rounded", ui-rounded, Nunito, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--kd-cream-text);
}
.kd-ring .kd-ring-target {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--kd-cream-muted);
}
.kd-ring .kd-ring-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--kd-cream-muted);
}

/* ---------- feed ---------- */
.kd-feed {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: none;
}
.kd-feed::-webkit-scrollbar { display: none; }

.kd-bubble {
  max-width: 84%;
  border-radius: var(--kd-radius);
  padding: 8px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  animation: kd-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.kd-bubble.kd-coach {
  align-self: flex-start;
  background: var(--kd-surface);
  color: var(--kd-text);
  border-bottom-left-radius: 5px;
}
.kd-bubble.kd-user {
  align-self: flex-end;
  background: var(--kd-green-dark);
  color: #eafff4;
  border-bottom-right-radius: 5px;
}
.kd-bubble a {
  color: var(--kd-green);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.kd-bubble.kd-photo {
  padding: 4px;
  max-width: 56%;
}
.kd-bubble.kd-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 13;
  object-fit: cover;
  border-radius: calc(var(--kd-radius) - 4px);
  background: var(--kd-raised);
}

.kd-typing {
  align-self: flex-start;
  background: var(--kd-surface);
  border-radius: var(--kd-radius);
  border-bottom-left-radius: 5px;
  padding: 12px 14px;
  display: flex;
  gap: 5px;
}
.kd-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kd-text-3);
  animation: kd-blink 1.2s infinite;
}
.kd-typing i:nth-child(2) { animation-delay: 0.2s; }
.kd-typing i:nth-child(3) { animation-delay: 0.4s; }

/* ---------- estimate card (dark, matches app dark mode) ---------- */
.kd-card {
  align-self: stretch;
  background: var(--kd-raised);
  color: var(--kd-text);
  border: 1px solid var(--kd-border);
  border-radius: 18px;
  padding: 11px 12px;
  animation: kd-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.kd-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--kd-text-3);
  margin-bottom: 5px;
}
.kd-conf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--kd-text-2);
}
.kd-conf::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kd-green);
}
.kd-conf.kd-conf-medium::before { background: #f59e0b; }
.kd-conf.kd-conf-low::before { background: var(--kd-negative); }

.kd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.kd-item:last-of-type { border-bottom: 0; }
.kd-item-info { flex: 1; min-width: 0; }
.kd-item-name {
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kd-item-meta { font-size: 10.5px; color: var(--kd-text-3); }
.kd-item-kcal {
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}
.kd-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 2px;
}
.kd-stepper button {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: var(--kd-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.kd-stepper button:hover { background: rgba(255, 255, 255, 0.12); }
.kd-stepper button:disabled { opacity: 0.3; cursor: default; }

.kd-card-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 5px;
  padding-top: 7px;
  border-top: 1.5px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
}
.kd-card-total b {
  font-family: "SF Pro Rounded", ui-rounded, Nunito, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 900;
}
.kd-card-hint {
  margin-top: 2px;
  font-size: 10px;
  color: var(--kd-text-3);
}
.kd-add-btn {
  margin-top: 8px;
  width: 100%;
  border-radius: 999px;
  background: var(--kd-cream);
  color: #111;
  font-size: 12.5px;
  font-weight: 800;
  padding: 9px 0;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.kd-add-btn:active { transform: scale(0.98); }
.kd-add-btn.kd-added {
  background: var(--kd-green-dark);
  color: #eafff4;
  cursor: default;
}

/* ---------- photo sheet ---------- */
.kd-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--kd-raised);
  border-radius: 26px 26px 0 0;
  padding: 14px 14px 16px;
  transform: translateY(105%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}
.kd-sheet.kd-open { transform: translateY(0); }
.kd-sheet-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--kd-text);
  margin: 0 0 3px;
}
.kd-sheet-sub {
  font-size: 11px;
  color: var(--kd-text-3);
  margin: 0 0 10px;
}
.kd-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kd-sheet-grid button {
  border-radius: 13px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--kd-surface);
  transition: transform 0.15s ease;
}
.kd-sheet-grid button:active { transform: scale(0.96); }
.kd-sheet-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kd-sheet-grid span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 13px 5px 4px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}
.kd-sheet-close {
  margin-top: 10px;
  width: 100%;
  border-radius: 999px;
  background: var(--kd-surface);
  color: var(--kd-text-2);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 0;
}
.kd-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 4;
}
.kd-scrim.kd-open { opacity: 1; pointer-events: auto; }

/* ---------- input bar ---------- */
.kd-inputwrap {
  flex-shrink: 0;
  padding: 6px 12px 14px;
}
.kd-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 7px;
  scrollbar-width: none;
}
.kd-chips::-webkit-scrollbar { display: none; }
.kd-chip {
  flex-shrink: 0;
  border: 1px solid var(--kd-border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 600;
  color: var(--kd-text-2);
  background: var(--kd-surface);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.kd-chip:hover { border-color: var(--kd-green); color: var(--kd-text); }
.kd-inputbar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--kd-surface);
  border: 1px solid var(--kd-border);
  border-radius: 999px;
  padding: 5px 5px 5px 7px;
}
.kd-cam {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kd-text-2);
  transition: color 0.2s ease, background 0.2s ease;
}
.kd-cam:hover { color: var(--kd-green); background: rgba(23, 242, 140, 0.08); }
.kd-cam svg { width: 18px; height: 18px; }
.kd-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  color: var(--kd-text);
  font-size: 13px;
  font-family: inherit;
}
.kd-input::placeholder { color: var(--kd-text-3); }
.kd-send {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--kd-green);
  color: #06281a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.kd-send:disabled { opacity: 0.35; cursor: default; }
.kd-send:not(:disabled):active { transform: scale(0.92); }
.kd-send svg { width: 15px; height: 15px; }

/* ---------- section chrome around the phone ---------- */
.kd-disclaimer {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: #807b76;
}

@keyframes kd-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes kd-blink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .kd-bubble, .kd-card { animation: none; }
  .kd-progress-fill, .kd-ring .kd-ring-fill { transition: none; }
}

@media (max-width: 420px) {
  .kd-phone {
    height: 640px;
    border-radius: 36px;
    box-shadow: 0 0 0 7px #1c1c1e, 0 0 0 8px rgba(255, 255, 255, 0.08), 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  }
}
