/* Carret contracts. Brand tokens from carret-app/design (colours, neutrals, radii, shadows). */

@font-face { font-family: 'Nunito Sans'; font-weight: 400; font-display: swap; src: url('../fonts/NunitoSans-400.woff') format('woff'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 600; font-display: swap; src: url('../fonts/NunitoSans-600.woff') format('woff'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 700; font-display: swap; src: url('../fonts/NunitoSans-700.woff') format('woff'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 600; font-display: swap; src: url('../fonts/SourceSerif4-600.woff') format('woff'); }

:root {
  --n-0: #ffffff;
  --n-50: #f8f7f5;
  --n-100: #f1efec;
  --n-200: #e4e1dc;
  --n-300: #cfcbc4;
  --n-400: #a8a39b;
  --n-500: #7c7770;
  --n-600: #5b5750;
  --n-700: #403d38;
  --n-900: #1b1a18;
  --primary: #355abf;
  --primary-hover: #2f51ad;
  --blue-50: #e9eef9;
  --blue-100: #cfdaf2;
  --blue-700: #27458f;
  --orange-50: #fef2e3;
  --orange-100: #fcddb5;
  --orange-700: #b8661a;
  --red-700: #a82d17;

  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px rgba(27, 26, 24, 0.06);
  --shadow-paper: 0 12px 32px rgba(27, 26, 24, 0.1), 0 2px 6px rgba(27, 26, 24, 0.06);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --sans: 'Nunito Sans', system-ui, sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;

  /* The paper is drawn in PDF points so lines wrap close to the downloaded PDF. */
  --pt: 1.45px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--n-900);
  background: var(--n-100);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 1px; }

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 20px;
  background: var(--n-0);
  border-bottom: 1px solid var(--n-200);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--n-700); }
.brand img { display: block; }
.brand-name { font-weight: 600; font-size: 15px; padding-left: 12px; border-left: 1px solid var(--n-200); line-height: 20px; }

.actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { cursor: progress; opacity: 0.75; }
.btn-primary { background: var(--primary); color: var(--n-0); padding: 0 18px 0 14px; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

/* ---------- layout ---------- */

.layout { flex: 1; min-height: 0; display: grid; }

/* ---------- desk and paper ---------- */

.desk { position: relative; overflow-y: auto; padding: 0 32px 64px; scroll-padding: 120px; }

.blanks {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: max-content;
  margin: 16px auto 0;
  padding: 6px 8px 6px 16px;
  background: var(--orange-50);
  color: var(--orange-700);
  border: 1px solid var(--orange-100);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.blanks[hidden] { display: none; }
.link {
  border: 0;
  background: var(--n-0);
  color: var(--orange-700);
  font-weight: 700;
  font-size: 13px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--orange-100);
  transition: background-color 150ms var(--ease-out);
}
.link:hover { background: var(--orange-100); }

.paper {
  width: calc(595.28 * var(--pt));
  min-height: calc(841.89 * var(--pt));
  margin: 16px auto 0;
  background: var(--n-0);
  border-radius: 4px;
  box-shadow: var(--shadow-paper);
}

.sheet {
  padding: calc(50 * var(--pt)) calc(56 * var(--pt)) calc(64 * var(--pt));
  font-size: calc(9.5 * var(--pt));
  line-height: 1.3;
  color: var(--n-900);
}

.doc-logo { display: block; width: calc(92 * var(--pt)); height: auto; margin-bottom: calc(14 * var(--pt)); }

.doc-title { font-family: var(--serif); font-weight: 600; font-size: calc(22 * var(--pt)); line-height: 1.1; margin: 0; letter-spacing: -0.005em; }
.doc-rule { border: 0; border-top: calc(1.2 * var(--pt)) solid var(--blue-700); margin: calc(8 * var(--pt)) 0 calc(14 * var(--pt)); }
.doc-h2 { font-family: var(--serif); font-weight: 600; font-size: calc(14 * var(--pt)); line-height: 1.1; color: var(--blue-700); margin: 0 0 calc(6 * var(--pt)); }
.doc-h2-terms { margin-top: calc(18 * var(--pt)); margin-bottom: calc(8 * var(--pt)); }
.doc-p { margin: 0 0 calc(10 * var(--pt)); }

.order { width: 100%; border-collapse: collapse; }
.order th, .order td { border: calc(0.6 * var(--pt)) solid var(--n-300); vertical-align: top; padding: calc(4.5 * var(--pt)) calc(7 * var(--pt)); text-align: left; }
.order th { width: calc(150 * var(--pt)); background: var(--n-100); font-weight: 700; position: relative; }
.order td { font-weight: 400; }

.terms { list-style: none; margin: 0; padding: 0; }
.term { position: relative; display: flex; margin-bottom: calc(6.5 * var(--pt)); }
.term-num { flex: none; width: calc(20 * var(--pt)); font-variant-numeric: tabular-nums; }
.term-text { margin: 0; flex: 1; }
.term-title { font-weight: 700; }

.signing { margin-top: calc(14 * var(--pt)); }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: calc(36 * var(--pt)); }
.party-heading { font-weight: 700; margin-bottom: calc(4 * var(--pt)); }
.sig-row { display: grid; grid-template-columns: calc(54 * var(--pt)) 1fr; align-items: end; margin-top: calc(10 * var(--pt)); }
.sig-row-tall { margin-top: calc(22 * var(--pt)); }
.sig-label { color: var(--n-600); }
.sig-value { border-bottom: calc(0.6 * var(--pt)) solid var(--n-600); min-height: 1.45em; padding: 0 4px 1px; }

/* ---------- editable lines ---------- */

.f {
  outline: none;
  border-radius: 3px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.f:hover { background: var(--blue-50); }
.f:focus { background: var(--n-0); box-shadow: 0 0 0 2px var(--primary), 0 0 0 5px var(--blue-100); }
.f.has-blank { background: var(--orange-50); box-shadow: inset 0 -2px 0 var(--orange-100); }
.f.has-blank:focus { background: var(--n-0); box-shadow: 0 0 0 2px var(--orange-700), 0 0 0 5px var(--orange-100); }
.f:empty::before { content: attr(data-ph); color: var(--n-400); }
.sig-value.f:empty::before { content: none; }
.order th .f:hover, .order th .f:focus { background-color: var(--n-0); }

/* Remove and add controls live in the paper's margin and never reach the PDF. */
.x {
  position: absolute;
  left: calc(-1 * (56 * var(--pt)) + 8px);
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--n-400);
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms var(--ease-out), background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.term .x { top: 0; translate: 0 -3px; }
.order tr:hover .x, .order tr:focus-within .x, .term:hover .x, .term:focus-within .x, .x:focus-visible { opacity: 1; }
.x:hover { background: var(--n-100); color: var(--red-700); }
.x::after { content: ''; position: absolute; inset: -8px; }

.add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--n-500);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 150ms var(--ease-out), background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.paper:hover .add, .add:focus-visible { opacity: 1; }
.add:hover { background: var(--blue-50); color: var(--primary); }

@media (max-width: 960px) {
  :root { --pt: 1.3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
