/* ── Outer group: heading → bar → serving line ─────────────────── */

.recipe-scale-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0;
}

.recipe-scale-group > h2 {
  margin: 0;
  padding: 0;
}

.recipe-scale-serving {
  margin: 0;
  font-size: 0.85em;
  line-height: 1.2;
}

/* Tighten gap between servings group and the next heading (Ingredients) */
.recipe-scale-group + h2 {
  margin-top: 0.8em;
}

/* ── Recipe Scaling Widget ──────────────────────────────────────── */

.recipe-scale-widget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Unified control bar: [ − | 6 | + ‖ ½× | 2× | 3× ] ──────── */

.recipe-scale-bar {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--md-default-fg-color--lighter, #555);
  border-radius: 0.4rem;
  overflow: hidden;
  height: 2rem;
}

/* Shared style for every cell in the bar */
.recipe-scale-bar > button,
.recipe-scale-bar > span {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--md-default-fg-color--light, #aaa);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

/* Vertical separator between every adjacent cell */
.recipe-scale-bar > * + * {
  border-left: 1px solid var(--md-default-fg-color--lighter, #555);
}

/* Stronger separator between stepper and presets */
.recipe-scale-divider {
  width: 0;
  padding: 0;
  cursor: default;
  border-left-width: 2px;
}

/* ── Stepper buttons (−, +) ───────────────────────────────────── */

.recipe-scale-btn {
  width: 2rem;
  font-size: 1rem;
  font-weight: 700;
  padding: 0;
}

.recipe-scale-btn:hover {
  background: var(--md-default-fg-color--lightest, rgba(255, 255, 255, 0.08));
  color: var(--md-default-fg-color, #ddd);
}

.recipe-scale-btn:active {
  background: var(--md-default-fg-color--lightest, rgba(255, 255, 255, 0.15));
}

/* ── Servings display (center number) ──────────────────────────── */

.recipe-scale-display {
  min-width: 1.8rem;
  padding: 0 0.15rem;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  cursor: default;
}

/* ── Preset chips (½×, 2×, 3×) ────────────────────────────────── */

.recipe-scale-chip {
  padding: 0 0.55rem;
  font-size: 0.75rem;
}

.recipe-scale-chip:hover {
  background: var(--md-default-fg-color--lightest, rgba(255, 255, 255, 0.08));
  color: var(--md-default-fg-color, #ddd);
}

.recipe-scale-chip:active {
  background: var(--md-default-fg-color--lightest, rgba(255, 255, 255, 0.15));
}

.recipe-scale-chip.active {
  background: var(--md-default-fg-color--lightest, rgba(255, 255, 255, 0.12));
  color: var(--md-default-fg-color, #ddd);
}

/* ── Reset link (outside the bar) ──────────────────────────────── */

.recipe-scale-reset {
  display: flex;
  align-items: center;
  height: 2rem;
  padding: 0 0.2rem;
  background: transparent;
  border: none;
  color: var(--md-default-fg-color--light, #999);
  font-size: 0.72rem;
  font-weight: 400;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.recipe-scale-reset:hover {
  color: var(--md-default-fg-color, #ddd);
}

/* ── Quantity Flash Animation ──────────────────────────────────── */

.recipe-qty-flash {
  animation: qty-flash 0.45s ease-out;
}

@keyframes qty-flash {
  0%   { background-color: rgba(255, 255, 255, 0.1); }
  100% { background-color: transparent; }
}

/* ── Reduced Motion ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .recipe-qty-flash {
    animation: none;
  }

  .recipe-scale-bar > button,
  .recipe-scale-reset {
    transition: none;
  }
}

/* Nutrition details link: force it to sit directly under the nutrition table */
h2#nutrition + table {
  margin-bottom: 0.1rem !important;
}

h2#nutrition + .md-typeset__scrollwrap {
  margin-bottom: 0.1rem !important;
}

h2#nutrition + table + .nutrition-details-row {
  margin-top: 0 !important;
}

h2#nutrition + .md-typeset__scrollwrap + .nutrition-details-row {
  margin-top: 0 !important;
}

.nutrition-details-row {
  margin-top: -0.7rem !important;
  margin-bottom: 0.4rem !important;
}
