/* Recipe Cost Calculator. Shared pieces are in assets/ab-tools.css. */

.abt-recipe {
  scroll-margin-top: 90px; /* Clears a sticky site header when moving between steps. */
}

.abt-recipe .abt-step-title:focus {
  outline: none;
}

.abt-field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.abt-field-pair .abt-field {
  margin-bottom: 0;
}

.abt-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* --- Ingredient rows --------------------------------------------------- */

/* Phones: name and remove on top, amount and unit underneath. */
.abt-ingredient {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  grid-template-areas:
    "name name remove"
    "qty  unit .";
  gap: 8px;
  padding: 10px;
  background: var(--abt-surface-low);
  border-radius: var(--abt-radius);
}

.abt-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

/* Column labels show on the first row only; screen readers still get them on every row. */
.abt-ingredient + .abt-ingredient .abt-label--sm {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.abt-ingredient > label {
  position: relative;
  display: block;
  min-width: 0;
  margin: 0;
}

.abt-row-name {
  grid-area: name;
}

.abt-row-qty {
  grid-area: qty;
}

.abt-row-unit {
  grid-area: unit;
}

.abt-ingredient .abt-row-remove {
  grid-area: remove;
  align-self: end;
  display: grid;
  place-items: center;
  width: 40px;
  height: var(--abt-tap);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--abt-radius);
  background: none;
  color: var(--abt-muted);
  cursor: pointer;
}

.abt-ingredient .abt-row-remove:hover {
  background: var(--abt-surface-high);
  color: var(--abt-error);
}

.abt-ingredient .abt-row-remove:disabled {
  visibility: hidden;
}

/* --- Photo ------------------------------------------------------------- */

.abt-photo-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 128px;
  margin: 0;
  padding: 20px;
  border: 2px dashed var(--abt-line);
  border-radius: var(--abt-radius-lg);
  background: var(--abt-surface-low);
  font: inherit;
  color: var(--abt-primary);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.abt-photo-pick:hover {
  border-color: var(--abt-primary);
}

.abt-photo-pick:focus-visible {
  outline: 2px solid var(--abt-primary);
  outline-offset: 2px;
}

.abt-photo-pick .abt-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
}

.abt-photo-pick-title {
  font-size: 16px;
  font-weight: 700;
}

.abt-photo-pick-text {
  font-size: 13px;
  color: var(--abt-muted);
}

.abt-photo-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  margin: 0;
  object-fit: cover;
  border-radius: var(--abt-radius-lg);
}

.abt-photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* --- Step 2: ingredient costs ------------------------------------------ */

.abt-costs {
  display: grid;
  gap: 10px;
}

.abt-cost {
  padding: 14px;
  border: 1px solid var(--abt-line);
  border-radius: var(--abt-radius);
  background: var(--abt-surface);
}

.abt-cost-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 10px;
}

.abt-cost-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--abt-text);
  overflow-wrap: anywhere;
}

.abt-cost-uses {
  font-size: 14px;
  color: var(--abt-muted);
}

.abt-cost-fields {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  align-items: end;
  gap: 8px;
}

.abt-cost-fields > label {
  display: block;
  min-width: 0;
  margin: 0;
}

/* "$5.00 for 400 g" reads naturally once there's room for the word. */
.abt-cost-for {
  display: none;
  padding-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--abt-muted);
}

@media (min-width: 480px) {
  .abt-cost-fields {
    grid-template-columns: 1fr auto 1.3fr;
  }

  .abt-cost-for {
    display: block;
  }
}

.abt-cost-line {
  margin-top: 10px;
  font-size: 14px;
  color: var(--abt-muted);
}

.abt-cost-line:empty {
  display: none;
}

.abt-cost-line strong {
  color: var(--abt-primary);
}

/* --- Step 3: results --------------------------------------------------- */

.abt-target {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--abt-line);
  border-radius: var(--abt-radius);
}

.abt-target-field {
  display: block;
  flex: 0 0 120px;
  margin: 0;
}

.abt-target-result {
  flex: 1 1 200px;
  font-size: 15px;
  color: var(--abt-muted);
}

.abt-target-result strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--abt-primary);
}

.abt-breakdown-label {
  margin-top: 4px;
}

.abt-bar {
  display: block;
  height: 6px;
  margin-top: 6px;
  border-radius: 3px;
  background: var(--abt-surface-high);
  overflow: hidden;
}

.abt-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--abt-primary);
}

/* --- Larger screens ---------------------------------------------------- */

@media (min-width: 600px) {
  .abt-ingredient {
    grid-template-columns: 1fr 110px 120px 40px;
    grid-template-areas: "name qty unit remove";
    padding: 10px 12px;
  }
}
