/* =========================================================
   Section 3 — Live Math Engine (Web Demo)
   Figma node 2132:1020 (desktop, 1512 × 1204) / 2197:2585 (mobile card)
   ========================================================= */

.demo {
  --demo-bg: #020d18;
  --demo-panel: #0d1117;
  --demo-card: #161b22;
  --demo-line: #30363d;
  --demo-divider: #1f2937;
  --demo-input: #1f2937;
  --demo-placeholder: #6b7280;
  --demo-label: #fafafa;
  --demo-muted: #999999;
  --demo-muted-2: #9ca3af;
  --demo-cyan: #00e5ff;
  --demo-chip-bg: rgba(40, 36, 5, 0.72);
  --demo-chip-line: #997125;
  --demo-chip-text: #f59e0b;
  --demo-danger: #ef4444;

  --demo-shadow:
    0 13.389px 20.083px -10.878px rgba(0, 0, 0, 0.5),
    0 1.799px 0.418px -1.674px rgba(0, 0, 0, 0.25),
    0 4.184px 1.255px -3.347px rgba(8, 8, 8, 0.2),
    0 5.021px 3.347px -3.347px rgba(8, 8, 8, 0.16),
    0 5.021px 10.878px 0 rgba(8, 8, 8, 0.12),
    0 20.083px 20.083px -13.389px rgba(8, 8, 8, 0.08);
  --demo-inset: inset 1.674px 3.347px 13.389px 0 rgba(253, 253, 253, 0.05);

  position: relative;
  padding-block: 96px;
  /* #0D1117 from section 2 fades into #020D18 and back out at the bottom */
  background:
    linear-gradient(180deg,
      var(--color-bg-fade) 0,
      var(--color-bg-fade) 25px,
      var(--demo-bg) 175px,
      var(--demo-bg) calc(100% - 110px),
      var(--color-bg-fade) 100%);
}

/* ---------- Heading ---------- */
.demo__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.demo__title {
  font-size: 52px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.52px;
  color: var(--color-white);
}

.demo__title-accent { color: var(--color-amber); }

.demo__subtitle {
  max-width: 880px;
  font-size: 20px;
  line-height: 1.7;
  color: var(--color-text-muted);
}

/* ---------- Main card ("Steps") ---------- */
.demo-card {
  position: relative;
  margin-top: 64px;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(118.87deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
    var(--demo-card);
  box-shadow: var(--demo-shadow);
}

/* Card stroke drawn on top (Figma strokes sit inside the frame) */
.demo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 1px solid var(--demo-line);
  border-radius: inherit;
  pointer-events: none;
}

/* Soft inner highlight used on every glass card */
.demo-card::after,
.demo-box::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--demo-inset);
  pointer-events: none;
}

.demo-card__header {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 24px 28px 23px;          /* + 1px divider = Figma's 77px header */
  border-bottom: 1px solid var(--demo-divider);
}

.demo-card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.demo-card__name {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-white);
}

.demo-card__tag {
  font-size: 18px;
  color: var(--color-text-muted);
}

.demo-card__limits {
  display: flex;
  gap: 10px;
}

/* Amber pill (limits + output amounts) */
.demo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border: 1.091px solid var(--demo-chip-line);
  border-radius: 999px;
  background: var(--demo-chip-bg);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  color: var(--demo-chip-text);
}

.demo-chip > span { opacity: 0.9; }

.demo-card__body {
  display: flex;
  align-items: stretch;
}

.demo-panel {
  flex: 1 1 0;
  min-width: 0;
  padding: 24px;
  background: var(--demo-panel);
}

.demo-panel--input {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--demo-divider);
}

.demo-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.demo-group--target { gap: 10px; }

.demo-label {
  font-size: 18px;
  line-height: 25px;
  color: var(--demo-muted);
}

.demo-label--alt { color: var(--demo-muted-2); }
.demo-label--output { font-size: 16px; line-height: 22px; }

/* "Sample" pill next to "Batch Output" — hidden once the visitor generates a batch */
.demo-label--output {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-sample-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--demo-chip-line);
  border-radius: 999px;
  background: var(--demo-chip-bg);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--demo-chip-text);
}

.demo-sample-tag[hidden] { display: none; }

/* Glass inner box */
.demo-box {
  position: relative;
  padding: 17px 13px;               /* 18/14 incl. the 1px stroke */
  border: 1px solid var(--demo-line);
  border-radius: 16px;
  background:
    linear-gradient(119.03deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
    var(--demo-card);
  box-shadow: var(--demo-shadow);
}

.demo-box--target {
  background:
    linear-gradient(149.39deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
    var(--demo-card);
}

/* ---------- Ingredient rows ---------- */
.demo-rows {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.demo-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.demo-row,
.demo-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-row-head {
  font-size: 16px;
  line-height: 1.2;
  color: var(--demo-label);
}

.demo-row-head > :first-child { flex: 1 1 0; min-width: 0; }
.demo-row-head > :nth-child(2) { flex: none; width: 102px; }
.demo-row-head > :nth-child(3) { flex: none; width: 26px; height: 26px; }

.demo-row { animation: demo-row-in 0.3s var(--ease-out); }

.demo-input {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--demo-line);
  border-radius: 10px;
  background: var(--demo-input);
  font: inherit;
  font-size: 16px;
  color: var(--demo-label);
  outline: none;
  text-overflow: ellipsis;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.demo-input::placeholder {
  color: var(--demo-placeholder);
  opacity: 1;
}

.demo-input:focus {
  border-color: var(--demo-chip-line);
  box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.12);
}

.demo-input.is-invalid {
  border-color: var(--demo-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.demo-input--qty {
  flex: none;
  width: 102px;
  padding: 0 4px;
  text-align: center;
}

.demo-delete {
  flex: none;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  border: 1.154px solid rgba(255, 255, 255, 0.06);
  background: rgba(69, 10, 10, 0.64);
  transition: background 0.2s ease, transform 0.2s ease;
}

.demo-delete img { width: 15px; height: 15px; }

.demo-delete:hover {
  background: rgba(127, 29, 29, 0.85);
  transform: scale(1.06);
}

.demo-add {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
  color: var(--color-amber);
  transition: opacity 0.2s ease;
}

.demo-add img { width: 16px; height: 16px; }

.demo-add:hover:not([aria-disabled="true"]) { text-decoration: underline; text-underline-offset: 3px; }

.demo-add[aria-disabled="true"] {
  cursor: not-allowed;
}

/* ---------- Target grams ---------- */
.demo-target {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.demo-target__label {
  font-size: 16px;
  line-height: 19px;
  color: var(--demo-label);
}

.demo-target__field {
  position: relative;
}

.demo-target__field .demo-input {
  padding-right: 38px;
  padding-bottom: 5px;              /* Figma places this placeholder slightly high */
}

.demo-target__unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: #f3f4f6;
  pointer-events: none;
}

/* Hide number spinners to match the design */
.demo-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.demo-input[type="number"]::-webkit-outer-spin-button,
.demo-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.demo-error {
  min-height: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #f87171;
}

.demo-error:empty { display: none; }
.demo-error.is-note { color: var(--demo-chip-text); }

/* ---------- Generate button ---------- */
.demo-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--demo-cyan);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  color: #000;
  transition: box-shadow 0.25s ease, transform 0.2s ease, filter 0.2s ease;
}

.demo-generate img { width: 20.25px; height: 18px; }

.demo-generate:hover {
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.45);
  filter: brightness(1.05);
}

.demo-generate:active { transform: scale(0.99); }

.demo-generate.is-busy img { animation: demo-spin 0.8s linear infinite; }

/* ---------- Output ---------- */
.demo-output {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 13px;
  border: 1px solid var(--demo-line);
  border-radius: 24px;
  background: var(--demo-panel);
  box-shadow: var(--demo-shadow);
}

.demo-output::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--demo-inset);
  pointer-events: none;
}

.demo-total {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 13px;
  border: 1px solid var(--demo-line);
  border-radius: 16px;
  background:
    linear-gradient(156.87deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
    var(--demo-card);
}

.demo-total__main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.demo-total__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1.846px solid var(--demo-line);
  border-radius: 50%;
  background:
    radial-gradient(24px 48px at 50% 0, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)),
    rgba(255, 255, 255, 0.02);
}

.demo-total__icon img { width: 26px; height: 26px; }

.demo-total__label {
  flex: 1 1 auto;
  font-size: 16px;
  color: #e5e7eb;
}

.demo-total__value {
  font-size: 24px;
  font-weight: 500;
  color: var(--color-white);
  white-space: nowrap;
}

.demo-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 12px;
}

.demo-result {
  display: flex;
  align-items: center;
  gap: 20px;
}

.demo-result + .demo-result {
  padding-top: 13px;                /* + 1px divider = 14px gap */
  border-top: 1px solid rgba(254, 254, 254, 0.1);
}

.demo-result__main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.demo-result__icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1.543px solid #414141;
  border-radius: 50%;
  background: radial-gradient(circle 16.1px at 50% 0, #202020, #141414);
  box-shadow: inset 0 0.159px 0 #777, 0 3.492px 0.794px rgba(0, 0, 0, 0.3);
}

/* soft amber glint (Figma "Ellipse 2") */
.demo-result__icon::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 179, 0, 0.35);
  filter: blur(3px);
}

.demo-result__icon img { position: relative; width: 18px; height: 18px; }

.demo-result__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  color: var(--demo-label);
}

.demo-result .demo-chip {
  padding: 5.091px 6.364px;
  border-width: 1.273px;
}

.demo-output.is-updated .demo-total,
.demo-output.is-updated .demo-result {
  animation: demo-pop 0.45s var(--ease-out) both;
}

.demo-output.is-updated .demo-result:nth-child(2) { animation-delay: 0.05s; }
.demo-output.is-updated .demo-result:nth-child(3) { animation-delay: 0.1s; }
.demo-output.is-updated .demo-result:nth-child(4) { animation-delay: 0.15s; }

.demo-note {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--demo-placeholder);
}

/* ---------- Store badges under the card ---------- */
.demo__stores {
  justify-content: center;
  margin-top: 48px;
}

@keyframes demo-row-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

@keyframes demo-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@keyframes demo-spin { to { transform: rotate(360deg); } }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1199px) {
  .demo__title { font-size: 44px; }
}

/* Tablet — panels stack (output under the form, like mobile) */
@media (max-width: 991px) {
  .demo__title    { font-size: 40px; }
  .demo__subtitle { font-size: 18px; }

  .demo-card__body { flex-direction: column; }

  .demo-panel--input {
    border-right: 0;
    border-bottom: 1px solid var(--demo-divider);
  }
}

/* Mobile — matches section_3_mobile.png / web_demo_mobile.svg */
@media (max-width: 767px) {
  .demo {
    padding-top: 49px;
    padding-bottom: 110px;
    background:
      linear-gradient(180deg,
        var(--color-bg-fade) 0,
        var(--color-bg-fade) 40px,
        var(--demo-bg) 200px,
        var(--demo-bg) 100%);
  }

  .demo__title {
    font-size: 26px;
    letter-spacing: -0.26px;
  }

  .demo__subtitle {
    font-size: 16px;
  }

  .demo-card {
    margin-top: 32px;
    border-radius: 18px;
    background:
      linear-gradient(97.26deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
      var(--demo-card);
  }

  .demo-card__header { padding: 13px 18px 12px; }
  .demo-target__label { line-height: 17px; }
  .demo-card__name   { font-size: 14px; }
  .demo-card__tag    { display: none; }
  .demo-card__limits { gap: 5px; }

  .demo-card__limits .demo-chip {
    height: 22px;
    padding: 0 8px;
    font-size: 10px;
  }

  .demo-panel { padding: 16px 14px; }

  .demo-label         { font-size: 16px; line-height: 22px; }
  .demo-label--output { font-size: 14px; line-height: 20px; }

  .demo-box { border-radius: 12px; }

  .demo-box:not(.demo-box--target) {
    background:
      linear-gradient(110.67deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
      var(--demo-card);
  }

  .demo-box--target {
    background:
      linear-gradient(139deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
      var(--demo-card);
  }

  .demo-row-head,
  .demo-target__label,
  .demo-add { font-size: 14px; }

  .demo-input {
    height: 42px;
    font-size: 14px;
  }

  .demo-generate { height: 42px; }

  .demo-output {
    gap: 16px;
    border-radius: 18px;
  }

  .demo-total {
    gap: 18px;
    padding: 7px 11px;
    border-radius: 12px;
    background:
      linear-gradient(152deg, rgba(22, 27, 34, 0.2) 71.337%, rgba(255, 255, 255, 0.2) 110.66%),
      var(--demo-card);
  }

  .demo-total__icon {
    width: 42px;
    height: 42px;
    border-width: 1.577px;
    background:
      radial-gradient(21px 42px at 50% 0, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)),
      rgba(255, 255, 255, 0.02);
  }

  .demo-total__icon img { width: 22.2px; height: 22.2px; }
  .demo-total__label    { font-size: 14px; }
  .demo-total__value    { font-size: 20px; }

  .demo-results { gap: 12px; }
  .demo-result + .demo-result { padding-top: 11px; }

  .demo-result__icon {
    width: 28px;
    height: 28px;
    background: radial-gradient(circle 11.9px at 50% 0, #202020, #141414);
  }

  .demo-result__icon::before { left: 13px; top: 5px; }
  .demo-result__icon img { width: 18px; height: 18px; }
  .demo-result__name { font-size: 13px; }

  .demo-result .demo-chip {
    padding: 3px 6.364px;
    font-size: 12px;
  }

  .demo__stores { margin-top: 30px; }
}

/* Phones & tablets: tiny icon glow as a gradient instead of blur(3px) */
@media (max-width: 991px), (hover: none) and (pointer: coarse) {
  .demo-result__icon::before {
    left: 15px;
    top: 4px;
    width: 11px;
    height: 11px;
    filter: none;
    background: radial-gradient(closest-side, rgba(255, 179, 0, 0.35), rgba(255, 179, 0, 0));
  }
}
