/* Text From Home — Conversation report · Concept A “Letter home”
   Tokens from /workspace/tfh-conversation-report (Sep 22, 2026) */

:root {
  --ink: #2C2416;
  --muted: #6B5E4E;
  --cream: #F7F1E8;
  --card: #FFFBF5;
  --accent: #C4893A;
  --accent-soft: #E8D4B8;
  --line: #D6CCC0;
  --inbound: #F3E6D4;
  --outbound: #FFFEFB;
  --outbound-border: #C4893A;
  --ok: #166534;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Source Sans 3", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
}
a { color: var(--accent); }
.wrap { width: min(720px, calc(100% - 2.5rem)); margin: 0 auto; }

header.site-header {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.85rem; padding: 1.25rem 0 0.5rem;
}
.logo { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); line-height: 0; }
.logo img { display: block; height: 11.28rem; width: auto; max-width: min(92vw, 40rem); }
.nav {
  width: 100%; max-width: 56rem; margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 0.65rem 1.75rem; font-size: 1.08rem;
}
.nav a {
  margin-left: 0; text-decoration: none; color: var(--muted);
  font-weight: 500; font-size: 1.08rem; line-height: 1.2;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

.btn {
  display: inline-block; border: 0; border-radius: 999px; padding: 0.7rem 1.15rem;
  font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(0.95); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.auth-loading {
  margin: 1.5rem 0; padding: 1.25rem 1.4rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 1.1rem;
  color: var(--muted);
}
.auth-loading[hidden], #report-panel[hidden] { display: none !important; }

/* —— Letter-home cover —— */
.report-header {
  padding: 1.75rem 0 0.5rem;
  text-align: center;
}
.eyebrow {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
  background: none;
  padding: 0;
  border-radius: 0;
}
.report-header h1 {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2rem, 4vw, 2.5rem); /* ~36–40px */
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.65rem;
  color: var(--ink);
}
.report-kicker {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 1.02rem;
}
.report-sub {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 1.05rem;
}
.report-sub strong { color: var(--ink); font-weight: 600; }
.sponsor-line {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.range-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 1rem;
}
.range-bar .label {
  font-size: 0.92rem; font-weight: 600; color: var(--muted); margin-right: 0.25rem;
}
.range-presets { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }
.range-presets button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 0.4rem 0.9rem; font: inherit; font-weight: 600;
  font-size: 0.9rem; cursor: pointer;
}
.range-presets button[aria-pressed="true"] {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.range-presets button:hover { border-color: var(--accent); }
.toolbar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem;
  margin: 0 0 1.5rem;
}
.source-chip {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  padding: 0.2rem 0.55rem; border-radius: 999px; margin-left: 0.4rem;
}

/* Quiet at-a-glance: text + hairline rules (not KPI tiles) */
.glance {
  display: block;
  margin: 0 0 1.75rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.glance-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.85rem;
}
.glance-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0;
}
.glance-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.35rem;
  min-width: 6.5rem;
}
.glance-stat + .glance-stat {
  border-left: 1px solid var(--line);
}
.glance-stat .n {
  font-family: Fraunces, Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
  margin: 0 0 0.2rem;
}
.glance-stat .l {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
  margin: 0;
}
.glance-keepsake {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}
@media (max-width: 560px) {
  .logo img { height: 7.8rem; }
  .glance-stat {
    flex: 1 1 100%;
    padding: 0.55rem 0;
    border-left: 0 !important;
  }
  .glance-stat + .glance-stat {
    border-top: 1px solid var(--line);
  }
}

/* Soft fade-in (web only; print/PDF static) */
@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: tfh-report-fade 0.55s ease-out both;
  }
  .fade-in:nth-child(1) { animation-delay: 0.05s; }
  .fade-in:nth-child(2) { animation-delay: 0.12s; }
  .fade-in:nth-child(3) { animation-delay: 0.2s; }
  @keyframes tfh-report-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}

.thread-section h2 {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.85rem;
  text-align: center;
}
.thread {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0 0 1.5rem;
}
.day-sep {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-variant: small-caps;
  page-break-after: avoid;
  break-after: avoid;
}
.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  page-break-inside: avoid;
  break-inside: avoid;
}
/* Concept A: inbound (loved one) left / outbound (TFH) right */
.bubble-row.inbound { align-self: flex-start; align-items: flex-start; }
.bubble-row.outbound { align-self: flex-end; align-items: flex-end; }
.bubble-meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.2rem;
  padding: 0 0.35rem;
}
.bubble-row.outbound .bubble-meta { color: var(--accent); }
.bubble {
  border-radius: 1.05rem;
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.02rem;
  color: var(--ink);
}
.bubble-row.inbound .bubble {
  background: var(--inbound);
  border: 1px solid transparent;
  border-bottom-left-radius: 0.35rem;
}
.bubble-row.outbound .bubble {
  background: var(--outbound);
  border: 1px solid var(--outbound-border);
  border-bottom-right-radius: 0.35rem;
}
.bubble-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.2rem 0.35rem 0;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 1.1rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  margin: 0 0 1.5rem;
}
.empty h3 {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
  color: var(--ink);
  margin: 0 0 0.5rem;
}
.empty p { margin: 0; }

.report-footer {
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.92rem;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  text-align: center;
}
.report-footer p { margin: 0 0 0.4rem; }
footer.site-footer {
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: 0.95rem;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}

/* Print / PDF — hide chrome; keep letter-home static */
@media print {
  body { background: #F7F1E8; color: var(--ink); }
  .site-header .nav,
  .toolbar,
  .range-bar,
  .no-print,
  footer.site-footer { display: none !important; }
  .logo img { height: 5.5rem; }
  .wrap { width: 100%; max-width: none; margin: 0; padding: 0 0.5in; }
  .glance, .bubble, .empty, .bubble-row { break-inside: avoid; }
  .day-sep { break-after: avoid; page-break-after: avoid; }
  .thread { gap: 0.5rem; }
  .bubble-row { max-width: 78%; }
  a[href]::after { content: ""; }
  .report-footer { border-top: 1px solid var(--line); }
  .fade-in { animation: none !important; opacity: 1 !important; transform: none !important; }
  @page { margin: 0.65in; }
}

/* —— Letter-home PDF DOM (html2pdf) ——
   Idle: must NOT paint on screen (height:0 / opacity:0).
   Rendering: .tfh-pdf-rendering toggled only while capturing, then node removed. */
.pdf-document {
  position: fixed;
  left: 0;
  top: 0;
  width: 7.1in; /* 8.5 − 2×0.70 */
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  background: #F7F1E8;
  color: #1C1917;
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 11pt;
  line-height: 1.5;
}
.pdf-document.tfh-pdf-rendering {
  height: auto;
  overflow: visible;
  opacity: 1;
  z-index: 2147483646;
  background: #F7F1E8;
}
.pdf-document * { box-sizing: border-box; }
.tfh-pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483645; /* below render root */
  background: #F7F1E8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: #44403c;
  letter-spacing: 0.01em;
  pointer-events: all;
}
.pdf-cover {
  background: #F7F1E8;
  padding: 0.2in 0 0.4in;
  text-align: center;
  page-break-after: always;
  break-after: page;
}
.pdf-logo {
  margin: 0 auto 0.55rem;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.09in;
}
.pdf-logo img {
  display: block;
  height: 0.45in; /* static tfh-mark@3x.png (127×144), name as text beside it */
  width: auto;
  max-width: 3.6in;
  margin: 0;
}
.pdf-logo-word {
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.206in; /* same mark:text ratio as the site header (22/48) */
  letter-spacing: -0.01em;
  line-height: 1;
  color: #1C1917;
  white-space: nowrap;
}
.pdf-brand {
  margin: 0.35rem 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b45309;
}
.pdf-title {
  margin: 0 0 0.55rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #1C1917;
}
.pdf-subline {
  margin: 0 0 1.1rem;
  color: #44403c;
  font-size: 11pt;
}
.pdf-glance {
  margin: 0.35rem 0 0;
  padding: 0.85rem 0.15in;
  border-top: 1px solid #D6CCC0;
  border-bottom: 1px solid #D6CCC0;
  text-align: left;
}
.pdf-glance-label {
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b45309;
}
.pdf-glance-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0;
}
.pdf-stat {
  flex: 1 1 0;
  padding: 0 0.35rem 0 0;
  min-width: 0;
}
.pdf-stat + .pdf-stat {
  border-left: 1px solid #D6CCC0;
  padding-left: 0.55rem;
}
.pdf-stat-n {
  margin: 0 0 0.15rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 18pt;
  font-weight: 700;
  color: #1C1917;
  line-height: 1.1;
}
.pdf-stat-l {
  margin: 0;
  font-size: 9pt;
  color: #57534e;
  font-weight: 400;
}
.pdf-keepsake {
  margin: 1rem 0 0;
  color: #44403c;
  font-size: 10.5pt;
}
.pdf-keepsake p { margin: 0 0 0.35rem; }
.pdf-next {
  margin: 1.1rem 0 0;
  color: #57534e;
  font-size: 10pt;
  font-weight: 500;
}
.pdf-thread {
  display: flex;
  flex-direction: column;
  background: #F7F1E8;
  padding: 0.05in 0 0.25in;
}
.pdf-slim-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.45rem;
  margin-bottom: 0.55rem;
  border-bottom: 1px solid #D6CCC0;
  page-break-after: avoid;
  break-after: avoid;
}
.pdf-logo-sm {
  line-height: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.06in;
}
.pdf-logo-sm img {
  display: block;
  height: 0.28in; /* static tfh-mark@3x.png */
  width: auto;
  max-width: 1.9in;
}
.pdf-logo-sm .pdf-logo-word { font-size: 0.128in; }
.pdf-slim-meta { flex: 1 1 auto; min-width: 0; }
.pdf-slim-title {
  margin: 0;
  font-weight: 600;
  font-size: 11pt;
  color: #1C1917;
}
.pdf-slim-sub {
  margin: 0.1rem 0 0;
  font-size: 8.5pt;
  color: #57534e;
}
.pdf-day-sep {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.75rem 0 0.4rem;
  color: #57534e;
  font-size: 8.5pt;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  page-break-before: always;
  break-before: page;
  page-break-after: avoid;
  break-after: avoid;
}
.pdf-day-sep--first {
  page-break-before: auto;
  break-before: auto;
  margin-top: 0.15rem;
}
.pdf-day-sep::before,
.pdf-day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #D6CCC0;
}
.pdf-bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 62%;
  margin: 0 0 0.45rem;
  page-break-inside: avoid;
  break-inside: avoid;
}
.pdf-inbound { align-self: flex-start; align-items: flex-start; }
.pdf-outbound { align-self: flex-end; align-items: flex-end; margin-left: auto; }
.pdf-bubble-meta {
  font-size: 8pt;
  color: #57534e;
  font-weight: 600;
  margin: 0 0 0.12rem;
  padding: 0 0.2rem;
}
.pdf-outbound .pdf-bubble-meta { color: #b45309; }
.pdf-bubble {
  border-radius: 0.85rem;
  padding: 0.55rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 10.5pt;
  line-height: 1.45;
}
.pdf-inbound .pdf-bubble {
  background: #FFFCFA;
  color: #1C1917;
  border: 1px solid #DCD2C6;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.04);
}
.pdf-outbound .pdf-bubble {
  background: #b45309;
  color: #ffffff;
  border: 1px solid #b45309;
  border-bottom-right-radius: 0.25rem;
}
.pdf-bubble-time {
  font-size: 7.5pt;
  color: #57534e;
  margin: 0.12rem 0.2rem 0;
}
.pdf-empty {
  text-align: center;
  color: #57534e;
  margin: 1rem 0;
}
.pdf-end-mark {
  text-align: center;
  color: #57534e;
  font-size: 9pt;
  margin: 1.1rem 0 0.35rem;
}

/* Toast + button loading for PDF download */
.tfh-toast {
  position: fixed;
  bottom: 1.35rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: min(92vw, 24rem);
  padding: 0.75rem 1.15rem;
  border-radius: 999px;
  background: #1C1917;
  color: #F7F1E8;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(28, 25, 23, 0.18);
  text-align: center;
}
.tfh-toast[hidden] { display: none !important; }
.tfh-toast--error { background: #7f1d1d; color: #fff; }
.btn.is-loading { position: relative; pointer-events: none; opacity: 0.75; }
.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.45em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: tfh-spin 0.7s linear infinite;
}
@keyframes tfh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation: none; opacity: 0.5; }
}
