/* Recipes library, recipe builder and brew-day planner.
   Every selector is scoped under .recipes-view, .recipe-edit or .brewday-view;
   the shared vocabulary (cards, metrics, phase, check, notice …) lives in app.css. */

/* ---------- shared bits ---------- */
.recipes-view .grow,
.brewday-view .grow { flex: 1; min-width: 0; }
.recipes-view table.compact th, .recipes-view table.compact td,
.recipe-edit table.compact th, .recipe-edit table.compact td { padding: 6px 5px; }
.recipes-view .recipe-tags,
.brewday-view .recipe-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

/* ---------- recipes: list ---------- */
.recipes-view .recipe-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 2px 14px; }
.recipes-view .search-box { position: relative; flex: 1 1 260px; max-width: 460px; }
.recipes-view .search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.recipes-view .search-box input { padding-left: 36px; }
.recipes-view .recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 13px; }
.recipes-view .recipe-card { display: block; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.recipes-view .recipe-card:hover { border-color: #c8c2b6; transform: translateY(-1px); }
.recipes-view .recipe-card h3 { color: var(--ink); }
.recipes-view .recipe-card .status-pill { flex: none; }
.recipes-view .recipe-metrics { margin-top: 13px; }
.recipes-view .recipe-metrics .metric strong { font-size: 18px; }

/* ---------- recipes: detail ---------- */
.recipes-view .recipe-sheet h2 { margin: 0 0 4px; font-size: 24px; line-height: 1.12; }
.recipes-view .recipe-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: flex-start; }
.recipes-view .recipe-actions { margin: 14px 0 6px; }
.recipes-view .recipe-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; }
.recipes-view .recipe-facts b { text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; margin-right: 4px; }
.recipes-view .recipe-h { margin: 18px 0 4px; }
.recipes-view .recipe-ingredients td:last-child { text-align: right; }
.recipes-view .recipe-steps { margin: 0; padding-left: 22px; }
.recipes-view .recipe-steps li { padding: 5px 0; border-bottom: 1px dashed var(--line2); }
.recipes-view .recipe-steps li:last-child { border-bottom: 0; }
.recipes-view .recipe-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.recipes-view .recipe-lower { margin-top: 13px; }
.recipes-view .recipe-lower .grid { align-items: start; }
.recipes-view .recipe-stats .metrics { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.recipes-view .recipe-stats h4 { margin: 14px 0 8px; }
.recipes-view .recipe-notes { margin: 8px 0 0; padding-left: 18px; }
.recipes-view .schedule-h { margin: 12px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.recipes-view .schedule-list { list-style: none; margin: 0; padding: 0; }
.recipes-view .schedule-list li {
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px dashed var(--line2);
}
.recipes-view .schedule-list li:last-child { border-bottom: 0; }
.recipes-view .schedule-list .when { font-weight: 800; font-size: 12.5px; color: var(--green); white-space: nowrap; }
.recipes-view .schedule-list .badge { vertical-align: 1px; }
.recipes-view .list-item { text-decoration: none; color: inherit; align-items: center; }

@media (max-width: 520px) {
  .recipes-view .recipe-pills { justify-content: flex-start; }
  .recipes-view .recipe-sheet .batch-head { flex-direction: column; }
}

/* ---------- recipe builder ---------- */
.recipe-edit .ed-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.recipe-edit .ed-main { display: grid; gap: 13px; min-width: 0; }
.recipe-edit .ed-main > .card > h3 { margin-bottom: 10px; }
.recipe-edit h3 label { font: inherit; color: inherit; }
.recipe-edit span.field { display: block; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 5px; }
.recipe-edit h4 { margin: 14px 0 6px; font-size: 14px; }
.recipe-edit [aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px rgba(151, 61, 57, .12); }
.recipe-edit input.stale { border-color: var(--gold); background: var(--goldSoft); }
.recipe-edit .notice ul { margin: 6px 0 0; padding-left: 18px; }

.recipe-edit .ed-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.recipe-edit .ed-swatch { position: relative; cursor: pointer; line-height: 0; }
.recipe-edit .ed-swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.recipe-edit .ed-swatch input + span {
  display: inline-block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.recipe-edit .ed-swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.recipe-edit .ed-swatch input:focus-visible + span { outline: 3px solid rgba(47, 91, 70, .45); outline-offset: 3px; }

.recipe-edit .ed-list:empty { display: none; }
.recipe-edit .ed-row { border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px 12px; background: var(--panel2); margin-bottom: 8px; }
.recipe-edit .ed-row.flash { animation: ed-flash 1.2s ease-out; }
@keyframes ed-flash { 0% { background: var(--goldSoft); border-color: var(--gold); } 100% { background: var(--panel2); border-color: var(--line); } }
.recipe-edit .ed-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.recipe-edit .ed-num {
  flex: none; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--greenSoft); color: var(--green);
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.recipe-edit .ed-row-title { flex: 1; min-width: 0; font-weight: 800; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-edit label.ed-row-title { margin: 0; color: var(--ink); font-size: 13.5px; }
.recipe-edit .ed-tools { display: flex; gap: 4px; flex: none; }
.recipe-edit .ed-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; font-weight: 800; font-size: 15px; color: var(--ink); padding: 0;
}
.recipe-edit .ed-btn:hover { border-color: #c8c2b6; }
.recipe-edit .ed-btn.danger { color: var(--red); }
.recipe-edit .ed-btn .icon { width: 16px; height: 16px; }
.recipe-edit .ed-add { margin-top: 4px; }
.recipe-edit .step-row textarea { min-height: 58px; }

.recipe-edit .ing-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; grid-auto-flow: dense; }
.recipe-edit .ing-grid .f-name { grid-column: span 3; }
.recipe-edit .ing-grid .f-pick { grid-column: span 2; }
.recipe-edit .ing-grid .f-qty,
.recipe-edit .ing-grid .f-note { grid-column: span 3; }
.recipe-edit .ing-grid .f-opt { display: flex; align-items: flex-end; padding-bottom: 10px; }
.recipe-edit .sched-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; }
.recipe-edit .sched-grid .f-title { grid-column: span 4; }
.recipe-edit .sched-grid .f-anchor,
.recipe-edit .sched-grid .f-kind { grid-column: span 2; }
.recipe-edit .sched-grid .f-notes { grid-column: span 3; }
.recipe-edit .sched-grid .f-off { grid-column: span 1; }

.recipe-edit .ed-live h3 { margin: 0; }
.recipe-edit .ed-live:focus { outline: none; }
.recipe-edit .ed-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recipe-edit .ed-metrics .metric strong { font-size: 19px; }
.recipe-edit .ed-points { margin-top: 10px; font-size: 13px; }
.recipe-edit .ed-points td:last-child { text-align: right; }
.recipe-edit .ed-points .total td { font-weight: 800; border-top: 1px solid var(--line); }
.recipe-edit .ed-honey {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--goldSoft); border: 1px solid #efd9a3;
}
.recipe-edit .ed-honey b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--gold); }
.recipe-edit .ed-honey span { display: block; font-weight: 850; font-size: 17px; }
.recipe-edit .ed-honey small { color: var(--muted); font-size: 11.5px; }
.recipe-edit .ed-nutrients { font-size: 13.5px; display: grid; gap: 5px; margin-bottom: 8px; }
.recipe-edit .ed-nutrients ul { margin: 0; }
.recipe-edit .ed-additions { list-style: none; padding: 0; margin: 0; }
.recipe-edit .ed-additions li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line2); }
.recipe-edit .ed-warnings { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.recipe-edit .ed-warnings li { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; padding: 7px 9px; border-radius: 10px; background: var(--redSoft); color: #6b2b28; }
.recipe-edit .ed-warnings .icon { color: var(--red); margin-top: 1px; }
.recipe-edit .ed-ok { display: flex; gap: 6px; align-items: center; color: var(--green); font-weight: 800; margin: 12px 0 0; }
.recipe-edit .ed-bottom { margin-top: 2px; }

.recipe-edit .ed-minibar {
  position: sticky; bottom: calc(var(--navH) + env(safe-area-inset-bottom) + 8px); z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px;
  padding: 9px 14px; border-radius: 13px; background: #1d231f; color: #fff; box-shadow: var(--shadow); font-size: 13px;
}
.recipe-edit .ed-minibar b { font-size: 15px; }
.recipe-edit .ed-minibar .link-btn { color: #fff; margin-left: auto; }

@media (min-width: 900px) {
  .recipe-edit .ed-minibar { bottom: 12px; }
}
@media (min-width: 1040px) {
  .recipe-edit .ed-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .recipe-edit .ed-side { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; border-radius: var(--radius); }
  .recipe-edit .ed-minibar { display: none; }
}
@media (max-width: 640px) {
  .recipe-edit .ing-grid, .recipe-edit .sched-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recipe-edit .ing-grid > *, .recipe-edit .sched-grid > * { grid-column: span 1; }
  .recipe-edit .ing-grid .f-name, .recipe-edit .ing-grid .f-pick, .recipe-edit .ing-grid .f-qty, .recipe-edit .ing-grid .f-note,
  .recipe-edit .sched-grid .f-title, .recipe-edit .sched-grid .f-notes { grid-column: 1 / -1; }
  .recipe-edit .ing-grid .f-opt { padding-bottom: 4px; }
  .recipe-edit .ed-row { padding: 9px 10px 11px; }
}

/* ---------- brew day ---------- */
.brewday-view .brewday-card { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
.brewday-view .brewday-card:hover { border-color: #c8c2b6; }
.brewday-view .brewday-card .pill .icon { width: 14px; height: 14px; }
.brewday-view .brewday-hero { margin-bottom: 12px; }
.brewday-view .bd-batches { margin: 0 0 12px; flex-wrap: wrap; overflow: visible; }
.brewday-view .bd-batches .badge { margin-left: 2px; }
.brewday-view .bd-missing { color: var(--muted); border-style: dashed; }
.brewday-view .bd-actions { margin: 0 0 13px; }
.brewday-view .bd-pull td:nth-child(2) { white-space: normal; }
.brewday-view .mixer-grid .card h3 { font-size: 16.5px; }
.brewday-view .mixbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 13px; padding: 13px; margin: 10px 0 0; }
.brewday-view .mixbox p { margin: 8px 0 0; }
.brewday-view .timer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 13px; padding: 13px; background: #fff;
}
.brewday-view .timer.running { border-color: #e2c27c; background: var(--goldSoft); }
.brewday-view .timer-display { font: 800 34px/1.1 var(--mono); letter-spacing: .02em; }
.brewday-view .timer-controls { align-items: flex-end; }
.brewday-view .timer-min { width: 92px; }
.brewday-view .timer-min label.field { margin-bottom: 3px; }
.brewday-view .bd-checklist .check { cursor: pointer; }
.brewday-view .bd-checklist .who { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.brewday-view textarea#bdNotes { min-height: 96px; }

@media (max-width: 520px) {
  .brewday-view .timer { flex-direction: column; align-items: stretch; }
  .brewday-view .timer-controls { flex-wrap: nowrap; gap: 7px; }
  .brewday-view .timer-controls .btn { flex: 1 1 auto; white-space: nowrap; padding-left: 10px; padding-right: 10px; }
  .brewday-view .timer-min { width: 64px; flex: none; }
  .brewday-view .timer-display { font-size: 40px; }
}

/* ---------- production sheet (views/sheet.js: recipes, #/sheet/:id) ---------- */
.prod-sheet { display: grid; gap: 10px; }
.ps-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); }
.ps-sum { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line2); font-size: 14px; }
.ps-sum b { font-size: 11px; letter-spacing: .04em; color: var(--muted); padding-top: 2px; }
.ps-sum span { font-weight: 700; overflow-wrap: anywhere; }
.ps-sum:first-child { grid-column: 1 / -1; background: var(--panel3); }
.ps-sum:first-child span { font-size: 17px; }
.ps-section { margin: 0; }
.ps-section > summary { font-size: 15px; letter-spacing: .03em; }
.ps-body { display: grid; gap: 12px; }
.ps-block h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .06em; color: var(--muted); }
.ps-check, .ps-steps, .ps-measure ul { margin: 0; padding-left: 0; }
.ps-check { list-style: none; display: grid; gap: 5px; }
.ps-check li { position: relative; padding-left: 26px; }
.ps-check li::before { content: ''; position: absolute; left: 0; top: 3px; width: 15px; height: 15px; border: 1.5px solid #9d988d; border-radius: 4px; background: #fff; }
.ps-steps { padding-left: 24px; display: grid; gap: 5px; }
.ps-steps li::marker { font-weight: 800; color: var(--green); }
.ps-measure { border: 1px solid var(--slate); background: var(--slateSoft); border-radius: 12px; padding: 10px 12px; }
.ps-measure h4 { color: var(--slate); display: flex; align-items: center; gap: 6px; }
.ps-measure ul { padding-left: 20px; display: grid; gap: 3px; }
.ps-note { margin: 0; }
.ps-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px; }
.ps-day { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel2); }
.ps-day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.ps-day p.mini { margin: 6px 0 0; }
.ps-splits { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ps-split { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--panel); display: grid; gap: 8px; align-content: start; }
.ps-split-head { display: flex; gap: 10px; align-items: center; }
.ps-key { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--green); color: #fff; font-weight: 900; font-size: 17px; }
.ps-dl { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 4px 8px; margin: 0; font-size: 14px; }
.ps-dl dt { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.ps-dl dd { margin: 0; }
.ps-split p.mini { margin: 0; }
.ps-now p { margin: 4px 0; }

/* ---------- master brew-day plan (views/brewday.js) ---------- */
.brewday-view .mp-phase { margin-bottom: 11px; border-left: 5px solid var(--green); }
.brewday-view .mp-phase.mp-complete { border-left-color: #b9c9bf; }
.brewday-view .mp-phase.mp-complete h3::after { content: ' ✓'; color: var(--green); }
.brewday-view .mp-phase h3 { margin-bottom: 4px; font-size: 16px; letter-spacing: .02em; }
.brewday-view .mp-phase > p.mini { margin: 0 0 8px; }
.brewday-view .mp-items .check { cursor: pointer; }
.brewday-view .mp-items .check .who { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.brewday-view .check.mp-adjust { background: var(--goldSoft); border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.brewday-view .mp-table { margin: 4px 0 10px; }
.brewday-view .mp-og { padding: 9px 0; border-bottom: 1px dashed var(--line2); }
.brewday-view .mp-og:last-child { border-bottom: 0; }
.brewday-view .mp-og-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.brewday-view .mp-og-row label.field { margin: 0; font-size: 14px; color: var(--ink); font-weight: 600; }
.brewday-view .mp-og-row input { width: 120px; flex: none; font-weight: 800; }
.brewday-view .mp-og.done .mp-og-row input { border-color: var(--green); background: var(--greenSoft); }
.brewday-view .mp-og-result { margin: 6px 0 0; font-size: 13px; }
.brewday-view .mp-og.mp-low .mp-og-result, .brewday-view .mp-og.mp-high .mp-og-result { color: var(--gold); }
.brewday-view .mp-brewmode { position: sticky; top: 64px; z-index: 20; border: 2px solid var(--green); box-shadow: 0 10px 28px rgba(20, 30, 24, .16); margin-bottom: 12px; }
.brewday-view .mp-brewmode h3 { margin: 2px 0 6px; font-size: 13px; letter-spacing: .08em; color: var(--green); }
.brewday-view .mp-brewmode h4 { margin: 12px 0 4px; font-size: 12px; letter-spacing: .08em; color: var(--muted); }
.brewday-view .mp-now > p { font-size: 18px; line-height: 1.35; margin: 0 0 10px; }
.brewday-view .mp-next { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: 14px; }

@media (max-width: 760px) {
  .ps-summary { grid-template-columns: 1fr; }
  .ps-sum { grid-template-columns: 112px minmax(0, 1fr); }
  .brewday-view .mp-og-row { flex-wrap: wrap; }
  .brewday-view .mp-brewmode { top: 58px; }
}

/* ---------- print ---------- */
@media print {
  .recipes-view .recipe-sheet, .recipes-view .card, .brewday-view .card { border-color: #bbb; }
  .recipes-view .recipe-sheet { border-top-width: 4px; }
  .recipes-view .grid, .brewday-view .grid { display: block; }
  .recipes-view .grid > *, .brewday-view .grid > * { margin-bottom: 10px; }
  .recipes-view .phase, .recipes-view .metric, .brewday-view .mixbox, .brewday-view .check { break-inside: avoid; }
  .recipes-view .card, .brewday-view .card { break-inside: auto; }
  .recipes-view tr, .brewday-view tr { break-inside: avoid; }
  .recipes-view .table-scroll, .brewday-view .table-scroll { overflow: visible; }
  .recipes-view .recipe-lower .list-item { border: 0; padding: 3px 0; }
  .recipes-view .search-box, .recipes-view .recipe-tools { display: none; }
  .brewday-view .timer-controls { display: none; }
  .brewday-view textarea#bdNotes { border: 0; padding: 0; resize: none; min-height: 0; }
  .ps-section > summary { list-style: none; }
  .ps-split, .ps-day, .ps-measure, .brewday-view .mp-og { break-inside: avoid; }
  .brewday-view .mp-brewmode { display: none; }
  .ps-key { background: none; color: #000; border: 1.5px solid #000; }
}
