/* Kitchen-printable recipe lookbook — hard one-page-per-recipe */
:root {
  --ink: #111;
  --muted: #444;
  --line: #ccc;
  --forest: #173f35;
  --coral: #e96343;
  --paper: #fff;
  --screen-bg: #f7f4ed;
  --sans: "DM Sans", system-ui, sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }

body.print-page {
  margin: 0;
  color: var(--ink);
  background: var(--screen-bg);
  font-family: var(--sans);
  line-height: 1.4;
  font-size: 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-family: var(--serif);
  font-size: 1.1rem;
}

.button {
  border: 0;
  border-radius: 3px;
  padding: 0.75rem 1.1rem;
  font: 700 0.82rem var(--sans);
  letter-spacing: 0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}
.button-primary { background: var(--coral); color: white; }
.button-outline {
  background: transparent;
  color: var(--forest);
  box-shadow: inset 0 0 0 1px var(--forest);
}

.print-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.print-chrome-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.print-chrome-actions { display: flex; gap: 0.6rem; }

.print-root {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2rem) 3rem;
}

.print-loading,
.print-message {
  background: var(--paper);
  padding: 1.5rem;
  border: 1px solid var(--line);
}
.print-message a {
  color: var(--forest);
  font-weight: 700;
}

/* Screen preview mimics letter page */
.print-card {
  background: var(--paper);
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
  overflow: hidden;
  position: relative;
}
.print-card:last-child { margin-bottom: 0; }

.print-card-frame {
  /* Screen preview ≈ letter printable area with breathing room (print uses 7.5×9.9in) */
  width: 100%;
  min-height: 520px;
  height: min(72vh, 9.9in);
  max-height: 9.9in;
  overflow: hidden;
  position: relative;
}

.print-card-inner {
  padding: 0.7rem 0.85rem 0.65rem;
  transform-origin: top left;
  width: 100%;
}

.print-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.print-night {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.print-card h1 {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.12;
  margin: 0.15rem 0 0.35rem;
  letter-spacing: -0.02em;
}
.print-kicker {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0;
}
.print-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
}
.print-chip {
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.12rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
}
.print-allium {
  border-left: 2px solid var(--ink);
  padding: 0.2rem 0.5rem;
  margin: 0.35rem 0 0.45rem;
  font-size: 0.75rem;
  line-height: 1.3;
}
.print-allium strong { font-weight: 700; }

.print-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.print-body {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 0.75rem;
  align-items: start;
}

.print-section { margin: 0; }
.print-section h2 {
  font: 700 0.65rem var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.3rem;
  color: var(--ink);
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--line);
}

.print-ingredients { columns: 1; }
.print-ingredient-group { margin-bottom: 0.4rem; }
.print-ingredient-group h3 {
  font: 700 0.78rem var(--sans);
  margin: 0 0 0.1rem;
}
.print-ingredient-group ul,
.print-footer ul {
  margin: 0.1rem 0 0;
  padding-left: 1rem;
}
.print-ingredient-group li {
  font-size: 0.78rem;
  line-height: 1.28;
  margin: 0.08rem 0;
}

.print-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: print-step;
}
.print-steps li {
  counter-increment: print-step;
  display: grid;
  grid-template-columns: 1.15rem 1fr;
  gap: 0.35rem;
  margin: 0.28rem 0;
  font-size: 0.78rem;
  line-height: 1.3;
}
.print-steps li::before {
  content: counter(print-step);
  width: 1.1rem;
  height: 1.1rem;
  border: 1.25px solid var(--ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  margin-top: 0.05rem;
}

.print-footer {
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.print-footer h3 {
  font: 700 0.62rem var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.15rem;
}
.print-footer li {
  font-size: 0.72rem;
  line-height: 1.28;
  margin: 0.05rem 0;
}
.print-footer-solo { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .print-body { grid-template-columns: 1fr; }
  .print-footer { grid-template-columns: 1fr; }
  .print-thumb { display: none; }
  .print-card-frame { height: auto; max-height: none; }
}

@media print {
  @page {
    size: letter portrait;
    /* 0.45in leaves breathing room vs exact 0.4in + 10.2in frame (rounding → blank page 2) */
    margin: 0.45in;
  }

  html, body.print-page {
    background: white !important;
    color: #000 !important;
    font-size: 9.5pt;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    /* Do NOT overflow:hidden on body in week mode — clips later pages */
  }

  /* Single-meal only: clip any stray trailing overflow that could invent page 2 */
  body.print-page.print-single {
    overflow: hidden;
  }

  .screen-only { display: none !important; }

  .print-root {
    max-width: none;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-card {
    border: 0;
    margin: 0 !important;
    padding: 0 !important;
    background: white;
    max-height: 9.9in;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* Only force page breaks BETWEEN cards — never after the last (avoids blank trailing page) */
  .print-card:not(:last-child) {
    page-break-after: always;
    break-after: page;
  }
  .print-card:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  /*
   * Printable area: letter 11in − 2×0.45in = 10.1in tall, 8.5 − 0.9 = 7.6in wide.
   * height:auto so JS-set visual height wins; max-height caps at one side.
   * Do NOT force a full-page 9.9in box — that + unscaled transform layout invents blank page 2.
   */
  .print-card-frame {
    width: 7.5in;
    height: auto;
    max-height: 9.9in;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  .print-card-inner {
    padding: 0;
  }

  .print-kicker { color: #000; }
  .print-chip {
    border-color: #000;
    background: transparent;
  }
  .print-allium {
    border-left-color: #000;
    background: transparent;
  }
  .print-steps li::before {
    border-color: #000;
    color: #000;
    background: transparent;
  }

  .print-thumb { display: none !important; }
  a { color: inherit; text-decoration: none; }

  .print-root > .print-card:last-child,
  .print-root {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
  }
}
