/* =========================================================
   XY — Cover Letter Builder
   Reuses the CV Builder layout (builder.css) and site tokens.
   ========================================================= */

.cl { min-height: 100vh; }
.cl-form .cb-panel h1 { margin-bottom: var(--s1); }
.cl-section { padding-top: var(--s3); margin-top: var(--s3); border-top: 1px solid var(--line); }
.cl-section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.cl-section > h2 { font-size: 1.5rem; margin-bottom: 4px; }
.cl-section > h2 em { font-style: italic; }
.cl-section > .hint { font-size: .875rem; color: var(--ink-2); margin-bottom: var(--s2); }
.cl-from-cv { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: var(--s3); border-radius: 12px; background: var(--accent-tint); color: var(--tag-ink); font-size: .875rem; }
.cl-from-cv::before { content: "✓"; font-weight: 800; color: var(--accent); }
.cl-tones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: var(--s3); }
.cl-tone { position: relative; display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--paper); cursor: pointer; }
.cl-tone input { position: absolute; opacity: 0; pointer-events: none; }
.cl-tone b { font-size: .9375rem; }
.cl-tone span { font-size: .8125rem; color: var(--ink-2); line-height: 1.4; }
.cl-tone:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.cl-tone:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.cl-edit textarea { min-height: 360px; font-size: .9375rem; line-height: 1.6; }
.cl-edit-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cl-edit-bar p { font-size: .8125rem; color: var(--ink-2); }
.cl-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: var(--s2); }
.cl-actions .btn { width: 100%; }
.cl-next { margin-top: var(--s4); padding: var(--s3); border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
.cl-next p { font-size: .9375rem; color: var(--ink-2); margin-bottom: var(--s2); }

/* ---------- The letter (always light) ---------- */
/* Saved letters (one per job) */
.cl-letters { margin-bottom: var(--s3); padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.cl-letters-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.cl-letters-head h2 { font-size: 1.125rem; }
.cl-letters-head h2 em { font-style: italic; }
.cl-letters .hint { margin-top: 6px; font-size: .8125rem; color: var(--ink-2); }
.cl-letter-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.cl-letter-list li { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); border-radius: 10px; }
.cl-letter-list li.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.cl-letter-open { flex: 1; min-width: 0; padding: 10px 12px; border: 0; background: none; color: var(--ink); font: 600 .875rem/1.3 var(--sans); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cl-letter-open small { margin-left: 6px; font-size: .75rem; font-weight: 700; color: var(--accent); }
.cl-letter-del { flex: none; width: 36px; height: 36px; margin-right: 2px; border: 0; border-radius: 8px; background: none; color: var(--ink-2); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.cl-letter-del:hover, .cl-letter-del:focus-visible { background: var(--line); color: var(--ink); }

.cll { --cv-accent: #3E4A34; --cv-side: #EEE7DB; width: 210mm; min-height: 297mm; padding: 20mm 22mm 18mm; background: #fff; color: #1C1A17; font-family: "Manrope", "Segoe UI", Arial, sans-serif; font-size: 10pt; line-height: 1.62; box-sizing: border-box; }
.cll.col-navy { --cv-accent: #1F3A5F; --cv-side: #E7EDF4; }
.cll.col-wine { --cv-accent: #6B2737; --cv-side: #F4E9EA; }
.cll.col-teal { --cv-accent: #1F5E63; --cv-side: #E3EFEE; }
.cll.col-charcoal { --cv-accent: #2E2E2E; --cv-side: #EEEDEA; }
.cll * { box-sizing: border-box; }
.cll h1, .cll p { margin: 0; padding: 0; max-width: none; color: inherit; letter-spacing: normal; }
.cll-head { padding-bottom: 6mm; margin-bottom: 9mm; border-bottom: 2px solid var(--cv-accent); }
.cll-name { font-family: "Fraunces", Georgia, serif; font-size: 25pt; line-height: 1.04; font-weight: 500; letter-spacing: -.02em; }
.cll-name em { font-style: italic; color: var(--cv-accent); }
.cll .cll-role { margin-top: 2mm; font-size: 10.5pt; font-weight: 600; color: var(--cv-accent); }
.cll .cll-contact { margin-top: 1.6mm; font-size: 8.8pt; color: #4F4942; overflow-wrap: anywhere; }
.cll .cll-date { color: #4F4942; margin-bottom: 6mm; }
.cll .cll-to { margin-bottom: 7mm; }
.cll-to b { font-weight: 700; }
.cll .cll-re { font-weight: 700; color: var(--cv-accent); margin-bottom: 6mm; }
.cll-body p { margin-bottom: 4mm; white-space: pre-line; }
.cll .cll-sign { margin-top: 7mm; }
.cll .cll-sign b { display: block; margin-top: 9mm; font-family: "Fraunces", Georgia, serif; font-size: 14pt; font-weight: 500; }
.cll .cv-empty { color: #736C63; font-style: italic; }
.cll .cll-fix { padding: 0 1px; border-radius: 2px; background: #FFE98A; }

/* ---------- Letter layouts: match the six CV templates ---------- */
/* Modern: solid color strip down the left, bold sans name */
.cll.lay-modern { border-left: 9mm solid var(--cv-accent); padding-left: 17mm; }
.cll.lay-modern .cll-name { font-family: "Manrope", "Segoe UI", Arial, sans-serif; font-weight: 800; font-size: 23pt; letter-spacing: -.035em; }
.cll.lay-modern .cll-name em { font-style: normal; }
.cll.lay-modern .cll-head { border-bottom-width: 2.5px; }
/* Minimal: thin line, spaced capitals */
.cll.lay-minimal .cll-head { border-bottom: 1px solid rgba(28, 26, 23, .18); }
.cll.lay-minimal .cll-name { font-family: "Manrope", "Segoe UI", Arial, sans-serif; font-weight: 300; font-size: 21pt; letter-spacing: .08em; text-transform: uppercase; line-height: 1.1; }
.cll.lay-minimal .cll-name em { font-style: normal; font-weight: 700; color: inherit; }
.cll.lay-minimal .cll-role { letter-spacing: .04em; }
.cll.lay-minimal .cll-re { color: inherit; font-size: 8.5pt; letter-spacing: .14em; text-transform: uppercase; }
/* Executive: full-width color band */
.cll.lay-executive { padding-top: 0; }
.cll.lay-executive .cll-head { margin: 0 -22mm 10mm; padding: 14mm 22mm 10mm; border-bottom: 0; background: var(--cv-accent); color: #fff; }
.cll.lay-executive .cll-name em { color: var(--cv-side); }
.cll.lay-executive .cll-role { color: var(--cv-side); }
.cll.lay-executive .cll-contact { color: rgba(255, 255, 255, .85); }
.cll.lay-executive .cll-head .cv-empty { color: rgba(255, 255, 255, .8); }
/* Timeline: initials badge beside the name */
.cll.lay-timeline .cll-head { display: flex; align-items: center; gap: 6mm; border-bottom: 1px solid rgba(28, 26, 23, .14); }
.cll-mono { flex: none; display: grid; place-items: center; width: 18mm; height: 18mm; border-radius: 50%; background: var(--cv-accent); color: #fff; font-family: "Fraunces", Georgia, serif; font-size: 15pt; box-shadow: 0 0 0 1mm #fff, 0 0 0 1.4mm var(--cv-accent); }
/* Compact: name left, contact details right, tighter page */
.cll.lay-compact { padding: 16mm 18mm 14mm; font-size: 9.6pt; }
.cll.lay-compact .cll-head { margin-bottom: 7mm; padding-bottom: 4mm; }
.cll.lay-compact .cll-id { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8mm; align-items: end; }
.cll.lay-compact .cll-name { grid-column: 1; font-size: 22pt; }
.cll.lay-compact .cll-role { grid-column: 1; }
.cll.lay-compact .cll-contact { grid-column: 2; grid-row: 1 / span 2; max-width: 70mm; margin-top: 0; text-align: right; line-height: 1.55; }

/* ---------- Print: the letter only, edge to edge ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body.cl { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.cl .cb-header, body.cl .cb-form, body.cl .cb-preview-head, body.cl .cb-design, body.cl .cl-actions, body.cl .cb-pages, body.cl .cb-preview-fab { display: none !important; }
  body.cl .cb-main { display: block; width: auto; margin: 0; }
  body.cl .cb-preview { position: static !important; display: block !important; padding: 0 !important; background: #fff !important; }
  body.cl .cb-paper-wrap { box-shadow: none; max-height: none; overflow: visible; border-radius: 0; }
  body.cl .cb-paper-scale { transform: none !important; margin: 0 !important; }
  body.cl .cll { min-height: 296mm; }
}

@media (max-width: 640px) {
  .cl-tones { grid-template-columns: minmax(0, 1fr); }
  .cl-actions { grid-template-columns: minmax(0, 1fr); }
}
