/* Family recipe box (frontend/family-hub/recipes.html). Box-first, inside the
   shared family shell; the shell owns header, hero, footer and the colour tokens. */

.family-shell main.recipes-main {
  width: min(1120px, calc(100% - clamp(28px, 8vw, 104px)));
  max-width: none;
  padding: 32px 0 64px;
}

.recipes-status,
.recipe-muted {
  color: var(--ink-muted);
}

/* The hero introduces the box; a recipe leads with its own picture. */
.page-recipes.recipes-view-recipe .hero {
  display: none;
}

/* --- Box ------------------------------------------------------------------ */

.recipe-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.recipe-field {
  position: relative;
  flex: 1 1 220px;
  display: block;
}

.recipe-field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
  pointer-events: none;
}

.recipe-field-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.recipe-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 42px;
  border: 1px solid rgba(24, 38, 35, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  box-shadow: 0 8px 20px rgba(118, 101, 76, 0.06);
}

.recipe-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-pale);
}

.recipe-add-hint {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.recipe-chips {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recipe-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(24, 38, 35, 0.1);
  background: #fff;
  color: var(--ink-light);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.recipe-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.recipe-results {
  margin-top: 18px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(24, 38, 35, 0.08);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 10px 26px rgba(118, 101, 76, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(118, 101, 76, 0.12);
}

.recipe-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.recipe-card-image {
  aspect-ratio: 16 / 10;
  background: var(--paper-deep);
  overflow: hidden;
}

.recipe-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.recipe-card-image.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
}

.recipe-card-body {
  padding: 16px 16px 18px;
}

.recipe-card-body h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 700;
}

.recipe-card-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.recipe-empty {
  text-align: center;
  padding: 48px 24px;
  background: #fff;
  border: 1px dashed rgba(24, 38, 35, 0.16);
  border-radius: 8px;
}

.recipe-empty h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  margin: 0 0 8px;
}

.recipe-empty p {
  margin: 0 0 18px;
  color: var(--ink-light);
}

.recipe-empty p:last-child {
  margin-bottom: 0;
}

/* --- Buttons ----------------------------------------------------------------- */

.btn-family {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-family-primary {
  background: var(--accent);
  color: #fff;
}

.btn-family-primary:hover {
  background: #b36d5a;
}

.btn-family-secondary {
  background: #fff;
  color: var(--ink);
  border-color: rgba(24, 38, 35, 0.12);
}

/* --- One recipe ------------------------------------------------------------- */

.recipe-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  color: var(--ink-light);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}

.recipe-detail-hero {
  margin-bottom: 22px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-deep);
}

.recipe-detail-hero img {
  display: block;
  width: 100%;
  height: min(52vw, 420px);
  object-fit: cover;
}

.recipe-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.recipe-detail-title {
  margin: 0 0 12px;
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  color: var(--ink);
}

.recipe-description {
  max-width: 42rem;
  margin: 0;
  color: var(--ink-light);
  line-height: 1.6;
}

.recipe-delete {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

.recipe-delete:hover {
  color: #8f5344;
  border-color: rgba(143, 83, 68, 0.25);
}

.recipe-delete svg {
  width: 20px;
  height: 20px;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 22px;
  padding: 14px 0;
  border-top: 1px solid rgba(24, 38, 35, 0.08);
  border-bottom: 1px solid rgba(24, 38, 35, 0.08);
  color: var(--ink-light);
  font-size: 0.92rem;
  font-weight: 600;
}

.recipe-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding: 10px 16px;
  border: 1px solid rgba(24, 38, 35, 0.08);
  border-radius: 8px;
  background: #fff;
}

.recipe-scale-note {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.recipe-stepper-label {
  font-weight: 600;
}

.recipe-stepper-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recipe-stepper-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(24, 38, 35, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.recipe-stepper-count {
  min-width: 1.5rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.recipe-section {
  margin-top: 36px;
}

.recipe-section h2 {
  margin: 0 0 8px;
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
}

.ingredient-list,
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ingredient-list li,
.step-list li {
  padding: 12px 0;
  border-bottom: 1px solid rgba(24, 38, 35, 0.08);
  line-height: 1.55;
}

.step-list li {
  display: flex;
  gap: 14px;
}

/* Ingredient checklist (recipe view and cook-mode sheet): no dividers; the whole
   row is the tap target and a checked line is struck through. */
.ingredient-list.ingredient-checklist li {
  padding: 0;
  border-bottom: none;
}

.ingredient-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 0;
  line-height: 1.5;
  cursor: pointer;
}

.ingredient-box {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.is-checked .ingredient-check span {
  text-decoration: line-through;
  color: var(--ink-muted);
}

.ingredient-uncheck {
  min-height: 44px;
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-light);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.ingredient-uncheck[hidden] {
  display: none;
}

.ingredient-box:focus-visible,
.ingredient-uncheck:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.step-list p {
  margin: 0;
}

.step-num {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-pale);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.step-list .step-timer {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.recipe-error {
  margin: 18px 0 0;
  color: #8f5344;
  font-size: 0.92rem;
}

.recipe-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

/* --- Cook mode: full screen on paper, chrome hidden ------------------------------ */

body.recipes-cooking {
  overflow: hidden;
}

body.recipes-cooking > :not(.cook-view) {
  display: none !important;
}

.cook-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* Keep controls clear of the notch and home bar, including landscape iPhone. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
}

.cook-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
}

.cook-progress-wrap {
  flex: 1;
}

.cook-progress {
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #e6e0d6;
}

.cook-progress-fill {
  height: 100%;
  background: var(--plum);
  transition: width 0.3s ease;
}

.cook-label {
  margin: 8px 0 0;
  color: var(--ink-light);
  font-size: 0.9rem;
  font-weight: 500;
}

.cook-label-page {
  white-space: nowrap;
}

.cook-ingredients-btn {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(24, 38, 35, 0.18);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.cook-close {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-light);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.cook-timer-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.cook-timer-strip[hidden] {
  display: none;
}

.cook-strip-btn {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent-pale);
  color: var(--plum);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  cursor: pointer;
}

.cook-strip-btn.is-done {
  background: var(--gold);
  color: var(--ink);
}

/* Long steps scroll from their first line; short ones sit centered. The auto
   margins center the content only when there is room, unlike justify-content.
   The step reads as a left-aligned column, one sentence per line. */
.cook-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  overflow-y: auto;
  /* A tap here is Next (recipes-cook.js); no grey flash on iPhone. */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cook-content {
  margin-block: auto;
  flex-shrink: 0;
  width: 100%;
  max-width: 36rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
  padding: 16px 0;
}

.cook-instruction {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.35;
}

.cook-sentence {
  display: block;
  text-wrap: pretty;
}

.cook-sentence + .cook-sentence {
  margin-top: 0.9em;
}

/* A long step split across pages (recipes-cook.js) says so under its text. */
.cook-continues {
  display: block;
  margin-top: 1.1rem;
  color: var(--ink-light);
  font-size: 0.95rem;
  font-weight: 500;
}

.cook-instruction:focus {
  outline: none;
}

/* The timer sits centred under the step, on the page itself. */
.cook-timer {
  align-self: center;
  text-align: center;
}

.cook-timer[hidden] {
  display: none;
}

.cook-timer-start {
  min-height: 56px;
  padding: 0 28px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(118, 101, 76, 0.18);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
}

.cook-clock {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.cook-clock.is-done {
  font-size: 2rem;
  color: var(--plum);
}

/* Wider screens: a wider column, larger step text and clock. After the base rules so it wins. */
@media (min-width: 700px) {
  .cook-content {
    max-width: 44rem;
  }

  .cook-instruction {
    font-size: 1.85rem;
  }

  .cook-clock {
    font-size: 4.5rem;
  }
}

.cook-timer-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.cook-timer-btn {
  min-width: 96px;
  min-height: 56px;
  border: none;
  border-radius: 8px;
  background: #ece6db;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.cook-bottom {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border-top: 1px solid rgba(24, 38, 35, 0.12);
  background: rgba(24, 38, 35, 0.12);
}

.cook-nav {
  min-height: 88px;
  border: none;
  background: #ece6db;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}

.cook-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.cook-next {
  background: var(--plum);
  color: #fff;
}

.cook-next.is-done {
  background: var(--ink);
}

.cook-announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Ingredients sheet: slides over the step, scrolls on its own. */
.cook-sheet {
  position: absolute;
  inset: auto 0 0;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-radius: 12px 12px 0 0;
  background: #fbfaf7;
  color: var(--ink);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.35);
}

.cook-sheet[hidden] {
  display: none;
}

.cook-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 8px;
}

.cook-sheet-head h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
}

.cook-sheet-close {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(24, 38, 35, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.cook-sheet-body {
  overflow-y: auto;
  padding: 0 20px 20px;
}

.cook-sheet-serves,
.cook-sheet-note {
  margin: 0 0 8px;
  color: var(--ink-light);
  font-size: 0.95rem;
}

.cook-sheet .ingredient-check {
  font-size: 1.1rem;
}

/* Step card: the ingredients this step needs. Above the step on a phone, so a long
   step never pushes it out of view (gather, then do); beside it on wide or landscape
   screens (below). The DOM keeps the step first for screen readers. A tap on it
   never advances the step. */
.cook-step-card {
  order: -1;
  box-sizing: border-box;
  padding: 14px 16px 4px;
  border: 1px solid rgba(24, 38, 35, 0.1);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(118, 101, 76, 0.12);
  cursor: default;
}

.cook-step-card[hidden] {
  display: none;
}

.cook-step-card-title {
  margin: 0 0 4px;
  color: var(--ink-light);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cook-step-card-serves {
  margin: 4px 0 0;
  color: var(--ink-light);
  font-size: 0.9rem;
}

.cook-step-card-serves[hidden] {
  display: none;
}

.cook-step-card .ingredient-list {
  margin: 0;
}

.cook-step-card .ingredient-check {
  font-size: 1.05rem;
}

@media (min-width: 900px), (orientation: landscape) and (min-width: 640px) {
  .cook-content.has-step-card {
    max-width: 68rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
    grid-template-areas:
      "instruction card"
      "timer card";
    align-items: start;
    column-gap: 48px;
    row-gap: 28px;
  }

  .cook-content.has-step-card .cook-instruction {
    grid-area: instruction;
  }

  .cook-content.has-step-card .cook-timer {
    grid-area: timer;
    justify-self: center;
  }

  /* Stays in view while a long step scrolls. */
  .cook-content.has-step-card .cook-step-card {
    grid-area: card;
    position: sticky;
    top: 16px;
  }
}

/* Laptop and tablet: card text big enough to read from the counter. */
@media (min-width: 900px) {
  .cook-content.has-step-card {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  }

  .cook-step-card-title {
    font-size: 0.85rem;
  }

  .cook-step-card .ingredient-check {
    font-size: 1.15rem;
  }
}

/* Landscape phone: a narrower card and gap so the step keeps its width. */
@media (orientation: landscape) and (max-height: 500px) {
  .cook-content.has-step-card {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem);
    column-gap: 24px;
  }

  .cook-step-card .ingredient-check {
    font-size: 1rem;
  }

  /* About 220px of height for the step: smaller text so one long sentence fits. */
  .cook-instruction {
    font-size: 1.3rem;
  }
}

/* --- Pressed, focus and disabled states ---------------------------------------- */

.btn-family:active,
.recipe-chip:active,
.recipe-stepper-btn:active,
.recipe-delete:active,
.cook-nav:active:not(:disabled),
.cook-timer-start:active,
.cook-timer-btn:active,
.cook-strip-btn:active,
.cook-ingredients-btn:active,
.cook-sheet-close:active,
.cook-close:active {
  transform: translateY(1px);
}

.recipe-chip:focus-visible,
.recipe-stepper-btn:focus-visible,
.recipe-delete:focus-visible,
.btn-family:focus-visible,
.recipe-back:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cook-view button:focus-visible {
  outline: 3px solid var(--plum);
  outline-offset: -3px;
}

/* The plum Next button takes a gold ring so focus still shows on it. */
.cook-view .cook-next:focus-visible {
  outline-color: var(--gold);
}

.cook-sheet button:focus-visible {
  outline-color: var(--accent);
}

.recipe-delete:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- Widths ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .recipe-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .family-shell main.recipes-main {
    width: min(calc(100% - 28px), 640px);
    padding-top: 24px;
  }

  .recipe-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .recipe-card,
  .cook-progress-fill {
    transition: none;
  }

  .recipe-card:hover {
    transform: none;
  }
}
