/* KuyaYos — /apply/ page styles
 * Clean professional onboarding form. Inherits brand tokens from styles.css.
 * Distinct from /book/'s docket aesthetic — applicants get a streamlined
 * single-card experience rather than a wizard.
 *
 * CSP: style-src 'self'. No inline styles, no external resources.
 */

.apply {
  padding: 2.5rem 0 4rem;
  background: var(--bg);
}

@media (min-width: 768px) {
  .apply {
    padding: 3.5rem 0 5rem;
  }
}

.apply__intro {
  margin-bottom: 1.75rem;
}

.apply__intro h1 {
  font-size: clamp(2rem, 3vw + 1rem, 2.75rem);
  margin-bottom: 0.85rem;
}

.apply__intro .lede {
  font-size: 1.0625rem;
  color: var(--ink-soft);
  max-width: 60ch;
  line-height: 1.55;
}

/* Form card -------------------------------------------------- */

.apply-card {
  background: var(--paper);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .apply-card {
    padding: 2.25rem;
  }
}

.apply-section {
  border: 0;
  padding: 0;
  margin: 0 0 2rem;
  min-width: 0;
}

.apply-section + .apply-section {
  padding-top: 1.75rem;
  border-top: 1px solid var(--slate-100);
}

.apply-section__title {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand);
  padding: 0;
  margin: 0 0 1.25rem;
  float: none;
}

/* Honeypot — invisible field for catching naive bots */

.honeypot {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Field primitives (kept independent of book.css's docket variants) */

.field {
  margin: 0 0 1.25rem;
  min-width: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.4rem;
}

.field__required {
  color: var(--action);
  margin-left: 0.15rem;
}

.field__optional {
  font-weight: 500;
  margin-left: 0.4rem;
  font-size: 0.875rem;
}

.field__hint {
  display: block;
  font-size: 0.875rem;
  color: var(--slate-500);
  margin: 0 0 0.6rem;
}

.field__error {
  display: block;
  color: #b91c1c;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0.4rem 0 0;
  padding-left: 0.5rem;
  border-left: 3px solid #b91c1c;
}

.field__error[hidden] {
  display: none;
}

.field__control {
  position: relative;
  display: block;
}

.field__control--narrow {
  max-width: 22rem;
}

.apply-card input[type="text"],
.apply-card input[type="tel"],
.apply-card input[type="email"],
.apply-card select,
.apply-card textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  min-height: 52px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.apply-card textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.55;
}

.apply-card select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand) 50%),
    linear-gradient(-45deg, transparent 50%, var(--brand) 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.75rem;
}

.apply-card input:hover,
.apply-card select:hover,
.apply-card textarea:hover {
  border-color: var(--slate-300);
}

.apply-card input:focus-visible,
.apply-card select:focus-visible,
.apply-card textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.4);
}

.apply-card input[aria-invalid="true"],
.apply-card select[aria-invalid="true"],
.apply-card textarea[aria-invalid="true"] {
  border-color: #b91c1c;
}

.apply-card input::placeholder,
.apply-card textarea::placeholder {
  color: var(--slate-500);
  opacity: 1;
}

/* Tile groups (radio + checkbox) ---------------------------- */

.tile-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 560px) {
  .tile-group {
    grid-template-columns: repeat(2, 1fr);
  }
  .tile-group--compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  .tile-group--checkbox {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (min-width: 820px) {
  .tile-group {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tile {
  position: relative;
  display: block;
  border: 2px solid var(--slate-200);
  background: var(--paper);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
  min-height: 56px;
}

.tile:hover {
  border-color: var(--slate-300);
}

.tile input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tile__label {
  display: block;
  padding: 0.85rem 0.95rem;
  position: relative;
}

.tile__title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.25;
}

.tile__sub {
  display: block;
  font-size: 0.8125rem;
  color: var(--slate-500);
  margin-top: 0.15rem;
}

.tile:has(input:checked) {
  background: var(--action-50);
  border-color: var(--action);
}

.tile:has(input:focus-visible) {
  outline: 3px solid var(--action);
  outline-offset: 2px;
}

.tile--compact {
  min-height: 52px;
}

/* Checkbox tile gets a small visible checkmark when selected */
.tile--checkbox {
  padding-right: 1.5rem;
}

.tile--checkbox::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 18px;
  height: 18px;
  border: 2px solid var(--slate-300);
  border-radius: 4px;
  background: var(--paper);
  transform: translateY(-50%);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.tile--checkbox:has(input:checked)::after {
  background: var(--action);
  border-color: var(--action);
  /* checkmark using border tricks */
  background-image:
    linear-gradient(45deg, transparent 50%, #fff 50%, #fff 55%, transparent 55%),
    linear-gradient(-45deg, transparent 60%, #fff 60%, #fff 65%, transparent 65%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.tile--checkbox:has(input:checked)::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  z-index: 1;
  /* draw the actual checkmark on top */
  background-image:
    linear-gradient(135deg, transparent 50%, #fff 50%, #fff 60%, transparent 60%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* Foot — turnstile + consent + submit ----------------------- */

.apply-foot {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--slate-200);
}

.apply-foot .field {
  margin-bottom: 1.25rem;
}

.apply-foot__note {
  text-align: center;
  font-size: 0.875rem;
  margin-top: 1.5rem;
}

.apply-submit {
  width: 100%;
  margin-top: 1.5rem;
}

@media (min-width: 560px) {
  .apply-submit {
    width: auto;
    min-width: 14rem;
  }
}

/* Consent — match book.css's pattern but lighter */

.field--consent {
  margin-bottom: 0;
}

.consent {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 0.85rem;
  align-items: flex-start;
  cursor: pointer;
  padding: 1rem;
  background: var(--brand-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-100);
}

.consent input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.consent__box {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid var(--brand);
  border-radius: 4px;
  background: var(--paper);
  margin-top: 1px;
  position: relative;
  flex-shrink: 0;
}

.consent input[type="checkbox"]:checked + .consent__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 7px;
  height: 12px;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(45deg);
}

.consent input[type="checkbox"]:focus-visible + .consent__box {
  outline: 3px solid var(--action);
  outline-offset: 2px;
}

.consent input[type="checkbox"]:checked + .consent__box {
  background: var(--action);
  border-color: var(--action);
}

.consent__text {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* Linklike (button styled as inline link, used inside consent text) */

.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.linklike:hover {
  color: var(--brand-800);
  text-decoration-thickness: 2px;
}

.linklike:focus-visible {
  outline: 3px solid var(--action);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Mono helper (re-declared so /apply/ doesn't depend on book.css) */

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Success card --------------------------------------------- */

.apply-success {
  background: var(--paper);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
}

@media (min-width: 640px) {
  .apply-success {
    padding: 2.75rem 2.5rem;
  }
}

.success-card__heading {
  margin: 0 0 0.6rem;
  color: var(--brand-900);
  font-size: clamp(1.5rem, 2vw + 1rem, 2rem);
}

.success-card__lede {
  font-size: 1.0625rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  max-width: 58ch;
}

.success-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  background: var(--brand-50);
  border-radius: var(--radius-sm);
  margin: 0 0 1.5rem;
}

@media (min-width: 560px) {
  .success-meta {
    grid-template-columns: repeat(3, 1fr);
  }
}

.success-meta > div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.success-meta dt {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--slate-500);
  margin: 0;
}

.success-meta dd {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  word-break: break-word;
}

.success-meta dd.mono {
  font-size: 1.05rem;
}

.dashed-rule {
  border: 0;
  height: 1px;
  background-image: linear-gradient(
    to right,
    var(--slate-300) 0 6px,
    transparent 6px 12px
  );
  background-size: 12px 1px;
  background-repeat: repeat-x;
  margin: 1.5rem 0;
}

.success-card__subhead {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  margin: 0 0 1rem;
  font-weight: 800;
}

.next-steps {
  display: grid;
  gap: 0.85rem;
  list-style: none;
  counter-reset: next;
  margin: 0 0 0.5rem;
  padding: 0;
}

.next-steps li {
  counter-increment: next;
  position: relative;
  padding-left: 2.5rem;
  padding-top: 0.15rem;
  min-height: 2rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

.next-steps li::before {
  content: counter(next, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.85rem;
  height: 1.85rem;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.8rem;
  font-weight: 800;
}

.next-steps strong {
  color: var(--ink);
}

.success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin: 1.5rem 0 0;
}

/* Privacy dialog -------------------------------------------- */

.privacy-dialog {
  max-width: 36rem;
  width: calc(100% - 2rem);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.privacy-dialog::backdrop {
  background: rgba(15, 28, 36, 0.65);
}

.privacy-dialog article {
  padding: 1.75rem;
}

.privacy-dialog h2 {
  margin: 0 0 1rem;
  color: var(--brand-900);
}

.privacy-dialog p {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.privacy-dialog form {
  margin-top: 1rem;
  text-align: right;
}

/* Noscript fallback ----------------------------------------- */

.noscript-fallback {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 2px dashed var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand-50);
}

.noscript-fallback h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.noscript-fallback ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.5rem 0 0;
}

/* Reduced motion override ----------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .tile {
    transition: none;
  }
}
