/* =========================================================
   CONTACT PAGE — scoped styles
   All rules are prefixed with .contact-* or scoped to
   .contact-page / #contact-form to avoid leaking into
   global styles or other pages.
   ========================================================= */

/* =========================================================
   PAGE ENTRY TRANSITION
   (mirrors .page-loaded pattern used site-wide in app.js)
   ========================================================= */

.contact-page main {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-loaded .contact-page main,
.contact-page.page-loaded main {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   HERO SECTION
   ========================================================= */

/* =========================================================
   HERO — override cs-hero full-viewport height
   ========================================================= */

.contact-hero {
  min-height: 0 !important;
  padding-top: calc(68px + 64px) !important;
  padding-bottom: 64px !important;
  background: #f5f5f3;
}

/* Two-column body below the h1 */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 56px;
  margin-top: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}

/* =========================================================
   PROCESS STEPS — left column
   ========================================================= */

.contact-process {
  padding-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.process-kicker {
  margin: 0 0 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.process-step {
  padding-bottom: 18px;
}

.process-step:not(:last-child) {
  border-bottom: 1px solid rgba(15, 15, 15, 0.08);
  margin-bottom: 18px;
}

.process-step-final {
  border-bottom: none !important;
  margin-bottom: 0 !important;
}

.process-num {
  display: block;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: rgba(0, 241, 170, 0.82);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.process-num::after {
  content: '';
  display: block;
  height: 2px;
  width: 20px;
  background: currentColor;
  opacity: 0.45;
  margin: 10px auto 18px;
}

.process-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.process-desc {
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

/* =========================================================
   TRUSTED BY — logo block below process steps
   ========================================================= */

.contact-trusted {
  margin-top: 0;
  padding-top: 48px;
  border-top: 1px solid rgba(15, 15, 15, 0.08);
}

.contact-trusted-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px;
}

.contact-trusted-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px 28px;
}

.contact-trusted-logos img {
  height: 18px;
  width: auto;
  opacity: 0.4;
  filter: grayscale(100%);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.contact-trusted-logos img:hover {
  opacity: 0.75;
  filter: grayscale(0%);
}

/* =========================================================
   FORM CONTAINER
   White card — grid handles width/centering
   ========================================================= */

.contact-form-container {
  background: rgb(0 241 170 / 65%);
  border-radius: 14px;
  padding: 28px 32px;
  border: 1px solid #f5f5f3;
}

/* =========================================================
   FORM GROUPS
   ========================================================= */

#contact-form .form-group {
  margin-bottom: 10px;
}

#contact-form .form-group:last-child {
  margin-bottom: 0;
}

/* =========================================================
   LABELS
   Accessible, always visible — no placeholder-only inputs
   ========================================================= */

#contact-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

/* Keep semantic labels for accessibility while showing copy in placeholders */
.field-label-inside {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-required-note {
  margin: 14px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.label-required {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #b42318;
  margin-left: 4px;
}

/* =========================================================
   TEXT INPUTS
   ========================================================= */

#contact-form input[type="text"],
#contact-form input[type="email"] {
  display: block;
  width: 100%;
  padding: 7px 11px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: #ffffff;
  border: 1.5px solid #d1d1d1;
  border-radius: 7px;
  outline: none;
  box-sizing: border-box;
  min-height: 36px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

#contact-form input[type="text"]:focus,
#contact-form input[type="email"]:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 241, 170, 0.18);
}

#contact-form input[type="text"]::placeholder,
#contact-form input[type="email"]::placeholder,
#contact-form textarea::placeholder {
  color: #8f949b;
  opacity: 1;
}

#contact-form input.show-inline-error::placeholder,
#contact-form textarea.show-inline-error::placeholder {
  color: #d93025;
}

/* =========================================================
   SELECT WRAPPER
   Positions the custom chevron over the native select
   ========================================================= */

.select-wrapper {
  position: relative;
  display: block;
}

.select-wrapper select {
  display: block;
  width: 100%;
  padding: 7px 36px 7px 11px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: #ffffff;
  border: 1.5px solid #d1d1d1;
  border-radius: 7px;
  outline: none;
  box-sizing: border-box;
  min-height: 36px;
  cursor: pointer;
  /* Remove native arrow */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-wrapper select:required:invalid {
  color: #8f949b;
}

.select-wrapper select.show-inline-error:required:invalid {
  color: #d93025;
}

.select-wrapper select option {
  color: var(--ink);
}

.select-wrapper select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 241, 170, 0.18);
}

/* Default / placeholder option */
.select-wrapper select option[value=""] {
  color: var(--muted);
}

/* Custom chevron icon */
.select-chevron {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 8px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.select-wrapper select:focus + .select-chevron {
  color: var(--brand-teal);
}

/* =========================================================
   FIELD STATE — INVALID
   ========================================================= */

#contact-form input.invalid,
#contact-form .select-wrapper.invalid select {
  border-color: #d93025;
}

#contact-form input.invalid:focus,
#contact-form .select-wrapper.invalid select:focus {
  border-color: #d93025;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12);
}

/* =========================================================
   FIELD STATE — VALID
   ========================================================= */

#contact-form input.valid,
#contact-form .select-wrapper.valid select {
  border-color: #2e7d32;
}

/* =========================================================
   INLINE ERROR MESSAGES
   ========================================================= */

#contact-form .field-error {
  display: block;
  font-size: 0.8125rem;
  color: #d93025;
  margin-top: 6px;
  line-height: 1.4;
  /* Reserve space so layout doesn't shift when error appears */
  min-height: 1.2em;
  /* Transition opacity rather than display to keep height stable */
  opacity: 0;
  transition: opacity 0.2s ease;
}

#contact-form .form-group > .field-error {
  display: none;
}

#contact-form .form-group > .field-error.visible {
  display: block;
}

#contact-form .field-error.visible {
  opacity: 1;
}

/* =========================================================
   RECAPTCHA GROUP
   ========================================================= */

.recaptcha-group {
  /* Slightly less gap above the widget */
  margin-top: 4px;
}

.recaptcha-group .g-recaptcha {
  /* Scale down on very narrow screens without breaking the widget */
  transform-origin: left top;
}

/* =========================================================
   SUBMIT BUTTON
   ========================================================= */

.submit-group {
  margin-top: 8px;
}

.form-privacy-link {
  display: block;
  margin-bottom: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.form-privacy-link a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.form-privacy-link a:hover {
  color: #222222;
}

#submit-btn {
  display: block;
  width: 100%;
  padding: 15px 32px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: #ffffff;
  background: var(--ink);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  min-height: 52px;
  transition:
    background 0.2s ease,
    transform 0.15s ease,
    opacity 0.25s ease;
  -webkit-appearance: none;
  appearance: none;
}

#submit-btn:hover:not(:disabled) {
  background: #222222;
  transform: translateY(-1px);
}

#submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Visible focus ring (keyboard / switch navigation) */
#submit-btn:focus-visible {
  outline: 2.5px solid var(--brand-primary);
  outline-offset: 3px;
}

/* Disabled state — shown until all fields are valid + CAPTCHA checked */
#submit-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

/* Sending state (class added by JS during submission) */
#submit-btn.is-sending {
  opacity: 0.7;
  cursor: wait;
}

/* =========================================================
   SUCCESS MESSAGE
   ========================================================= */

.form-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(0, 241, 170, 0.08);
  border: 1px solid rgba(0, 241, 170, 0.4);
  border-radius: 7px;
  padding: 18px 22px;
  font-size: 0.9375rem;
  color: var(--ink);
  line-height: 1.55;
  /* Animate in */
  animation: successReveal 0.3s ease forwards;
}

.form-success[hidden] {
  display: none;
}

@keyframes successReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   RESPONSIVE — TABLET (max 960px)
   Stack columns, reduce padding
   ========================================================= */

@media (max-width: 960px) {
  .contact-layout {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .contact-form-container {
    order: 1;
  }

  .contact-process {
    order: 2;
  }

  .contact-process {
    padding-top: 0;
    /* Horizontal scroll of steps on mid-size screens */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    column-gap: 32px;
  }

  .process-step {
    padding-bottom: 0;
    border-bottom: none !important;
    margin-bottom: 0 !important;
  }

  .contact-form-container {
    padding: 44px 40px;
  }
}

/* =========================================================
   RESPONSIVE — MOBILE (max 767px)
   ========================================================= */

@media (max-width: 767px) {
  .contact-form-section {
    padding: calc(68px + 48px) 16px 64px;
  }

  .contact-layout {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .contact-process {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .process-step {
    padding-bottom: 28px;
  }

  .process-step:not(:last-child) {
    border-bottom: 1px solid rgba(15, 15, 15, 0.08);
    margin-bottom: 28px;
  }

  .contact-form-container {
    padding: 32px 20px 36px;
    border-radius: 7px;
  }

  /* Full-width button already handled by width:100% above */

  /* Scale reCAPTCHA widget on very small viewports */
  @media (max-width: 360px) {
    .recaptcha-group .g-recaptcha {
      transform: scale(0.88);
    }
  }
}

/* =========================================================
   LABEL — OPTIONAL BADGE
   ========================================================= */

.label-optional {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

/* =========================================================
   TEXTAREA — PROJECT DESCRIPTION
   Inherits all border / radius / focus rules from inputs.
   ========================================================= */

#contact-form textarea {
  display: block;
  width: 100%;
  padding: 7px 11px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: #ffffff;
  border: 1.5px solid #d1d1d1;
  border-radius: 7px;
  outline: none;
  box-sizing: border-box;
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

#contact-form textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 241, 170, 0.18);
}

#contact-form textarea.invalid {
  border-color: #d93025;
}

#contact-form textarea.invalid:focus {
  border-color: #d93025;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12);
}

#contact-form textarea.valid {
  border-color: #2e7d32;
}

/* Footer row: validation error (left) + character counter (right) */
.textarea-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  min-height: 1.2em;
}

/* Error inside textarea-footer reuses the global .field-error rules
   but needs flex-grow so it takes available space */
.textarea-footer .field-error {
  flex: 1 1 auto;
  margin-top: 0; /* override the global margin-top — footer handles spacing */
}

/* Character counter */
.char-counter {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s ease;
  /* Keep counter vertically aligned with the error baseline */
  padding-top: 1px;
}

/* Warn when approaching the limit (≥ 4750 chars) */
.char-counter.is-warning {
  color: #b45309;
}

/* At limit */
.char-counter.is-limit {
  color: #d93025;
  font-weight: 600;
}

/* =========================================================
   FILE UPLOAD — DRAG-AND-DROP ZONE
   ========================================================= */

.upload-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 20px 24px;
  border: 1.5px dashed #c8c8c8;
  border-radius: 7px;
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  /* Ensure the hidden input covers the zone for click delegation */
  overflow: hidden;
}

/* Hidden native file input — stretched to fill the zone so native
   click areas work as a fallback, but JS handles the open() call */
.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  /* Prevent the file input from consuming pointer events —
     JS triggers input.click() from the zone's click handler instead */
  pointer-events: none;
}

/* Hover: subtle teal tint */
.upload-zone:hover {
  border-color: var(--brand-teal);
  background: rgba(0, 241, 170, 0.04);
}

/* Keyboard focus ring (matches submit button pattern) */
.upload-zone:focus-visible {
  outline: 2.5px solid var(--brand-primary);
  outline-offset: 3px;
  border-color: var(--brand-primary);
}

/* Drag-over state — more pronounced highlight */
.upload-zone.drag-over {
  border-color: var(--brand-primary);
  background: rgba(0, 241, 170, 0.08);
  box-shadow: 0 0 0 3px rgba(0, 241, 170, 0.18);
}

/* Invalid file dropped / selected */
.upload-zone.has-error {
  border-color: #d93025;
  background: rgba(217, 48, 37, 0.04);
}

/* ---- Idle state (icon + label) ---- */

.upload-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.upload-icon {
  width: 28px;
  height: 28px;
  color: #9e9e9e;
  transition: color 0.2s ease;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  color: var(--brand-teal);
}

.upload-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.upload-label-title {
  color: #6f7782;
}

.upload-label-optional {
  font-size: 0.85em;
  color: #8f949b;
}

.upload-label-action {
  font-size: 0.88em;
}

/* ---- File selected state (name chip + remove) ---- */

.upload-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
  text-align: left;
}

.upload-file-info[hidden] {
  display: none;
}

.file-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--brand-teal);
}

.upload-filename {
  font-size: 0.9rem;
  color: var(--ink);
  word-break: break-all;
  text-align: left;
  flex: 1 1 auto;
}

/* Remove button */
.upload-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  pointer-events: all; /* override parent */
  transition: background 0.2s ease, color 0.2s ease;
}

.upload-remove svg {
  width: 11px;
  height: 11px;
}

.upload-remove:hover {
  background: rgba(217, 48, 37, 0.12);
  color: #d93025;
}

.upload-remove:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ---- Hint text below the zone ---- */

.upload-hint {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 8px;
  text-align: left;
  line-height: 1.4;
}


/* =========================================================
   RESPONSIVE — MOBILE additions for new fields
   ========================================================= */

@media (max-width: 767px) {
  .upload-zone {
    min-height: 84px;
    padding: 16px 16px;
  }

  .upload-label {
    font-size: 0.875rem;
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .contact-page main,
  #contact-form input,
  #contact-form textarea,
  #contact-form .select-wrapper select,
  #contact-form .field-error,
  .char-counter,
  .upload-zone,
  .upload-icon,
  .upload-remove,
  #submit-btn,
  .form-success {
    transition: none;
    animation: none;
  }
}
