/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --paper:        #FBF9F3;
  --paper-dim:     #F2EEE3;
  --ink:           #232220;
  --ink-soft:      #5B5750;
  --navy:          #1B2A4A;
  --navy-deep:     #11192E;
  --seal:          #2F6F62;
  --seal-deep:     #234F45;
  --gold:          #B98B3E;
  --border:        #DCD5C4;
  --border-strong: #C9BFA6;
  --error:         #B3261E;
  --error-bg:      #FBEAE8;

  --font-display: "Source Serif 4", Georgia, serif;
  --font-body:    "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(27,42,74,0.04), 0 12px 32px -16px rgba(27,42,74,0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper-dim);
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.req { color: var(--error); }

/* =========================================================
   Page shell
   ========================================================= */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =========================================================
   Masthead
   ========================================================= */
.masthead {
  width: 100%;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 3px solid var(--gold);
}

.masthead__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 30px 24px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.masthead__mark {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  color: var(--gold);
}
.masthead__mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.masthead__eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #C9B98F;
}

.masthead__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 4vw, 32px);
  color: #fff;
  letter-spacing: -0.01em;
}

/* =========================================================
   Sheet (the "document" card)
   ========================================================= */
.sheet {
  width: 100%;
  max-width: 880px;
  margin: -18px auto 0;
  padding: 0 24px 56px;
  flex: 1;
}

.sheet__intro {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  margin: 0;
  padding: 22px 28px 18px;
  color: var(--ink-soft);
  font-size: 14.5px;
  position: relative;
  top: 18px;
}

#application-form {
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-card);
  padding: 8px 28px 32px;
  position: relative;
  top: 18px;
}

/* honeypot - visually hidden */
.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* =========================================================
   Field grid
   ========================================================= */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px 24px;
  padding-top: 22px;
}

.field--full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; }

.field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.field label .hint {
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field textarea {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  width: 100%;
}

.field textarea { resize: vertical; min-height: 110px; }

.mono-input { font-family: var(--font-mono); letter-spacing: 0.02em; }

.field input::placeholder,
.field textarea::placeholder { color: #ACA597; }

.field input:hover,
.field textarea:hover { border-color: var(--seal); }

.field input:focus,
.field textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(47,111,98,0.14);
}

.field input.invalid,
.field textarea.invalid {
  border-color: var(--error);
  background: var(--error-bg);
}

.field-error {
  display: none;
  color: var(--error);
  font-size: 12.5px;
  margin-top: 6px;
}
.field-error.visible { display: block; }

/* =========================================================
   Dropzone — "dossier slot" signature element
   ========================================================= */
.field--full + .field--full,
.dropzone-wrapper { margin-top: 4px; }

#dropzone-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  margin: 26px 0 9px;
}

.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(135deg, rgba(47,111,98,0.035) 0 2px, transparent 2px 14px),
    var(--paper);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--seal);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--seal);
  background:
    repeating-linear-gradient(135deg, rgba(47,111,98,0.06) 0 2px, transparent 2px 14px),
    #F1F6F4;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  color: var(--seal);
  margin-bottom: 6px;
}
.dropzone__icon svg { width: 100%; height: 100%; }

.dropzone__title {
  margin: 4px 0 2px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
}

.dropzone__sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* File chips list */
.file-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 12px;
  font-size: 13.5px;
  animation: chip-in 0.18s ease;
}

@keyframes chip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.file-chip__icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--seal);
}
.file-chip__icon svg { width: 100%; height: 100%; }

.file-chip__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.file-chip__size {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  flex-shrink: 0;
}

.file-chip__remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.file-chip__remove:hover { background: var(--error-bg); color: var(--error); }

/* =========================================================
   Consent checkbox
   ========================================================= */
.field--consent { margin-top: 22px; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.checkbox input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.checkbox__box {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--paper);
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.checkbox input:checked + .checkbox__box {
  background: var(--seal);
  border-color: var(--seal);
}
.checkbox input:checked + .checkbox__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox input:focus-visible + .checkbox__box {
  box-shadow: 0 0 0 3px rgba(47,111,98,0.2);
}

.checkbox__text { padding-top: 1px; }

/* =========================================================
   Status banner
   ========================================================= */
.form-status {
  display: none;
  margin-top: 22px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.form-status.visible { display: block; }
.form-status.success { background: #E9F3EE; color: var(--seal-deep); border: 1px solid #BFDDD0; }
.form-status.error   { background: var(--error-bg); color: var(--error); border: 1px solid #E3BAB6; }

/* =========================================================
   Submit — wax-seal stamp button
   ========================================================= */
.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

.seal-btn {
  position: relative;
  border: none;
  background: var(--seal);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 14px 36px 14px 30px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 18px -8px rgba(47,111,98,0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.seal-btn:hover { background: var(--seal-deep); box-shadow: 0 10px 20px -8px rgba(47,111,98,0.6); }

.seal-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 10px -6px rgba(47,111,98,0.5);
}

.seal-btn__ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  flex-shrink: 0;
  position: relative;
}
.seal-btn__ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
}

.seal-btn__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.seal-btn__spinner {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
}

.seal-btn.is-loading .seal-btn__spinner {
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
.seal-btn.is-loading .seal-btn__text { opacity: 0.85; }
.seal-btn[disabled] { cursor: not-allowed; opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }

/* "stamp" press feedback */
.seal-btn.is-stamped::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid var(--seal);
  border-radius: 999px;
  opacity: 0.6;
  animation: stamp-ring 0.5s ease-out forwards;
}
@keyframes stamp-ring {
  from { opacity: 0.6; transform: scale(0.85); }
  to   { opacity: 0; transform: scale(1.25); }
}

/* =========================================================
   Footer
   ========================================================= */
.page-footer {
  width: 100%;
  text-align: center;
  padding: 18px 24px 28px;
}
.page-footer p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .file-chip, .seal-btn, .seal-btn.is-stamped::before, .seal-btn__spinner {
    animation: none !important;
    transition: none !important;
  }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 700px) {
  .masthead__inner { padding: 24px 18px 22px; }
  .sheet { padding: 0 14px 40px; }
  .sheet__intro { padding: 18px 18px 16px; font-size: 14px; }
  #application-form { padding: 6px 18px 26px; }
  .field-grid { grid-template-columns: 1fr; gap: 18px; }
  .actions { justify-content: stretch; }
  .seal-btn { width: 100%; justify-content: center; }
}

@media (max-width: 420px) {
  .masthead__title { font-size: 22px; }
  .dropzone { padding: 22px 14px; }
}
