/* Login and first-login pages. All values come from the brand tokens. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  padding: var(--s6) var(--s4) var(--s7);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--navy);
  color: var(--ink);
  font: 400 var(--fs-body)/var(--lh-body) var(--sans);
  -webkit-font-smoothing: antialiased;
}
/* A fixed layer rather than background-attachment, which iOS Safari does not honour. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--mist); }

.auth-logo { display: block; width: 150px; height: auto; margin: auto 0 var(--s6); }

.auth-card {
  width: 100%;
  max-width: 480px;
  margin-bottom: auto;
  padding: var(--s7);
  background: var(--cream);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}

.auth-step {
  margin: 0 0 var(--s3);
  color: var(--ink-muted);
  font-size: var(--fs-label);
  line-height: var(--lh-label);
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 { margin: 0; font: 300 36px/42px var(--serif); }
h1 em { display: block; color: var(--deep-mint); font-style: italic; }
.auth-lede { margin: var(--s3) 0 var(--s6); color: var(--ink-muted); }

.field { margin-bottom: var(--s4); min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
label { display: block; margin-bottom: var(--s1); font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 500; }

input:not([type="checkbox"]) {
  width: 100%;
  height: 44px;
  padding: 0 var(--s3);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-field);
  color: var(--ink);
  font: inherit;
}
input:focus-visible, .btn:focus-visible, .link-btn:focus-visible, .nda-text:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
input[aria-invalid="true"] { border-color: var(--coral); }

.field-error, .form-error { margin: var(--s1) 0 0; color: #B3343D; font-size: var(--fs-small); line-height: var(--lh-small); }
.form-error { margin: 0 0 var(--s4); }
.field-hint { margin: var(--s1) 0 0; color: var(--ink-subtle); font-size: var(--fs-small); line-height: var(--lh-small); }

.btn {
  width: 100%;
  height: 44px;
  margin-top: var(--s2);
  background: var(--navy);
  border: 0;
  border-radius: var(--r-pill);
  color: var(--cream);
  font: 500 var(--fs-body)/1 var(--sans);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.btn:hover { background: var(--navy-700); }
.btn:disabled { opacity: .6; cursor: progress; }

.link-btn {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--ink-muted);
  font: 400 var(--fs-small)/var(--lh-small) var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }
.signout { margin-top: var(--s4); text-align: center; }

/* NDA */
.nda-text {
  max-height: 340px;
  margin-bottom: var(--s5);
  padding: var(--s5);
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  font-size: var(--fs-small);
  line-height: 22px;
}
.nda-text h2 { margin: 0 0 var(--s3); font: 300 var(--fs-h3)/var(--lh-h3) var(--serif); }
.nda-text h3 { margin: var(--s4) 0 var(--s1); font: 500 var(--fs-small)/var(--lh-small) var(--sans); }
.nda-text p { margin: 0 0 var(--s2); color: var(--navy-800); }
.nda-text h2 { margin-bottom: var(--s1); }
.nda-text .nda-sub { margin-bottom: var(--s4); color: var(--ink-muted); font-size: var(--fs-label); letter-spacing: .04em; }
.nda-text .nda-foot { margin: var(--s4) 0 0; color: var(--ink-subtle); font-style: italic; }

/* Acceptance panel */
.access-panel { padding: var(--s5); background: var(--neutral-100); border: 1px solid var(--line); border-radius: var(--r-panel); }
.access-panel svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.access-eyebrow {
  display: flex; align-items: center; gap: var(--s2);
  margin: 0 0 var(--s3);
  color: var(--ink-muted);
  font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
}
.access-eyebrow svg { width: 20px; height: 20px; }
.access-panel h2 { margin: 0 0 var(--s2); font: 300 var(--fs-h3)/var(--lh-h3) var(--serif); }
.access-lede { margin: 0 0 var(--s4); color: var(--ink-muted); font-size: var(--fs-small); line-height: 22px; }
.access-rules { margin: 0 0 var(--s4); padding: var(--s2) var(--s4); list-style: none; background: var(--white); border-radius: var(--r-card); }
.access-rules li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; font-weight: 500; }
.access-rules svg { width: 20px; height: 20px; color: var(--ink-muted); }
.access-note { margin: 0 0 var(--s4); color: var(--ink-muted); font-size: var(--fs-small); line-height: var(--lh-small); }

.access-check { display: flex; align-items: flex-start; gap: var(--s3); margin: var(--s2) 0 var(--s4); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 400; cursor: pointer; }
.access-check input {
  flex: none; width: 24px; height: 24px; margin: 0;
  appearance: none; -webkit-appearance: none;
  background: var(--white) center / 14px no-repeat;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
}
.access-check input:checked {
  background-color: var(--navy);
  border-color: var(--navy);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FAF7F2' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.500 4.500L19 7.500'/%3E%3C/svg%3E");
}
.access-check input:focus-visible { outline: none; box-shadow: var(--focus); }

.btn-access { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin-top: 0; }
.btn-access svg { width: 18px; height: 18px; }
.btn-access:disabled { background: var(--neutral-200); color: var(--neutral-700); opacity: 1; cursor: not-allowed; }

.sig-box { position: relative; height: 160px; }
#signature {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-field);
  cursor: crosshair;
  touch-action: none;
}
.sig-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neutral-600);
  font-size: var(--fs-small);
  pointer-events: none;
}
.sig-clear { position: absolute; right: var(--s3); bottom: var(--s2); }

/* Agreement page: stacked on narrow screens */
.nda-card { max-width: 720px; }
.nda-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); }
.nda-head .auth-step { margin-bottom: var(--s1); }
.nda-head .link-btn { white-space: nowrap; }
.nda-grid { display: grid; gap: var(--s4); }
.nda-text { margin-bottom: 0; }
.nda-section + .nda-section { margin-top: var(--s3); }
.where-wide { display: none; }
.nda-head-logo { display: none; }
#name-hint { display: inline; margin: 0; font-weight: 400; }

.nda-text { scrollbar-width: thin; scrollbar-color: var(--navy-300) transparent; }
.nda-title { margin-bottom: var(--s4); }
.sig-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s1); }
.sig-label { font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 500; }
.sig-modes { display: inline-flex; padding: 2px; background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--r-pill); }
.sig-modes button { padding: 2px 12px; background: none; border: 0; border-radius: var(--r-pill); color: var(--ink-muted); font: 500 13px/20px var(--sans); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.sig-modes button:hover { color: var(--ink); }
.sig-modes button[aria-pressed="true"] { background: var(--navy); color: var(--cream); }
.sig-modes button:focus-visible { outline: none; box-shadow: var(--focus); }
#signature.is-generated { cursor: default; touch-action: auto; }
.sig-note { position: absolute; right: var(--s3); bottom: var(--s1); color: var(--ink-subtle); font-size: var(--fs-label); line-height: var(--lh-label); pointer-events: none; }

/* Agreement page: one screen on wider screens, with the agreement scrolling in its own box */
@media (min-width: 1000px) {
  .nda-page { padding: var(--s4); justify-content: center; }
  .nda-page > .auth-logo { display: none; }
  .nda-card { max-width: 1280px; margin: 0; padding: var(--s5) var(--s6); }

  .nda-head { align-items: center; gap: var(--s5); margin-bottom: var(--s4); }
  .nda-head-logo { display: block; flex: none; width: 120px; height: auto; }
  .nda-head-main { display: contents; }
  .nda-head h1 { order: 1; flex: 1; padding-left: var(--s5); border-left: 1px solid var(--line-strong); font-size: 26px; line-height: 32px; }
  .nda-head h1 em { display: inline; }
  .nda-head .auth-step { order: 2; margin: 0; white-space: nowrap; }
  .nda-head form { order: 3; }

  .nda-grid { grid-template-columns: minmax(0, 1fr) 440px; align-items: stretch; gap: var(--s5); }

  /* The panel sets the height; the agreement fills it and scrolls. */
  .nda-text-wrap { position: relative; min-height: 0; }
  .nda-text { position: absolute; inset: 0; max-height: none; padding: var(--s5) var(--s6); }
  .where-wide { display: inline; }
  .where-narrow { display: none; }

  .access-panel { display: flex; flex-direction: column; padding: var(--s4) var(--s5); }
  .access-eyebrow { margin-bottom: var(--s1); }
  .access-panel h2 { margin-bottom: var(--s1); font-size: 22px; line-height: 28px; }
  .access-lede { margin-bottom: var(--s3); line-height: 20px; }
  .access-rules { margin-bottom: var(--s3); padding: var(--s1) var(--s3); }
  .access-rules li { padding: 3px 0; font-size: var(--fs-small); line-height: 20px; }
  .access-rules svg { width: 18px; height: 18px; }
  .access-note { margin-bottom: var(--s3); }
  .access-panel .field { margin-bottom: var(--s3); }
  .sig-box { height: 92px; }
  .access-panel input:not([type="checkbox"]) { height: 40px; }
  .access-check { margin: 0 0 var(--s2); }
  .access-check span { font-size: var(--fs-small); line-height: 20px; }
  /* One line kept free for messages, so an error cannot push the page into scrolling. */
  .access-panel .form-error { min-height: 20px; margin: 0 0 var(--s1); }
  .access-panel .form-error[hidden] { display: block !important; visibility: hidden; }
  .btn-access { margin-top: auto; }
}

/* Shorter laptop screens: tighter spacing first, so the page has to shrink less. */
@media (min-width: 1000px) and (max-height: 780px) {
  .nda-page { padding: var(--s2); }
  .nda-card { padding: var(--s3) var(--s5); }
  .nda-head { margin-bottom: var(--s2); }
  .nda-text { padding: var(--s4) var(--s5); }
  .access-panel { padding: var(--s3) var(--s4); }
  .access-lede { margin-bottom: var(--s2); }
  .access-rules { margin-bottom: var(--s2); }
  .access-rules li { padding: 1px 0; }
  .access-note { margin-bottom: var(--s2); }
  .access-panel .field { margin-bottom: var(--s2); }
  .sig-box { height: 72px; }
  .access-panel input:not([type="checkbox"]) { height: 36px; }
}

@media (max-width: 560px) {
  .auth-card { padding: var(--s5); }
  h1 { font-size: 30px; line-height: 36px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}
