/* ============================================
   Itqaan Solutions — Application Form
   Typeform-style full-viewport steps
   ============================================ */

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Progress Bar */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(247, 243, 238, 0.08);
  z-index: var(--z-nav);
}

.progress-bar__fill {
  height: 100%;
  width: 100%;
  /* Compositor-only growth. JS sets --progress (0-1) instead of a width. */
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
  background: var(--rust-fill);
  transition: transform var(--transition-base);
}

/* Header */
.apply-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-md) var(--space-lg);
  z-index: var(--z-nav);
}

.apply-header__logo {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--text-cream);
  text-decoration: none;
  letter-spacing: var(--letter-spacing-snug);
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.apply-header__logo:hover {
  opacity: 1;
}

.apply-header__logo span {
  color: var(--accent-light);
}

/* Main container */
.apply-main {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Steps */
.step {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
  overflow-y: auto;
}

.step.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  z-index: 1;
}

/* The step being left clears faster than the arriving one settles, and on the
   accelerating curve — leaving is the phase nobody needs to watch. */
.step.exit-up {
  opacity: 0;
  transform: translateY(-24px);
  transition: opacity 180ms var(--ease-in), transform 180ms var(--ease-in);
}

.step__content {
  width: 100%;
  max-width: 520px;
}

.step__content--wide {
  max-width: 640px;
  text-align: center;
}

/* Step counter */
.step__counter {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-md);
}

/* Step titles */
.step__headline {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-extrabold);
  letter-spacing: var(--letter-spacing-tight);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-lg);
  color: var(--ink);
}

.step__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-snug);
  line-height: var(--line-height-snug);
  margin-bottom: var(--space-xl);
  color: var(--ink);
}

.step__subtext {
  font-size: var(--font-size-md);
  color: var(--text-muted);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-xl);
}

.step__hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: calc(-1 * var(--space-md));
  margin-bottom: var(--space-lg);
}

/* Video embed */
.step__video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin-bottom: var(--space-xl);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(247, 243, 238, 0.04);
}

.step__video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Form fields */
.step__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

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

.field--other {
  margin-top: var(--space-md);
  margin-bottom: var(--space-lg);
}

.field__label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.field__input {
  width: 100%;
  padding: var(--space-sm) 0;
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-light);
  transition: border-color var(--transition-fast);
}

/* Placeholders are text. 0.2 alpha was roughly 1.6:1. */
.field__input::placeholder {
  color: rgba(247, 243, 238, 0.55);
}

.field__input:focus-visible {
  border-bottom-color: var(--rust-on-dark);
  outline: 2px solid var(--rust-on-dark);
  outline-offset: 4px;
}

.field__input.invalid {
  border-bottom-color: var(--error-on-dark);
}

.field__textarea {
  resize: vertical;
  min-height: 120px;
  border: 2px solid rgba(247, 243, 238, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  line-height: var(--line-height-normal);
}

.field__textarea:focus-visible {
  border-color: var(--rust-on-dark);
}

.field__error {
  font-size: var(--font-size-xs);
  color: var(--error-on-dark);
  min-height: 1.2em;
  margin-top: var(--space-xs);
}

/* Option cards (single & multi select) */
.step__options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.option-card {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-cream);
  background: rgba(247, 243, 238, 0.04);
  border: 2px solid rgba(247, 243, 238, 0.1);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast);
}

.option-card:hover {
  background: rgba(247, 243, 238, 0.08);
  border-color: rgba(247, 243, 238, 0.28);
}

.option-card.selected {
  background: var(--vermilion-tint);
  border-color: var(--accent-primary);
  color: var(--text-light);
}

/* Navigation */
.step__nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(247, 243, 238, 0.06);
  border: 1px solid rgba(247, 243, 238, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast);
  flex-shrink: 0;
}

.btn-back:hover {
  background: rgba(247, 243, 238, 0.1);
  color: var(--text-light);
}

.btn-continue,
.btn-continue--start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-xl);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  /* Was pure white on --rust (4.68:1 by luck). The system has no pure white. */
  color: var(--ink);
  background: var(--rust-fill);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast);
  height: 44px;
}

.btn-continue:hover,
.btn-continue--start:hover {
  background: var(--rust-fill-hover);
}

.btn-continue:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-continue--start {
  padding: var(--space-md) var(--space-2xl);
  font-size: var(--font-size-md);
  height: 52px;
  border-radius: var(--radius-lg);
}

.btn-continue--submit {
  background: var(--sage);
}

.btn-continue--submit:hover {
  background: var(--gold);
}

/* Keyboard hint */
.step__nav::after {
  content: "or press Enter";
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-left: var(--space-sm);
  opacity: 0.6;
}

/* Redirect modal */
.redirect-modal[hidden] {
  display: none;
}

.redirect-modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-lg);
}

.redirect-modal__box {
  background: var(--bg-cream);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

/* Was a run of inline styles on the element. */
.redirect-modal__link--button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-family: inherit;
}

/* ── Modal entrance ──────────────────────────
   `hidden` still controls display and the a11y tree; .is-open drives the
   transition and is applied one frame later by showModal() in scripts/apply.js.
   transform-origin stays at its default centre: modals are not anchored to a
   trigger, so scaling from a point would invent a spatial story that isn't there. */
.redirect-modal {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.redirect-modal.is-open { opacity: 1; }

.redirect-modal__box {
  opacity: 0;
  transform: scale(0.97);
  /* 40ms behind the backdrop so the ground establishes first. Never scale(0). */
  transition: opacity 280ms var(--ease) 40ms,
              transform 280ms var(--ease) 40ms;
}
.redirect-modal.is-open .redirect-modal__box {
  opacity: 1;
  transform: none;
}

.redirect-modal__icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-tint);
  border: 3px solid var(--sage);
  border-radius: 50%;
  margin: 0 auto var(--space-lg);
  color: var(--sage);
}

.redirect-modal__icon svg {
  width: 32px;
  height: 32px;
}

.redirect-modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  letter-spacing: var(--letter-spacing-snug);
}

.redirect-modal__text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: var(--line-height-relaxed);
}

.redirect-modal__countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 3px solid var(--accent-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--accent-dark);
  margin-bottom: var(--space-lg);
}

.redirect-modal__link {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--accent-primary);
  font-weight: var(--font-weight-medium);
}

.redirect-modal__link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* Urgency banner */
.urgency-banner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--vermilion-tint);
  border: 1px solid var(--crease-gold);
  border-radius: var(--radius-full);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--accent-light);
  margin-bottom: var(--space-md);
}

.urgency-banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

/* Inline testimonial */
.testimonial-inline {
  margin-top: var(--space-xl);
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-lg);
  background: rgba(247, 243, 238, 0.04);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  text-align: left;
  max-width: 540px;
}

.testimonial-inline__quote {
  font-size: var(--font-size-sm);
  color: rgba(245, 241, 237, 0.8);
  line-height: var(--line-height-relaxed);
  font-style: italic;
  margin-bottom: var(--space-md);
}

.testimonial-inline__author {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.testimonial-inline__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--vermilion-tint);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.testimonial-inline__name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-cream);
}

.testimonial-inline__role {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Mobile */
@media (max-width: 640px) {
  .step {
    padding: var(--space-2xl) var(--space-md) var(--space-xl);
    align-items: flex-start;
    padding-top: calc(var(--space-3xl) + var(--space-lg));
  }

  .step__headline {
    font-size: var(--font-size-2xl);
  }

  .step__title {
    font-size: var(--font-size-lg);
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .field__input {
    font-size: var(--font-size-md);
  }

  .step__nav::after {
    display: none;
  }

  .btn-continue--start {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .step__headline {
    font-size: var(--font-size-xl);
  }
}

/* "(optional)" inside a field label. Was an inline opacity:0.5, which dropped
   this text to roughly 3.4:1 on the dark ground. */
.field__label-opt {
  font-weight: var(--font-weight-regular);
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

/* Submit failure notice — sits under the submit button, announced on appear. */
.submit-error {
  margin-top: var(--space-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  color: var(--error-on-dark);
}
.submit-error a { color: inherit; text-decoration: underline; text-underline-offset: 0.2em; }

/* Modal note — was an inline #888 that answered to no token. */
.redirect-modal__note {
  font-size: var(--font-size-xs);
  color: var(--paper-muted);
  margin-bottom: var(--space-md);
}

/* ============================================
   Focus + reduced motion
   apply.html does not load main.css, so this surface carries its own copy of
   the two global layers. Ring uses the on-dark rust: this page sits on --paper.
   ============================================ */
:focus-visible {
  outline: 2px solid var(--rust-on-dark);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--gold); color: var(--sumi); }
:root { accent-color: var(--rust-fill); caret-color: var(--rust-on-dark); }

/* ── Press feedback ──────────────────────── */
.btn-continue:active,
.btn-continue--start:active,
.btn-back:active,
.redirect-modal__link:active {
  transform: scale(0.97);
}
/* Option cards are wide; a uniform 0.97 reads as a bigger jump on a long
   target, so they scale less. */
.option-card:active { transform: scale(0.985); }
/* A disabled control must not answer a press. */
.btn-continue:disabled:active,
.btn-continue--start:disabled:active { transform: none; }

/* ── Invalid answer ───────────────────────────
   The container refuses the press. Movement only; .invalid carries the colour.
   Lives here, not in a runtime-injected <style>, so the reduced-motion block
   below can actually reach it. */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake 400ms var(--ease); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  /* The refusal stops moving; .invalid still colours the field. */
  .shake { animation: none; }
  /* Progress still moves — it is the state — it just arrives without travel. */
  .progress-bar__fill { transition: none; }
  .step { transition: none; }
  .btn-continue:hover,
  .btn-continue--start:hover { transform: none; }

  /* Press feedback drops its movement; colour still answers the press. */
  .btn-continue:active,
  .btn-continue--start:active,
  .btn-back:active,
  .option-card:active,
  .redirect-modal__link:active { transform: none; }

  /* The modal still fades in — appearing from nothing is the jarring thing we
     are fixing — but the card no longer scales or waits. */
  .redirect-modal__box {
    transform: none;
    transition: opacity var(--dur-fast) var(--ease);
  }
  .redirect-modal.is-open .redirect-modal__box { transform: none; }
}


/* ============================================================================
   "One Sheet, Folded" — world override
   ============================================================================
   Appended, not merged: every rule below is presentational, so the apply flow's
   markup, field names, ids and JavaScript hooks stay exactly as they were. The
   Supabase wiring and the redirects are deliberately untouched.
   ========================================================================== */

/* Paper does not round. */
.apply-header,
.step,
.step__content,
.option-card,
.field__input,
.field__textarea,
.btn-continue,
.btn-back,
.progress-bar,
.progress-bar__fill,
.redirect-modal__box,
.redirect-modal__link { border-radius: 0; }

.step__headline,
.step__title,
.redirect-modal__title {
  font-family: var(--font-display);
  font-weight: 300;
  letter-spacing: -0.02em;
}

.step__counter,
.field__label,
.step__hint,
.redirect-modal__countdown,
.redirect-modal__note {
  font-family: var(--font-mono);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  font-size: var(--text-3xs);
}

/* The mark: this world's button — a stamped block, with the crease under it. */
.btn-continue,
.redirect-modal__link {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  background: var(--fold-white);
  color: var(--sumi);
  border: 0;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-fold);
}
.btn-continue:hover:not(:disabled),
.redirect-modal__link:hover { background: var(--gold); color: var(--sumi); }
.btn-continue:active:not(:disabled) { transform: scale(0.985); }

.btn-back,
.redirect-modal__link--button {
  font-family: var(--font-mono);
  font-size: var(--text-3xs);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  background: transparent;
  color: var(--light-muted);
  box-shadow: inset 0 0 0 1px var(--crease-on-dark);
}
.btn-back:hover { color: var(--fold-white); box-shadow: inset 0 0 0 1px var(--light-muted); }

/* Options are creased panels, not chips. */
.option-card {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--crease-on-dark);
  color: var(--fold-white);
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.option-card:hover { box-shadow: inset 0 0 0 1px var(--light-muted); }
.option-card.active,
.option-card[aria-pressed="true"] {
  background: var(--fold-white);
  color: var(--sumi);
  box-shadow: none;
}

.field__input,
.field__textarea {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--crease-on-dark);
  color: var(--fold-white);
}
.field__input:focus,
.field__textarea:focus { border-bottom-color: var(--gold); }

/* Progress is folds completed, so it is marked in gold. */
.progress-bar { background: var(--light-ghost); }
.progress-bar__fill { background: var(--gold); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }


/* The crane mark. On sumi it flies as a fold-white silhouette. */
.brand-mark, .brand-mark img {
  display: inline-block;
  height: 24px;
  width: auto;
  vertical-align: middle;
  margin-right: 0.4em;
}

/* Reveals the body the inline <style> in each page's <head> hid until this
   sheet arrived, and cancels its 3s fallback. */
body { visibility: visible; animation: none; }
