/* ============================================================
   ftb-print.css
   ============================================================
   Scoped stylesheet for the Function Task Brief template only.
   NOT linked from the wizard's index.html — the wizard uses
   style.css. The FTB intentionally departs from the wizard's
   app register and adopts a printed-business-document register:
   serif display (Literata) for headings, sans body (Figtree)
   for running text, generous margins, masthead, signature
   block, horizontal rule section dividers.

   The Pre-calibration vs During-calibration label distinction
   uses BOTH color (text-tertiary vs accent) AND typographic
   weight (roman vs italic) so the labels remain visually
   distinct in grayscale and black-and-white print.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Inherits the same color tokens as the wizard for consistency.
     The FTB lives in the same prototype context; only the typography
     and layout register diverge. */
  --bg: oklch(0.97 0.005 265);
  --surface: oklch(0.99 0.003 265);
  --text: oklch(0.18 0.02 265);
  --text-secondary: oklch(0.40 0.015 265);
  --text-tertiary: oklch(0.55 0.01 265);
  --text-light: oklch(0.65 0.01 265);
  --border: oklch(0.87 0.012 265);
  --border-subtle: oklch(0.92 0.008 265);
  --accent: oklch(0.62 0.18 30);

  /* Typography: Literata serif display with system-serif fallback;
     Figtree sans for body with system-sans fallback. Fallbacks cover
     macOS / Windows / Linux when the Google Fonts CDN is unreachable
     (offline printing path). */
  --font-display: 'Literata', Georgia, 'Times New Roman', serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 0;
}

/* ---- Page container with generous margins ---- */
.ftb-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 56px 96px;
  background: var(--surface);
  min-height: 100vh;
}

/* ---- Masthead ---- */
.ftb-masthead {
  margin-bottom: 32px;
}

.ftb-function-name {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 14px;
}

.ftb-function-name:empty::before,
.ftb-function-name[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  font-style: italic;
  font-weight: 400;
}

.ftb-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 16px 24px;
  margin-top: 12px;
}

.ftb-meta-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.ftb-meta-value {
  font-size: 14px;
  color: var(--text-secondary);
  display: block;
}

/* ---- Framing block ---- */
.ftb-framing {
  background: var(--bg);
  padding: 16px 20px;
  border-radius: 4px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---- Divider rules ---- */
.ftb-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 28px 0;
}

/* ---- Section headers + phase labels ---- */
.ftb-section {
  margin-bottom: 8px;
}

.ftb-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ftb-section-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Phase labels: Pre-calibration vs During calibration session.
   COLOR (text-tertiary vs accent) AND TYPOGRAPHIC WEIGHT
   (roman vs italic) carry the distinction. The italic vs roman
   treatment works in grayscale and B&W print where color may
   collapse to similar grays. */
.ftb-phase-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ftb-phase-pre {
  font-style: normal;
  color: var(--text-tertiary);
}

.ftb-phase-during {
  font-style: italic;
  color: var(--accent);
}

/* Inline phase labels inside the framing prose */
.ftb-framing .ftb-phase-label {
  display: inline-block;
  padding: 0 4px;
  vertical-align: baseline;
}

/* ---- Section bodies (editable areas) ---- */
.ftb-section-instruction {
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.6;
}

.ftb-section-body {
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  outline: none;
}

.ftb-section-body:empty::before,
.ftb-section-body[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  font-style: italic;
}

.ftb-section-body:focus {
  border-color: var(--border);
  background: #fff;
}

.ftb-synthesis {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  min-height: 100px;
  padding: 16px 20px;
}

/* ---- Task list ---- */
.ftb-task-list {
  list-style: none;
  margin: 16px 0;
  padding: 0;
}

.ftb-task {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.ftb-task:last-of-type {
  border-bottom: none;
}

.ftb-task-row {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.ftb-task-number {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.ftb-task-content {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  min-height: 22px;
  outline: none;
  padding: 1px 4px;
  border-radius: 2px;
}

.ftb-task-content:empty::before,
.ftb-task-content[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  font-style: italic;
}

.ftb-task-content:focus {
  background: var(--bg);
}

.ftb-task-tag-row {
  display: grid;
  grid-template-columns: 36px 1fr 72px 2fr;
  gap: 8px 12px;
  align-items: baseline;
  margin-left: 38px;
  font-size: 13px;
}

.ftb-task-tag-label,
.ftb-task-rationale-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.ftb-task-tag {
  color: var(--text);
  font-weight: 600;
  outline: none;
  padding: 1px 4px;
  border-radius: 2px;
  min-height: 18px;
}

.ftb-task-rationale {
  color: var(--text-secondary);
  outline: none;
  padding: 1px 4px;
  border-radius: 2px;
  min-height: 18px;
}

.ftb-task-tag:empty::before,
.ftb-task-rationale:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  font-weight: 400;
  font-style: italic;
}

.ftb-task-tag:focus,
.ftb-task-rationale:focus {
  background: var(--bg);
}

.ftb-task-list-extend {
  font-size: 13px;
  font-style: italic;
  color: var(--text-tertiary);
  margin-top: 14px;
}

/* ---- Sign-off block ---- */
.ftb-signoff {
  margin-top: 32px;
}

.ftb-signoff-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-top: 18px;
}

.ftb-signature-line {
  border-bottom: 1px solid var(--text);
  height: 32px;
  margin-top: 4px;
}

/* ============================================================
   @media print
   ============================================================
   Print to PDF for the lead's records. Avoid page breaks inside
   a task, inside the synthesis paragraph, or inside the sign-off
   block. Strip editable affordances. Drop background tints to
   maximize ink efficiency. The roman vs italic phase label
   distinction carries through in print where color may collapse.
   ============================================================ */
@media print {
  body {
    background: #fff;
    font-size: 11pt;
    line-height: 1.55;
  }

  .ftb-page {
    max-width: 100%;
    padding: 0;
    margin: 0;
    background: #fff;
    min-height: auto;
  }

  @page {
    size: letter;
    margin: 1in;
  }

  .ftb-function-name {
    font-size: 24pt;
  }

  .ftb-section-header h2 {
    font-size: 14pt;
  }

  .ftb-synthesis {
    font-size: 12pt;
  }

  /* Strip editable affordances (placeholders, focus glow) */
  [contenteditable]:empty::before {
    content: '' !important;
  }
  [contenteditable] {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
  .ftb-section-body {
    border: none;
    padding: 0;
    background: transparent;
  }
  .ftb-synthesis {
    background: transparent;
    border: none;
    padding: 0;
  }

  /* Drop background tints from the framing block */
  .ftb-framing {
    background: transparent;
    padding: 0;
  }

  /* Avoid breaks inside critical units */
  .ftb-task,
  .ftb-signoff,
  .ftb-synthesis,
  .ftb-masthead,
  .ftb-section-header {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Phase label distinction in print:
     - .ftb-phase-pre stays roman (font-style: normal)
     - .ftb-phase-during stays italic
     - both can be safely rendered in solid black for max ink contrast;
       italic vs roman carries the distinction without color */
  .ftb-phase-label {
    color: #000;
  }

  .ftb-phase-pre {
    font-style: normal;
  }

  .ftb-phase-during {
    font-style: italic;
  }

  /* Divider lines remain visible */
  .ftb-divider {
    border-top: 0.5pt solid #999;
  }
}
