/* ── Cook mode ─────────────────────────────────────────────────────────────
   Full-screen, one-step-at-a-time cooking view (see cook-mode.js).
   Uses the site's existing colors and fonts from styles.css.
   Every rule is scoped under .cm / .cook-* so nothing else on the site changes. */

/* "Start cooking" button on recipe pages */
.cook-start-row { margin: -0.2rem 0 1.4rem; display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.cook-start {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 48px; padding: 0.7rem 1.5rem;
  font-size: 1.05rem; font-weight: 600;
  box-shadow: var(--shadow);
}
.cook-start-note { color: var(--text-light); font-size: 0.88rem; }

/* Lock the page behind the overlay */
html.cm-open, html.cm-open body { overflow: hidden; }

.cm {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.cm button { font-family: inherit; }
.cm :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.cm-top {
  display: flex; align-items: center; gap: 0.5rem;
  padding: calc(0.4rem + env(safe-area-inset-top)) 0.6rem 0.4rem;
  background: var(--cream); border-bottom: 3px solid var(--accent);
}
.cm-top-title {
  flex: 1; min-width: 0; text-align: center;
  font-family: 'Lora', Georgia, serif; font-weight: 600; color: var(--primary);
  font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-topbtn {
  min-height: 44px; min-width: 44px; padding: 0 0.8rem;
  border: none; background: transparent; border-radius: 999px;
  color: var(--sage); font-size: 0.95rem; font-weight: 500; cursor: pointer;
}
.cm-topbtn:hover { color: var(--primary); background: var(--cream-dk); }

/* Progress */
.cm-progress { padding: 0.7rem 1.2rem 0.2rem; max-width: 760px; width: 100%; margin: 0 auto; }
.cm-progress-label { font-size: 0.85rem; color: var(--text-light); font-weight: 500; margin-bottom: 0.35rem; }
.cm-bar { height: 6px; background: var(--cream-dk); border-radius: 999px; overflow: hidden; }
.cm-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.25s ease; }

/* Step area */
.cm-stage { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0.6rem 1.2rem 5.5rem; }
.cm-stage:focus { outline: none; }
.cm-step { max-width: 720px; margin: 0 auto; }
.cm-eyebrow {
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sage); font-weight: 600; margin: 0.6rem 0 0.2rem;
}
.cm-step-title {
  font-family: 'Lora', Georgia, serif; color: var(--accent-dk);
  font-size: 1.75rem; line-height: 1.2; margin: 0.5rem 0 0.7rem;
}
.cm-step-title:focus { outline: none; }
.cm-step-text { font-size: 1.3rem; line-height: 1.6; margin: 0 0 1rem; }
.cm-scaled { background: #F7EBD3; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.cm-step-text a, .cm-tip a, .cm-cue a, .cm-note a { color: var(--primary); border-bottom: 1px solid var(--accent); }
.cm-tip, .cm-cue, .cm-batch {
  font-size: 1.05rem; line-height: 1.5; margin: 0 0 0.8rem;
  padding: 0.7rem 0.9rem; border-radius: 10px;
}
.cm-tip { background: var(--cream); border-left: 4px solid var(--accent); }
.cm-cue { background: #F3F5EE; border-left: 4px solid var(--sage); }
.cm-batch { background: #FBEFEC; border-left: 4px solid var(--primary); }

/* Ingredients for this step */
.cm-ings {
  background: white; border: 1px solid var(--cream-dk); border-radius: var(--radius);
  padding: 0.8rem 1rem 0.5rem; margin: 1.2rem 0; box-shadow: var(--shadow);
}
.cm-ings h3 { font-size: 1.05rem; color: var(--primary); margin: 0 0 0.3rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cm-scale-tag {
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 600;
  background: var(--accent); color: white; padding: 2px 9px; border-radius: 999px;
}
.cm-ings ul, .cm-sheet-list { list-style: none; margin: 0; padding: 0; }
.cm-ings li, .cm-sheet-list li:not(.cm-group) { display: flex; align-items: center; gap: 0.7rem; border-top: 1px solid var(--cream-dk); }
.cm-ings li:first-child { border-top: none; }
.cm-ings input, .cm-sheet-list input {
  width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--primary); cursor: pointer;
}
.cm-ings label, .cm-sheet-list label { flex: 1; padding: 0.65rem 0; min-height: 44px; font-size: 1.12rem; line-height: 1.4; cursor: pointer; display: flex; align-items: center; }
li.is-checked label { color: var(--text-light); text-decoration: line-through; text-decoration-color: var(--accent); }

/* Timer buttons in a step */
.cm-timers { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; margin: 1.2rem 0 0.5rem; }
.cm-timer-btn {
  min-height: 52px; padding: 0.7rem 1.4rem; border: none; border-radius: 999px;
  background: var(--primary); color: white; font-size: 1.08rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
.cm-timer-btn:hover { background: var(--primary-dk); }
.cm-timer-btn.is-running { background: white; color: var(--primary); border: 2px solid var(--primary); }
.cm-phone-hint { margin: 0.2rem 0 0; font-size: 0.98rem; color: var(--text-light); font-style: italic; }

/* Resume banner */
.cm-resume {
  max-width: 720px; margin: 0.4rem auto 0.4rem; display: flex; align-items: center; gap: 0.2rem;
  background: var(--cream); border: 1px solid var(--cream-dk); border-radius: 10px; padding: 0.4rem 0.4rem 0.4rem 0.9rem; font-size: 0.95rem;
}
.cm-resume span { flex: 1; min-width: 0; }
.cm-resume button {
  min-height: 44px; min-width: 44px; border: none; background: transparent; color: var(--primary);
  font-weight: 600; font-size: 0.95rem; cursor: pointer; border-radius: 999px; padding: 0 0.8rem;
}
.cm-resume button:hover { background: var(--cream-dk); }

/* Done screen */
.cm-done { text-align: center; padding-top: 1rem; }
.cm-done-mark { font-size: 3rem; }
.cm-notes { text-align: left; margin: 1.6rem 0 0; border-top: 1px solid var(--cream-dk); padding-top: 0.8rem; }
.cm-notes-head { font-size: 1.15rem; color: var(--sage); margin: 0 0 0.4rem; }
.cm-note h3 { font-size: 1.02rem; color: var(--primary); margin: 0.9rem 0 0.2rem; }
.cm-note p { font-size: 1.05rem; line-height: 1.55; margin: 0.3rem 0; }
.cm-done-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin: 1.6rem 0 0; }
.cm-btn {
  min-height: 48px; padding: 0.6rem 1.4rem; border-radius: 999px; border: none; cursor: pointer;
  background: var(--primary); color: white; font-size: 1rem; font-weight: 600;
}
.cm-btn:hover { background: var(--primary-dk); }
.cm-btn-ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--accent); }
.cm-btn-ghost:hover { background: var(--accent); color: white; }

/* Bottom dock: basket + timer tray + Back/Next */
.cm-dock { position: relative; background: var(--cream); border-top: 1px solid var(--cream-dk); }
.cm-basket {
  position: absolute; right: 16px; top: -70px;
  width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--accent);
  background: white; box-shadow: var(--shadow-lg); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-size: 1.45rem; line-height: 1;
}
.cm-basket:hover { border-color: var(--primary); }
.cm-basket-count { font-size: 0.66rem; font-weight: 600; color: var(--text-light); margin-top: 2px; }

.cm-tray { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.6rem 0.8rem 0; -webkit-overflow-scrolling: touch; }
.cm-tray[hidden] { display: none; }
.cm-chip {
  flex: none; display: flex; align-items: stretch; border-radius: 12px; overflow: hidden;
  background: white; border: 1.5px solid var(--cream-dk); box-shadow: var(--shadow);
}
.cm-chip button {
  min-height: 48px; min-width: 44px; border: none; background: transparent; cursor: pointer;
  color: var(--primary); font-size: 0.95rem; font-weight: 600; padding: 0 0.6rem;
}
.cm-chip button + button { border-left: 1px solid var(--cream-dk); }
.cm-chip button:hover { background: var(--cream); }
.cm-chip-main { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; padding: 0.3rem 0.8rem !important; max-width: 13rem; }
.cm-chip-label { font-size: 0.75rem; font-weight: 500; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.cm-chip-time { font-size: 1.15rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cm-chip.is-paused .cm-chip-time { color: var(--text-light); }
.cm-chip.is-done { border-color: var(--primary); background: #FBEFEC; }
.cm-chip.is-done .cm-chip-time { color: var(--primary); }
.cm-chip.is-ringing { animation: cm-ring 1s ease-in-out infinite; }

.cm-nav { display: flex; gap: 0.6rem; padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom)); }
.cm-navbtn {
  flex: 1; min-height: 56px; border-radius: 999px; cursor: pointer;
  font-size: 1.12rem; font-weight: 600;
}
.cm-prev { flex: 0 0 34%; background: white; color: var(--primary); border: 1.5px solid var(--accent); }
.cm-next { background: var(--primary); color: white; border: none; }
.cm-next:hover { background: var(--primary-dk); }
.cm-prev:disabled { opacity: 0.4; cursor: default; }

/* Timer-finished banner */
.cm-alerts { padding: 0 0.8rem; }
.cm-alert {
  max-width: 720px; margin: 0.5rem auto 0; display: flex; align-items: center; gap: 0.5rem;
  background: var(--primary); color: white; border-radius: 12px; padding: 0.5rem 0.5rem 0.5rem 1rem;
  box-shadow: var(--shadow-lg);
}
.cm-alert div { flex: 1; display: flex; flex-direction: column; }
.cm-alert strong { font-size: 1.1rem; }
.cm-alert span { font-size: 0.92rem; opacity: 0.95; }
.cm-alert button {
  min-height: 44px; min-width: 52px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,0.7);
  background: transparent; color: white; font-weight: 600; font-size: 0.95rem; cursor: pointer; padding: 0 0.8rem;
}
.cm-alert button:last-child { background: white; color: var(--primary); border-color: white; }
.cm.is-flashing .cm-alert { animation: cm-flash 1s ease-in-out infinite; }

/* Ingredients sheet */
.cm-sheet { position: fixed; inset: 0; z-index: 1001; background: rgba(60, 46, 38, 0); transition: background 0.2s ease; display: flex; align-items: flex-end; }
.cm-sheet[hidden] { display: none; }
.cm-sheet.is-open { background: rgba(60, 46, 38, 0.4); }
.cm-sheet-panel {
  width: 100%; max-width: 760px; margin: 0 auto; max-height: 85vh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  padding: 0.6rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s ease;
}
.cm-sheet.is-open .cm-sheet-panel { transform: none; }
.cm-sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -0.6rem; background: var(--bg); padding: 0.4rem 0; z-index: 1; }
.cm-sheet-head h2 { font-size: 1.4rem; color: var(--primary); }
.cm-sheet-head .cm-topbtn { color: var(--primary); font-weight: 600; }
.cm-scale { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin: 0.3rem 0 0.6rem; }
.cm-scale > span { font-weight: 600; color: var(--text-light); margin-right: 0.3rem; font-size: 0.95rem; }
.cm-scale button {
  min-height: 44px; min-width: 52px; border-radius: 999px; border: 1.5px solid var(--accent);
  background: white; color: var(--primary); font-size: 1rem; font-weight: 600; cursor: pointer; padding: 0 0.7rem;
}
.cm-scale button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: white; }
.cm-scale button:disabled { opacity: 0.4; cursor: default; }
.cm-scale strong { min-width: 2.2rem; text-align: center; font-size: 1.25rem; }
.cm-yield { color: var(--text-light); font-size: 0.9rem; margin: 0 0 0.4rem; font-style: italic; }
.cm-sheet-list .cm-group {
  font-family: 'Lora', serif; font-weight: 600; color: var(--sage); font-size: 1rem; padding: 0.9rem 0 0.2rem;
}
.cm-uncheck { margin-top: 0.9rem; }

/* Toast when a timer finishes while cook mode is closed */
.cm-toasts { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1100; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; pointer-events: none; padding: 0 12px; }
.cm-toast {
  pointer-events: auto; width: 100%; max-width: 480px; display: flex; align-items: center; gap: 0.5rem;
  background: var(--primary); color: white; border-radius: 14px; padding: 0.6rem 0.5rem 0.6rem 1rem; box-shadow: var(--shadow-lg);
  animation: cm-flash 1s ease-in-out 4;
}
.cm-toast div { flex: 1; display: flex; flex-direction: column; }
.cm-toast span { font-size: 0.88rem; opacity: 0.95; }
.cm-toast a { color: var(--primary); background: white; border-radius: 999px; padding: 0.6rem 0.9rem; font-weight: 600; font-size: 0.92rem; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.cm-toast a:hover { text-decoration: none; }
.cm-toast button { min-width: 44px; min-height: 44px; border: none; background: transparent; color: white; font-size: 1.1rem; cursor: pointer; }

/* Screen-reader-only live regions */
.cm-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@keyframes cm-flash { 0%, 100% { filter: none; } 50% { filter: brightness(1.25); transform: scale(1.01); } }
@keyframes cm-ring  { 0%, 100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 4px rgba(160, 74, 59, 0.35); } }

@media (prefers-reduced-motion: reduce) {
  .cm *, .cm-toast { animation: none !important; transition: none !important; }
}

/* Larger screens: a bit more breathing room */
@media (min-width: 700px) {
  .cm-step-title { font-size: 2.1rem; }
  .cm-step-text { font-size: 1.4rem; }
  .cm-nav { max-width: 760px; margin: 0 auto; }
  .cm-tray { justify-content: center; }
}
@media (max-width: 380px) {
  .cm-topbtn span { display: none; }
  .cm-step-text { font-size: 1.2rem; }
}
/* Batch buttons get their own row so all five fit on a small phone */
.cm-scale[role="group"] > span { flex-basis: 100%; margin: 0 0 0.1rem; }
