/* =====================================================================
   Timothy Cunningham — Recipe Card Component
   Adapted from the TC recipe PDF template for web rendering.
   Loaded only on recipe pages via head.html conditional.
   ===================================================================== */

/* ===== Variables (inherit site accent, add recipe-specific tokens) ===== */
.rc {
  --rc-paper: #fcfbf7;
  --rc-ink: #1f1f1b;
  --rc-muted: #5e5a51;
  --rc-line: #d9d3c6;
  --rc-accent: var(--color-accent, #7a4b2a);
  --rc-accent-soft: #efe4da;
  --rc-sage: #707861;
  --rc-sage-soft: #edf0ea;
  --rc-shadow: rgba(0, 0, 0, 0.05);
  --rc-radius: 10px;
}

/* ===== Dark mode overrides ===== */
@media (prefers-color-scheme: dark) {
  .rc {
    --rc-paper: #1e1d1a;
    --rc-ink: #e8e6e1;
    --rc-muted: #a8a49b;
    --rc-line: #3d3a33;
    --rc-accent-soft: #2e2520;
    --rc-sage-soft: #232620;
    --rc-shadow: rgba(0, 0, 0, 0.2);
  }
}

/* ===== Root container ===== */
.rc {
  background: var(--rc-paper);
  color: var(--rc-ink);
  border: 1px solid var(--rc-line);
  border-radius: 12px;
  padding: 1.75rem 2rem 1.5rem;
  margin: 2.5rem 0;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ===== Brand bar ===== */
.rc-brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  border-bottom: 1.5px solid var(--rc-line);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.rc-brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rc-brand-mark {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--rc-accent);
  border-radius: 50%;
  color: var(--rc-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading, Georgia, serif);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.rc-brand-text small {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.65rem;
  color: var(--rc-muted);
  margin-bottom: 1px;
}

.rc-brand-text strong {
  display: block;
  font-size: 1rem;
  font-family: var(--font-heading, Georgia, serif);
  font-weight: 700;
}

.rc-brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Print button ===== */
.rc-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--rc-accent);
  color: #fff;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.rc-print-btn:hover {
  background: var(--color-accent-hover, #5a3a1e);
  transform: translateY(-1px);
}

.rc-print-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== Recipe header ===== */
.rc-head {
  margin-bottom: 1rem;
}

.rc-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--rc-accent);
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.rc h2.rc-title {
  font-family: var(--font-heading, Georgia, serif);
  font-size: 1.75rem;
  line-height: 1.15;
  margin: 0 0 0.5rem;
  font-weight: 700;
  border: none;
  padding: 0;
}

.rc-subtitle {
  font-size: 1rem;
  color: var(--rc-muted);
  margin: 0 0 0.5rem;
}

/* ===== Meta grid ===== */
.rc-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 1rem 0;
}

.rc-meta-card {
  border: 1px solid var(--rc-line);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--rc-radius);
  padding: 0.5rem 0.65rem;
}

@media (prefers-color-scheme: dark) {
  .rc-meta-card {
    background: rgba(255, 255, 255, 0.04);
  }
}

.rc-meta-card .rc-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--rc-muted);
  margin-bottom: 2px;
}

.rc-meta-card .rc-value {
  font-size: 0.9rem;
  font-weight: 700;
}

/* ===== Summary grid (intro + at-a-glance) ===== */
.rc-summary-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin: 1rem 0 1.25rem;
}

/* ===== Panels ===== */
.rc-panel {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius);
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 8px var(--rc-shadow);
}

@media (prefers-color-scheme: dark) {
  .rc-panel {
    background: rgba(255, 255, 255, 0.03);
  }
}

.rc-panel h3,
.rc-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 0.4rem;
  color: var(--rc-accent);
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
}

.rc-panel h4,
.rc-section h4 {
  font-family: var(--font-heading, Georgia, serif);
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}

/* ===== Quick facts (at-a-glance sidebar) ===== */
.rc-quick-facts {
  display: grid;
  gap: 0;
}

.rc-fact-row {
  border-top: 1px solid var(--rc-line);
  padding: 0.45rem 0;
}

.rc-fact-row:first-child {
  border-top: none;
  padding-top: 0;
}

.rc-fact-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--rc-muted);
}

.rc-fact-value {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

/* ===== Two-column layout ===== */
.rc-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 1rem;
}

/* ===== Ingredients ===== */
.rc-ingredients-list {
  list-style: none;
  margin: 0.25rem 0 0.5rem;
  padding: 0;
}

.rc-ingredients-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(217, 211, 198, 0.5);
  font-size: 0.9rem;
}

.rc-ingredients-list li:last-child {
  border-bottom: none;
}

.rc-amount {
  display: inline-block;
  min-width: 80px;
  font-weight: 700;
  color: var(--rc-accent);
}

.rc-ingredient-group-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin: 0.75rem 0 0.25rem;
  color: var(--rc-ink);
}

.rc-ingredient-group-name:first-child {
  margin-top: 0;
}

/* ===== Method / Instructions ===== */
.rc-method {
  counter-reset: rc-step;
  list-style: none;
  margin: 0.25rem 0 0.5rem;
  padding: 0;
}

.rc-method li {
  position: relative;
  padding: 0 0 0.6rem 2.75rem;
  border-bottom: 1px solid rgba(217, 211, 198, 0.5);
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.rc-method li:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.rc-method li::before {
  counter-increment: rc-step;
  content: counter(rc-step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--rc-accent);
  color: var(--rc-accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: var(--rc-paper);
}

.rc-method strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

/* ===== Callout (notes, serving suggestions, quick tips) ===== */
.rc-callout {
  border: 1px solid var(--rc-line);
  background: var(--rc-accent-soft);
  border-radius: var(--rc-radius);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.rc-callout-sage {
  background: var(--rc-sage-soft);
}

.rc-callout-title {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.65rem;
  color: var(--rc-accent);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.rc-callout-sage .rc-callout-title {
  color: var(--rc-sage);
}

.rc-note-list {
  margin: 0 0 0 1rem;
  padding: 0;
}

.rc-note-list li {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

/* ===== Footer ===== */
.rc-footer {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rc-line);
  color: var(--rc-muted);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rc-footer-url {
  color: var(--rc-accent);
  text-decoration: none;
  font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .rc {
    padding: 1.25rem 1.25rem 1rem;
  }
  .rc-summary-grid {
    grid-template-columns: 1fr;
  }
  .rc-two-col {
    grid-template-columns: 1fr;
  }
  .rc-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .rc h2.rc-title {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .rc-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* =====================================================================
   SCREEN: Hide the TC recipe card — it only appears when printing.
   ===================================================================== */
.rc {
  display: none;
}

/* =====================================================================
   PRINT STYLES — Optimized for standard home printers, portrait mode.
   Triggered by printRecipe() which adds body.printing-recipe class
   before calling window.print().
   ===================================================================== */

/* Page setup */
@page {
  size: Letter portrait;
  margin: 0.5in 0.5in 0.6in 0.5in;
}

/* ---- Hide everything except the TC recipe card ---- */
body.printing-recipe .recipe-post > *:not(.rc),
body.printing-recipe .site-header,
body.printing-recipe .site-nav,
body.printing-recipe footer,
body.printing-recipe .container > *:not(.recipe-post) {
  display: none !important;
}

/* ---- Fix width: override Pico CSS container constraints ---- */
body.printing-recipe,
body.printing-recipe main,
body.printing-recipe .container,
body.printing-recipe article,
body.printing-recipe .recipe-post {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.printing-recipe {
  --pico-container-max-width: 100%;
}

/* ---- Show the TC card ---- */
body.printing-recipe .rc {
  display: block !important;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
  max-width: 100%;
  background: #fff;
  color: var(--rc-ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9.5pt;
  line-height: 1.35;
  /* Force light palette for print */
  --rc-paper: #fff;
  --rc-ink: #1f1f1b;
  --rc-muted: #5e5a51;
  --rc-line: #d9d3c6;
  --rc-accent: #7a4b2a;
  --rc-accent-soft: #efe4da;
  --rc-sage: #707861;
  --rc-sage-soft: #edf0ea;
}

/* ---- Preserve brand colors in print ---- */
body.printing-recipe .rc-meta-card,
body.printing-recipe .rc-panel,
body.printing-recipe .rc-callout,
body.printing-recipe .rc-brand-mark,
body.printing-recipe .rc-method li::before {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ---- Hide print button ---- */
body.printing-recipe .rc-print-btn {
  display: none !important;
}

/* ---- Compact brand bar ---- */
body.printing-recipe .rc-brand {
  padding-bottom: 6px;
  margin-bottom: 10px;
  flex-direction: row !important;
  align-items: flex-end !important;
}
body.printing-recipe .rc-brand-mark {
  width: 28px;
  height: 28px;
  font-size: 11pt;
}
body.printing-recipe .rc-brand-text small {
  font-size: 7pt;
}
body.printing-recipe .rc-brand-text strong {
  font-size: 12pt;
}

/* ---- Compact header ---- */
body.printing-recipe .rc-head {
  margin-bottom: 6px;
}
body.printing-recipe .rc-kicker {
  font-size: 8pt;
  margin-bottom: 4px;
}
body.printing-recipe .rc h2.rc-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21pt;
  line-height: 1.08;
  margin: 0 0 4px;
}
body.printing-recipe .rc-subtitle {
  font-size: 10pt;
  margin-bottom: 4px;
}

/* ---- Force meta grid to single row ---- */
body.printing-recipe .rc-meta-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)) !important;
  gap: 6px !important;
  margin: 8px 0 !important;
}
body.printing-recipe .rc-meta-card {
  padding: 5px 8px 6px;
  border-radius: 6px;
  background: #fff;
}
body.printing-recipe .rc-meta-card .rc-label {
  font-size: 6.8pt;
}
body.printing-recipe .rc-meta-card .rc-value {
  font-size: 9pt;
}

/* ---- Compact summary grid ---- */
body.printing-recipe .rc-summary-grid {
  display: grid !important;
  grid-template-columns: 2fr 1fr !important;
  gap: 10px !important;
  margin: 8px 0 10px !important;
}

/* ---- Compact panels ---- */
body.printing-recipe .rc-panel {
  padding: 8px 10px;
  border-radius: 7px;
  box-shadow: none;
  background: rgba(255,255,255,0.95);
}
body.printing-recipe .rc-panel h3 {
  font-size: 8.5pt;
  margin: 0 0 3px;
}
body.printing-recipe .rc-panel h4 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12pt;
  margin: 0 0 4px;
}

/* ---- Compact quick facts ---- */
body.printing-recipe .rc-fact-row {
  padding: 3px 0;
}
body.printing-recipe .rc-fact-label {
  font-size: 6.8pt;
}
body.printing-recipe .rc-fact-value {
  font-size: 9pt;
}

/* ---- Force two-column ingredients + method ---- */
body.printing-recipe .rc-two-col {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin-top: 8px !important;
}

/* ---- Compact ingredients ---- */
body.printing-recipe .rc-ingredients-list {
  margin: 2px 0 4px;
}
body.printing-recipe .rc-ingredients-list li {
  padding: 2px 0;
  font-size: 9pt;
}
body.printing-recipe .rc-amount {
  min-width: 70px;
}
body.printing-recipe .rc-ingredient-group-name {
  font-size: 8.5pt;
  margin: 5px 0 2px;
}

/* ---- Compact method steps ---- */
body.printing-recipe .rc-method {
  margin: 2px 0 4px;
}
body.printing-recipe .rc-method li {
  padding: 0 0 5px 36px;
  margin-bottom: 5px;
  font-size: 9pt;
}
body.printing-recipe .rc-method li::before {
  width: 22px;
  height: 22px;
  font-size: 8.5pt;
  background: #fff;
}
body.printing-recipe .rc-method strong {
  font-size: 9pt;
  margin-bottom: 1px;
}

/* ---- Compact callouts ---- */
body.printing-recipe .rc-callout {
  margin-top: 8px;
  padding: 6px 10px;
  box-shadow: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
body.printing-recipe .rc-callout-title {
  font-size: 7pt;
}
body.printing-recipe .rc-note-list li {
  font-size: 9pt;
  margin-bottom: 2px;
}

/* ---- Compact footer ---- */
body.printing-recipe .rc-footer {
  margin-top: 10px;
  padding-top: 6px;
  font-size: 8pt;
}

/* ---- Page break control ---- */
body.printing-recipe .rc-brand,
body.printing-recipe .rc-head,
body.printing-recipe .rc-meta-grid,
body.printing-recipe .rc-summary-grid,
body.printing-recipe .rc-panel,
body.printing-recipe .rc-callout {
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing-recipe .rc-method li {
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing-recipe h2, body.printing-recipe h3, body.printing-recipe h4 {
  break-after: avoid;
}

/* ---- Spacing tightening ---- */
body.printing-recipe .rc p {
  margin: 0 0 0.3rem;
}
body.printing-recipe .rc ul,
body.printing-recipe .rc ol {
  margin: 0.15rem 0 0.4rem;
}
