/* styles.css — mobile-first, works on desktop. No framework. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #ff8f00;        /* Princeton orange — fills, bars, active chips */
  --accent-ink: #241300;    /* text sitting ON the orange */
  --accent-soft: #ffe6c2;   /* soft orange tint for pressed states */
  --accent-text: #c2410c;   /* readable orange for text on light surfaces */
  --bar: #ff8f00;
  --danger: #b91c1c;
  --radius: 14px;
  --tap: 46px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --card: #171a1f;
    --ink: #eceef1;
    --muted: #9aa3ad;
    --line: #262b31;
    --accent: #ff9e1f;        /* slightly brighter orange for dark surfaces */
    --accent-ink: #241300;
    --accent-soft: #3a2610;
    --accent-text: #fdba74;   /* light orange for text on dark surfaces */
    --bar: #ff9e1f;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: manipulation; /* kill double-tap-to-zoom so mis-taps don't zoom the app */
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.visually-hidden, .visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* ---------- header ---------- */
.app-head { display: flex; flex-direction: column; gap: 8px; }

.meal-picker select {
  width: 100%;
  min-height: var(--tap);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 40px 0 14px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---------- config chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip-x {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 2px 2px 2px 4px;
  margin-left: 2px;
  cursor: pointer;
  opacity: .7;
}
.chip-x:hover { opacity: 1; }

/* the save action, same footprint as a preset chip but visually an action */
.chip-save { border-style: dashed; color: var(--accent-text); background: transparent; }
.chip-save:hover { border-color: var(--accent); }

/* ---------- total ---------- */
.total-row {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  gap: 10px;
  align-items: center;
}

.total-value { text-align: center; }

.total-num {
  width: 100%;
  text-align: center;
  font-size: 34px;
  font-weight: 700;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.total-value .unit {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- steppers ---------- */
.step {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid transparent;
  background: var(--accent-soft);   /* tinted fill so it reads as a button, not the number field */
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  -webkit-user-select: none;
  user-select: none;
}
.step:hover { border-color: var(--accent); }
.step:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: none; }
.step-lg { font-size: 16px; }

/* ---------- ingredient rows ---------- */
.row { padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }

.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.row-name { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; }
.row-emoji { margin-right: 7px; font-size: 18px; }

/* per-ingredient lock toggle */
.lock {
  flex: none;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
}
.lock.lock-on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.lock .ic-closed { display: none; }
.lock.lock-on .ic-open { display: none; }
.lock.lock-on .ic-closed { display: inline-block; }
/* grams is the hero number during meal prep */
.row-grams { display: inline-flex; align-items: baseline; gap: 3px; color: var(--accent-text); white-space: nowrap; }
.g-num { font-weight: 800; font-size: 26px; line-height: 1; }
.g-unit { font-weight: 700; font-size: 13px; }

.stepper {
  display: grid;
  grid-template-columns: var(--tap) 1fr auto var(--tap);
  gap: 8px;
  align-items: center;
}

.num {
  font-size: 16px; /* >=16px prevents iOS zoom-on-focus */
  font: inherit;
}

.row-cal {
  width: 100%;
  min-height: var(--tap);
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
}

/* locked ingredient: dim its steppers, keep the pinned value readable */
.step:disabled { opacity: .4; cursor: default; box-shadow: none; }
.row.locked .row-cal { border-color: var(--accent); background: var(--accent-soft); }
.row-cal:disabled { opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); }

.stepper .unit {
  font-size: 12px;
  color: var(--accent-text);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* strip native number spinners */
.num::-webkit-outer-spin-button,
.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num[type=number] { -moz-appearance: textfield; appearance: textfield; }

.bar { margin-top: 10px; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 999px; transition: width .12s ease; }

/* ---------- desktop niceties ---------- */
@media (min-width: 600px) {
  .app { padding-top: 28px; }
  .btn-save:hover, .chip:hover, .step:hover { filter: brightness(0.98); }
}
