/* ==========================================================================
   Scope-Creep Impact — Local Minimum Prototype Styles
   Derived from The Freelance Floor design tokens (no external font imports)
   ========================================================================== */

:root {
  --ink: #f8fafc;
  --ink-soft: #ffffff;
  --paper: #0f172a;
  --gold: #2563eb;
  --gold-dark: #1d4ed8;
  --teal: #0f766e;
  --rust: #b91c1c;
  --text-hi: #0f172a;
  --text-body: #334155;
  --text-dim: #475569;
  --line: #e2e8f0;

  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'SFMono-Regular', Consolas, monospace;

  --container: 960px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--ink);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

h1,
h2,
h3 {
  color: var(--text-hi);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.45em;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.65rem, 3.2vw, 2.25rem);
  font-weight: 800;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.9em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 6px;
}

.mono {
  font-family: var(--font-mono);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  background: var(--ink-soft);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-hi);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo .mark {
  color: var(--gold);
}

.proto-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--teal);
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- intro ---------- */
.page-head {
  padding: 28px 0 18px;
}

.page-head .lede {
  color: var(--text-body);
  max-width: 66ch;
  margin-bottom: 0;
  font-size: 0.98rem;
}

/* ---------- main workspace card ---------- */
.main-section {
  padding: 8px 0 44px;
}

.calc-card {
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.currency-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}

.currency-btns {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.currency-btns button {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--text-body);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
}

.currency-btns button:last-child {
  border-right: none;
}

.currency-btns button.active {
  background: var(--gold);
  color: #fff;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- form ---------- */
.input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-hi);
}

.input-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.input-box.has-error {
  border-color: var(--rust);
  background: #fef2f2;
}

.input-prefix,
.input-suffix {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
}

.input-prefix {
  margin-right: 6px;
}

.input-suffix {
  margin-left: 6px;
}

.input-box input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-hi);
}

.input-box input:focus {
  outline: none;
}

.desc-textarea,
.msg-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-hi);
  background: #fff;
  resize: vertical;
}

.desc-textarea:focus,
.msg-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.field-error {
  font-size: 0.8rem;
  color: var(--rust);
  font-weight: 600;
  min-height: 1.1em;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.field-hint.is-warning {
  color: #92400e;
}

/* ---------- results ---------- */
.results-block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 2px solid var(--line);
}

.empty-state-banner {
  background: #fef2f2;
  border-left: 4px solid var(--rust);
  color: var(--text-hi);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.score-block {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}

.score-block.highlight {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.score-block.warn {
  background: #fef2f2;
  border-color: #fecaca;
}

.score-number {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-hi);
  margin: 4px 0;
  word-break: break-word;
}

.score-block.warn .score-number {
  color: var(--rust);
}

.score-block.highlight .score-number {
  color: var(--gold);
}

.score-sub {
  font-size: 0.83rem;
  color: var(--text-dim);
  font-weight: 500;
}

.math-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
  font-size: 0.88rem;
}

.math-box h3 {
  font-size: 0.88rem;
  color: var(--teal);
  margin-bottom: 8px;
}

.math-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.math-list li {
  display: flex;
  justify-content: space-between;
  gap: 6px 12px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}

.math-list li:first-child {
  border-top: none;
  padding-top: 0;
}

.math-eq {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-hi);
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* ---------- message builder ---------- */
.message-block {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 2px solid var(--line);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tone-btns {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tone-btns button {
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
}

.tone-btns button:last-child {
  border-right: none;
}

.tone-btns button.active {
  background: var(--paper);
  color: #fff;
}

.message-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.manual-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.stale-alert {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  color: #78350f;
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 10px;
}

.stale-prompt {
  margin-top: 12px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 14px 16px;
}

.stale-prompt-title {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #78350f;
}

.stale-prompt-desc {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: #78350f;
}

.stale-prompt-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-stale-warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #78350f;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--gold-dark);
}

.btn-ghost {
  background: #fff;
  color: var(--text-hi);
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.copy-feedback {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--teal);
  min-height: 1.2em;
}

.copy-feedback.is-error {
  color: var(--rust);
}

/* ---------- optional 1-page summary & print ---------- */
.optional-pdf-block {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}

.optional-pdf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-toggle {
  margin-top: 12px;
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gold);
}

.print-preview-wrap.is-collapsed {
  display: none;
}

.print-sheet {
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  font-size: 0.9rem;
  color: var(--text-hi);
}

.print-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 2px solid var(--paper);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.print-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.print-kv {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.print-kv span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.print-kv strong {
  font-size: 0.96rem;
  color: var(--text-hi);
}

.print-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fff;
}

.print-disclaimer {
  font-size: 0.76rem;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

/* ---------- footer ---------- */
.site-footer {
  padding: 20px 0 36px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---------- mobile responsive ---------- */
@media (max-width: 720px) {
  .input-grid,
  .metrics-grid,
  .print-sheet-grid {
    grid-template-columns: 1fr;
  }

  .calc-card {
    padding: 18px 16px;
  }

  .actions-row .btn,
  .quick-actions .btn,
  .optional-pdf-head .btn,
  .stale-prompt-actions .btn {
    width: 100%;
  }

  .tone-btns {
    width: 100%;
  }

  .tone-btns button {
    flex: 1;
    text-align: center;
  }
}

/* ---------- multi-page safe print / PDF ---------- */
@page {
  size: A4;
  margin: 12mm;
}

@media print {
  html,
  body {
    width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    background: #fff;
    color: #0f172a;
    font-size: 10.5pt;
    line-height: 1.4;
  }

  .no-print {
    display: none !important;
  }

  .wrap,
  .main-section,
  .calc-card {
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: #fff;
  }

  .optional-pdf-block {
    margin: 0;
    padding: 0;
    border: none;
  }

  .print-preview-wrap,
  .print-preview-wrap.is-collapsed {
    display: block !important;
    margin: 0;
  }

  .print-sheet {
    display: block !important;
    margin: 0;
    padding: 0;
    border: none;
  }

  .print-sheet-header,
  .print-kv {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    margin-bottom: 10px;
  }

  .print-kv {
    padding: 6px 8px;
  }

  .print-box {
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 9.5pt;
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-disclaimer {
    font-size: 8pt;
    padding-top: 8px;
    margin-top: 8px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
