/* =====================================================================
   cooking.css — cooking-mode dedicated styles
   ---------------------------------------------------------------------
   Activated when JS sets <body class="cooking-mode-active">. Hides
   reading-mode chrome, shows the focused stage card, top bar, controls,
   and ingredients drawer.

   Intentionally NOT bundled with recipe.css — keeps reading-mode
   stylesheet clean and means cooking-mode CSS only loads where needed.
   ===================================================================== */

/* =====================================================================
   "Cook with me" entry button (visible in reading mode, inside the
   method section heading area)
   ===================================================================== */
.cook-with-me-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 500;
  color: var(--paper);
  background: var(--terracotta);
  border: none;
  padding: 0.85rem var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin: var(--space-md) auto var(--space-lg);
  display: flex;
  width: fit-content;
  box-shadow: 0 4px 14px var(--shadow);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.cook-with-me-btn:hover {
  background: var(--terracotta-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--shadow-deep);
}

.cook-with-me-btn .cook-icon {
  font-style: normal;
  font-size: 1.3rem;
}

.cook-with-me-btn .cook-detail {
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.85;
  padding-left: 0.4rem;
  border-left: 1px solid rgba(255,255,255,0.4);
  margin-left: 0.3rem;
}

@media (max-width: 600px) {
  .cook-with-me-btn { font-size: 1rem; }
  .cook-with-me-btn .cook-detail { display: none; }
}

/* =====================================================================
   Cooking-mode chrome — entire fullscreen overlay
   ===================================================================== */
.cooking-mode-chrome {
  position: fixed;
  inset: 0;
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(200,150,90,0.05), transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(160,73,45,0.04), transparent 70%);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

body.cooking-mode-active .cooking-mode-chrome {
  display: flex;
}

/* When cooking mode is active, hide the reading-mode page entirely
   except the chrome overlay. Lock body scroll. */
body.cooking-mode-active {
  overflow: hidden;
}

body.cooking-mode-active > nav,
body.cooking-mode-active > .toc-panel,
body.cooking-mode-active > article,
body.cooking-mode-active > .recipe-prev-next,
body.cooking-mode-active > .site-footer,
body.cooking-mode-active > section {
  display: none !important;
}

/* =====================================================================
   Cooking-mode top bar — exit + counter + recipe title
   ===================================================================== */
.cm-top {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--paper-deep);
  border-bottom: 1px solid var(--rule-soft);
  box-shadow: 0 1px 4px var(--shadow);
}

.cm-exit {
  justify-self: start;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--terracotta);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.cm-exit:hover {
  background: rgba(160, 73, 45, 0.08);
}

.cm-exit .cm-arrow {
  font-style: normal;
  margin-right: 0.3rem;
}

.cm-counter {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
  white-space: nowrap;
}

.cm-counter .cm-current,
.cm-counter .cm-total {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--terracotta);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.cm-recipe-title {
  justify-self: end;
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 25vw;
}

@media (max-width: 720px) {
  .cm-top {
    grid-template-columns: auto 1fr auto;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
  }
  .cm-exit { font-size: 0.85rem; padding: 0.3rem 0.4rem; }
  .cm-exit > span:not(.cm-arrow) { display: none; }
  .cm-counter { font-size: 0.75rem; letter-spacing: 0.16em; }
  .cm-recipe-title { font-size: 0.85rem; max-width: 35vw; }
}

/* =====================================================================
   Stage card — the focus area
   ===================================================================== */
.cm-stage-wrap {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--gutter) var(--space-md);
}

.cm-stage {
  max-width: 720px;
  margin: 0 auto;
  opacity: 1;
}

.cm-stage-fade {
  animation: cmFade 0.22s ease-out;
}

@keyframes cmFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* The cloned .stage gets its reading-mode styles. Override for cooking
   mode: number + title sit close together (not a giant centred hero
   number floating in whitespace), prose flows immediately below. */
.cm-stage .stage {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
  padding: 0 0 var(--space-md);
  border: none;
  border-bottom: 1px solid var(--rule-soft);
  background: transparent;
  grid-template-columns: none;
  grid-gap: 0;
}

.cm-stage .stage-num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-style: italic;
  font-weight: 500;
  color: var(--terracotta);
  line-height: 1;
  flex-shrink: 0;
  text-align: center;
  background: none;
  width: auto;
  height: auto;
  padding: 0;
}

.cm-stage .stage-num small {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.2rem;
  font-style: normal;
}

.cm-stage .stage-content {
  flex: 1;
  min-width: 0;
}

.cm-stage .stage-content h4 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--space-md);
  line-height: 1.15;
  text-align: left;
}

.cm-stage .stage-content p {
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: var(--space-md);
}

.cm-stage .stage-content ol,
.cm-stage .stage-content ul {
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: var(--space-md);
  padding-left: var(--space-md);
}

.cm-stage .stage-content li {
  margin-bottom: var(--space-sm);
}

.cm-stage .stage-illustration {
  margin: var(--space-md) 0;
  max-width: 100%;
}

.cm-stage .stage-illustration img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 18px var(--shadow);
}

.cm-stage .stage-illustration figcaption {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .cm-stage-wrap { padding: var(--space-md) var(--space-md); }
  .cm-stage .stage {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  .cm-stage .stage-num { font-size: 2.4rem; }
  .cm-stage .stage-content h4 { font-size: 1.6rem; }
  .cm-stage .stage-content p,
  .cm-stage .stage-content ol,
  .cm-stage .stage-content ul { font-size: 1rem; }
}

/* =====================================================================
   Bottom controls — prev / ingredients / next
   ===================================================================== */
.cm-bottom {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--paper-deep);
  border-top: 1px solid var(--rule-soft);
  box-shadow: 0 -2px 8px var(--shadow);
}

.cm-prev,
.cm-next {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: none;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-md);
  padding: 0.7rem var(--space-sm);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

.cm-next {
  align-items: flex-end;
  text-align: right;
}

.cm-prev:hover:not(:disabled),
.cm-next:hover:not(:disabled) {
  border-color: var(--terracotta);
  background: rgba(160, 73, 45, 0.05);
  transform: translateY(-1px);
}

.cm-prev:disabled,
.cm-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.cm-prev .cm-dir,
.cm-next .cm-dir {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin-bottom: 0.2rem;
}

.cm-prev .cm-stage-name,
.cm-next .cm-stage-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cm-show-ingredients {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.7rem var(--space-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.cm-show-ingredients:hover {
  background: var(--ink-soft);
}

@media (max-width: 720px) {
  .cm-bottom { padding: var(--space-xs) var(--space-sm); }
  .cm-prev, .cm-next { padding: 0.5rem 0.6rem; }
  .cm-prev .cm-stage-name,
  .cm-next .cm-stage-name { font-size: 0.85rem; }
  .cm-prev .cm-dir, .cm-next .cm-dir { font-size: 0.6rem; }
  .cm-show-ingredients { font-size: 0.8rem; padding: 0.5rem 0.7rem; }
}

/* =====================================================================
   Ingredients drawer — slides up from bottom
   ===================================================================== */
.cm-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 31, 20, 0.4);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.cm-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cm-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--paper);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  z-index: 1200;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -8px 30px var(--shadow-deep);
}

.cm-drawer.open {
  transform: translateY(0);
}

.cm-drawer-handle {
  width: 48px;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  margin: 0.6rem auto 0;
  flex-shrink: 0;
}

.cm-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--rule-soft);
  flex-shrink: 0;
}

.cm-drawer-header h4 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--ink);
  margin: 0;
}

.cm-drawer-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.cm-drawer-close:hover {
  background: rgba(43, 31, 20, 0.08);
  color: var(--ink);
}

.cm-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* Inherit ingredient table styles inside the drawer (defined in recipe.css) */
.cm-drawer-body .ingredients-group { margin-bottom: var(--space-md); }
.cm-drawer-body table.ing { width: 100%; }
