/* =========================================================
   Freelance Proposal & Contract Generator
   Palette: deep ink navy + warm amber accent + cool paper
   Type: Sora (display) + Inter (body)
   ========================================================= */

:root {
  --ink:        #11161f;   /* near-black navy */
  --ink-soft:   #2b3340;
  --slate:      #5a6577;
  --slate-2:    #8590a1;
  --line:       #e2e6ee;
  --bg:         #f4f6fb;   /* cool app background */
  --surface:    #ffffff;
  --paper:      #ffffff;   /* document paper */
  --amber:      #e08a2b;   /* warm accent */
  --amber-deep: #b86d16;
  --teal:       #14705f;   /* secondary accent for links/headings */
  --teal-soft:  #e3f1ed;
  --danger:     #b3402f;

  --radius:   14px;
  --radius-sm:9px;
  --shadow:   0 1px 2px rgba(17,22,31,.05), 0 12px 32px -12px rgba(17,22,31,.18);
  --shadow-sm:0 1px 2px rgba(17,22,31,.06), 0 4px 12px -6px rgba(17,22,31,.12);

  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Focus ---------- */
:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(244,246,251,.86);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; }
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand-mark {
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  color: #fff; background: var(--ink); width: 2rem; height: 2rem;
  display: grid; place-items: center; border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--amber);
}
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; line-height: 1.1; display: flex; flex-direction: column; }
.brand-sub { font-family: var(--font-body); font-weight: 500; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--slate); }
.header-actions { display: flex; gap: .4rem; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: .9rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .55rem .95rem; cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .05s;
  background: transparent; color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--slate-2); }
.btn-add {
  background: var(--teal-soft); color: var(--teal); border: 1px dashed #9ecdc1;
  font-weight: 600; width: 100%; padding: .7rem; margin-top: .6rem;
}
.btn-add:hover { background: #d8ece6; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 2rem;
  align-items: start;
  padding: 2rem 0 1rem;
}

/* ---------- Editor ---------- */
.editor-intro h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.5rem); line-height: 1.08;
  letter-spacing: -.02em; margin: 0 0 .6rem;
}
.editor-intro .accent { color: var(--amber-deep); }
.lede { color: var(--slate); font-size: 1.02rem; margin: 0 0 1.4rem; max-width: 46ch; }
.lede strong { color: var(--ink-soft); }

form { display: flex; flex-direction: column; gap: 1.1rem; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 1.15rem 1.2rem 1.3rem; margin: 0;
  box-shadow: var(--shadow-sm);
}
legend {
  font-family: var(--font-display); font-weight: 600; font-size: .82rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--slate);
  padding: 0 .5rem; margin-left: -.5rem;
}
legend .opt { text-transform: none; letter-spacing: 0; color: var(--slate-2); font-weight: 500; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }

label { font-weight: 600; font-size: .82rem; color: var(--ink-soft); }
label .opt { font-weight: 500; color: var(--slate-2); }

input, textarea, select {
  font-family: var(--font-body); font-size: .95rem; color: var(--ink);
  background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .7rem; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #aab2c0; }
input:focus, textarea:focus, select:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(224,138,43,.16); outline: none; background: #fff; }
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6577' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; padding-right: 2rem; }

.hint { font-size: .78rem; color: var(--slate-2); margin: .1rem 0 0; }
.is-hidden { display: none !important; }

/* ---------- Line items ---------- */
.line-items { display: flex; flex-direction: column; gap: .55rem; }
.line-item { display: grid; grid-template-columns: 1fr 120px auto; gap: .5rem; align-items: center; }
.line-item input { margin: 0; }
.line-item .li-price { text-align: right; }
.li-remove {
  border: 1px solid var(--line); background: #fff; color: var(--slate);
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 1.1rem; line-height: 1; display: grid; place-items: center;
}
.li-remove:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Preview ---------- */
.preview { position: sticky; top: 4.4rem; display: flex; flex-direction: column; }
.preview-toolbar { display: inline-flex; gap: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .25rem; width: fit-content; box-shadow: var(--shadow-sm); }
.tab {
  font-family: var(--font-display); font-weight: 600; font-size: .85rem;
  border: none; background: transparent; color: var(--slate);
  padding: .45rem 1.1rem; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s;
}
.tab.is-active { background: var(--ink); color: #fff; }
.tab:not(.is-active):hover { color: var(--ink); }

.preview-actions { display: flex; gap: .45rem; margin: .8rem 0; flex-wrap: wrap; }

.doc-scroll {
  background: linear-gradient(180deg, #eef1f7, #e7ebf3);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; max-height: 78vh; overflow: auto; box-shadow: inset 0 2px 8px rgba(17,22,31,.06);
}

.paper {
  background: var(--paper); color: var(--ink);
  padding: 2.6rem 2.5rem; border-radius: 6px;
  box-shadow: var(--shadow); max-width: 720px; margin-inline: auto;
  font-size: .92rem;
}

/* Document typography */
.doc h1.doc-title { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .2rem; }
.doc .doc-kicker { font-family: var(--font-display); font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--amber-deep); margin: 0 0 .8rem; }
.doc h2.doc-h { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; margin: 1.7rem 0 .5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--line); color: var(--ink); }
.doc .doc-num { color: var(--amber-deep); }
.doc p { margin: 0 0 .7rem; color: var(--ink-soft); }
.doc ul { margin: 0 0 .7rem; padding-left: 1.1rem; color: var(--ink-soft); }
.doc li { margin-bottom: .3rem; }
.doc .doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 1.5rem; margin: 1rem 0 0; font-size: .86rem; }
.doc .doc-meta div span { display: block; color: var(--slate-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.doc .doc-meta div strong { color: var(--ink); font-weight: 600; }

.price-table { width: 100%; border-collapse: collapse; margin: .4rem 0 .6rem; font-size: .9rem; }
.price-table td { padding: .5rem .2rem; border-bottom: 1px solid var(--line); color: var(--ink-soft); vertical-align: top; }
.price-table td.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink); }
.price-table tr.total td { border-bottom: none; border-top: 2px solid var(--ink); font-weight: 700; color: var(--ink); padding-top: .6rem; }
.price-table tr.total td.amt { font-size: 1.05rem; }

.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2.2rem; margin-top: 1.8rem; }
.sig-block { border-top: 1.5px solid var(--ink); padding-top: .4rem; font-size: .82rem; color: var(--slate); }
.sig-block .sig-line { height: 2.2rem; }

.legal-banner {
  background: #fdf3e7; border: 1px solid #f0cf9e; border-left: 4px solid var(--amber);
  color: #6b4a17; padding: .8rem 1rem; border-radius: var(--radius-sm);
  font-size: .82rem; margin-bottom: 1.6rem;
}
.doc-disclaimer { margin-top: 2rem; padding-top: 1rem; border-top: 1px dashed var(--line); font-size: .76rem; color: var(--slate-2); }

.empty-note { color: var(--slate-2); font-style: italic; }

/* ---------- CTA ---------- */
.cta { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; margin: 2.5rem auto; }
.cta-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.7rem; box-shadow: var(--shadow-sm); }
.cta-card h2 { font-family: var(--font-display); font-size: 1.2rem; margin: 0 0 .4rem; }
.cta-card p { color: var(--slate); margin: 0 0 1.1rem; font-size: .94rem; }
.cta-pv { background: var(--ink); color: #fff; }
.cta-pv h2 { color: #fff; }
.cta-pv p { color: #b9c2d1; }
.cta-pv .btn-ghost { background: transparent; border-color: #3a4452; color: #fff; }
.cta-pv .btn-ghost:hover { border-color: var(--amber); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 1.6rem 0; }
.footer-inner p { margin: .2rem 0; font-size: .84rem; color: var(--slate); }
.footer-inner a { color: var(--teal); font-weight: 600; text-decoration: none; }
.footer-inner a:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 999px;
  font-size: .88rem; font-weight: 500; box-shadow: var(--shadow); z-index: 90;
  transition: transform .25s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .preview { position: static; top: auto; }
  .doc-scroll { max-height: none; }
  .cta { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr auto; }
  .line-item .li-price { grid-column: 1 / 2; }
  .paper { padding: 1.6rem 1.3rem; }
  .brand-text { font-size: .92rem; }
  .header-actions .btn { padding: .5rem .65rem; font-size: .82rem; }
}

/* =========================================================
   PRINT — clean single document, hides app chrome
   ========================================================= */
@media print {
  @page { margin: 18mm 16mm; }
  body { background: #fff; }
  .site-header, .editor, .preview-toolbar, .preview-actions, .cta, .site-footer, .toast, .skip-link { display: none !important; }
  .wrap, .layout { width: auto; margin: 0; padding: 0; display: block; }
  .preview { position: static; }
  .doc-scroll { background: none; border: none; padding: 0; max-height: none; overflow: visible; box-shadow: none; }
  .paper { box-shadow: none; border-radius: 0; max-width: none; padding: 0; font-size: 11pt; color: #000; }
  .doc.is-hidden { display: none !important; }
  .doc[hidden] { display: none !important; }
  .doc h2.doc-h { break-after: avoid; }
  .doc p, .doc li, .price-table tr, .sig-grid { break-inside: avoid; }
  .legal-banner { border: 1px solid #999; background: #f7f7f7; color: #000; }
  a { color: #000; text-decoration: none; }
}
