/*
 * GoWay driver signup — standalone page styled to match gowayapp.net.
 * Tokens are lifted from goway-front/src/index.css light (:root) set: clean
 * near-white canvas, deeper logo greens that clear WCAG AA on white.
 */

:root {
  --background: oklch(0.992 0.003 160);
  --foreground: oklch(0.21 0.02 165);
  --card: oklch(1 0 0);
  --muted-foreground: oklch(0.48 0.015 165);
  --brand: oklch(0.53 0.15 152);
  --brand-bright: oklch(0.63 0.17 146);
  --brand-deep: oklch(0.43 0.12 153);
  --brand-foreground: oklch(0.99 0.01 150);
  --destructive: oklch(0.58 0.22 27);
  --border: oklch(0.9 0.01 165);
  --input: oklch(0.985 0.004 160);
  --ring: oklch(0.55 0.15 151);

  --radius: 0.75rem;
  --font-sans: 'Geist', 'Readex Pro', system-ui, sans-serif;
  --font-heading: 'Readex Pro', 'Geist', system-ui, sans-serif;
}

* { box-sizing: border-box; border-color: var(--border); }

/* hidden must beat any display set by layout rules (e.g. the step-2 grid) */
[hidden] { display: none !important; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-heading); /* Arabic-first page: Readex Pro leads */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Decorative background ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Faint brand-tinted dot grid, fading out toward the center so the form stays calm */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    color-mix(in oklch, var(--brand) 22%, transparent) 1px,
    transparent 1px
  );
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 42%, transparent 30%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 42%, transparent 30%, black 100%);
}

/* Dashed trip route with pins */
.bg-route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: color-mix(in oklch, var(--brand) 45%, transparent);
}

.route-path { opacity: 0.55; }

.pin-halo { fill: color-mix(in oklch, var(--brand) 12%, transparent); }
.pin-dot  { fill: color-mix(in oklch, var(--brand) 55%, transparent); }
.pin-mark { fill: color-mix(in oklch, var(--brand) 30%, transparent); }
.pin-hole { fill: var(--background); }

/* Swap the route drawing by viewport shape: the wide 1440×900 drawing is
   cropped with "slice", which throws its pins off-screen on tall/narrow
   viewports — so phones get a 440×900 drawing composed for portrait instead.
   (Kept slightly fainter there since it sits closer to the content.) */
.bg-route--portrait { display: none; }

@media (max-width: 640px) {
  .bg-route--landscape { display: none; }
  .bg-route--portrait { display: block; opacity: 0.6; }
}

/* ---------- Header / footer ---------- */

.site-header {
  display: flex;
  justify-content: center;
  padding: 1.25rem 1.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.logo img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  object-fit: cover;
  box-shadow: 0 0 0 1px oklch(0 0 0 / 10%);
}

.wordmark {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.wordmark .brand { color: var(--brand); }

.site-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

/* ---------- Layout ---------- */

.main {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
  padding: 1rem 1.25rem 3rem;
  transition: max-width 0.3s ease;
}

/* Step 2 grows with the progressive reveal: it starts narrow (just the vehicle
   type select), widens when the category select appears, and opens to the full
   horizontal docs grid once the uploads are revealed. The .main max-width
   transition (declared above) animates each jump. */
body.is-step-2 .main { max-width: 34rem; }
body.is-step-2 .main:has(#category-field:not([hidden])) { max-width: 40rem; }
body.is-step-2 .main:has(#docs-section:not([hidden])) { max-width: 60rem; }

.intro { text-align: center; margin-bottom: 1.75rem; }

.intro h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.text-brand-gradient {
  background: linear-gradient(100deg, var(--brand-bright), var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro p { margin: 0; color: var(--muted-foreground); }

/* The GoWay mark inside the intro line, same treatment as the header wordmark */
.intro-brand {
  display: inline-block;
  font-weight: 600;
  color: var(--foreground);
}

.intro-brand span { color: var(--brand); }

/* ---------- Sales pitch under the form (step 1 only) ---------- */

.pitch { margin-top: 2.5rem; }

/* Step 1 sales pitch only — gone the moment the wizard advances (and it stays
   gone on the success panel, which is only reached from step 2). */
body.is-step-2 .pitch { display: none; }

.pitch-title {
  margin: 0 0 1.25rem;
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 4vw, 1.55rem);
  font-weight: 700;
  text-align: center;
}

.benefits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.benefit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: 1rem 0.7rem;
  /* Slightly translucent so the dot grid glows through, like a glass tile */
  background: color-mix(in oklch, var(--card) 72%, transparent);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.benefit-icon {
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  flex-shrink: 0;
  border-radius: 1rem;
  color: var(--brand);
  background: linear-gradient(
    135deg,
    color-mix(in oklch, var(--brand-bright) 16%, transparent),
    color-mix(in oklch, var(--brand) 9%, transparent)
  );
  border: 1px solid color-mix(in oklch, var(--brand) 25%, transparent);
}

.benefit-icon svg { width: 1.5rem; height: 1.5rem; }

.benefit h3 {
  margin: 0 0 0.15rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
}

.benefit p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

/* Staggered entrance on load */
@media (prefers-reduced-motion: no-preference) {
  .benefit {
    animation: rise 0.55s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  }
  .benefit:nth-child(2) { animation-delay: 0.08s; }
  .benefit:nth-child(3) { animation-delay: 0.16s; }
}

/* «انضم الآن» — scrolls back up to the form. Narrower than the form's
   full-width submit so it reads as a call-out, not another form control. */
.join {
  display: block;
  width: auto;
  min-width: 12rem;
  margin-inline: auto;
  padding-inline: 2.5rem;
}

/* Phones: three columns won't fit — switch to compact rows, icon beside copy,
   so the form stays above the fold as much as possible. */
@media (max-width: 560px) {
  .benefits { grid-template-columns: 1fr; gap: 0.55rem; }
  .benefit {
    flex-direction: row;
    text-align: start;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
  }
  .benefit-icon { width: 2.5rem; height: 2.5rem; border-radius: 0.8rem; }
  .benefit-icon svg { width: 1.3rem; height: 1.3rem; }
}

/* ---------- Step indicator ---------- */

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.step-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: color-mix(in oklch, var(--foreground) 18%, transparent);
  transition: background 0.3s, box-shadow 0.3s;
}

.step-dot.is-active {
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brand) 22%, transparent);
}

.step-line {
  width: 3.5rem;
  height: 2px;
  border-radius: 1px;
  background: color-mix(in oklch, var(--foreground) 14%, transparent);
}

/* ---------- Back button (step 2) ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}

.back:hover { color: var(--foreground); }

.back svg { width: 1rem; height: 1rem; }

/* ---------- Step 2: horizontal layout ---------- */

/* Vehicle type + category sit side by side (on mobile too); the back button
   and the docs section span the full row. */
.step[data-step="2"] {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 0.9rem;
  align-items: start;
}

.step[data-step="2"] > .back,
.step[data-step="2"] > #docs-section {
  grid-column: 1 / -1;
}

/* City and area always share a row; until the category select is revealed,
   only the vehicle-type select spans the full row. */
.step[data-step="2"]:has(> #category-field[hidden]) > #type-field {
  grid-column: 1 / -1;
}

/* ---------- Progressive reveal ---------- */

.docs-title {
  margin: 0 0 0.3rem;
  font-weight: 600;
}

/* Supported-files note under the docs title */
.docs-hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

@media (prefers-reduced-motion: no-preference) {
  .reveal-item {
    opacity: 0;
    transform: translateY(14px);
    transition:
      opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .reveal-item.is-in {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Card ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.8);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 14px 40px -24px color-mix(in oklch, var(--foreground) 25%, transparent);
}

/* ---------- Fields ---------- */

.field { margin-bottom: 1.25rem; }

.field > label,
.upload-label {
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.45rem;
}

.upload-label { line-height: 1.35; }

/* On wider screens the slots sit in a row, so reserve two lines: single- and
   double-line labels ("صورة شخصية" vs "صورة عن رخصة القيادة") then start their
   dropzones at the same height. On phones (one slot per row) this is skipped. */
@media (min-width: 561px) {
  .upload-label {
    display: flex;
    align-items: flex-end;
    min-height: 2.8em;
  }
}

input[type="text"],
input[type="tel"],
select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font: inherit;
  color: var(--foreground);
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder { color: color-mix(in oklch, var(--muted-foreground) 75%, transparent); }

input[dir="ltr"] { text-align: start; }

select { appearance: auto; cursor: pointer; }

select:disabled,
input:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Searchable select (city / area) ---------- */

.combo { position: relative; }

.combo input { padding-inline-end: 2.4rem; }

.combo-chevron {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.85rem;
  width: 1rem;
  height: 1rem;
  translate: 0 -50%;
  color: var(--muted-foreground);
  pointer-events: none;
}

.combo-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.35rem);
  inset-inline: 0;
  max-height: 14rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px -20px color-mix(in oklch, var(--foreground) 40%, transparent);
}

.combo-option {
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  border-radius: calc(var(--radius) * 0.6);
  cursor: pointer;
}

.combo-option:hover,
.combo-option.is-active {
  background: color-mix(in oklch, var(--brand) 10%, transparent);
}

.combo-option.is-selected {
  color: var(--brand);
  font-weight: 600;
}

.combo-empty {
  padding: 0.6rem 0.7rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

input:focus-visible,
select:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 30%, transparent);
}

.is-invalid input,
.is-invalid select,
.is-invalid .dropzone {
  border-color: var(--destructive);
}

/* ---------- Uploads ---------- */

.uploads {
  display: grid;
  /* auto-fit flows the slots by available width: 4 across on the wide step-2
     card, fewer as it narrows, down to a single full-width column on phones —
     no fixed breakpoints, so it never overflows a small screen. */
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem 0.9rem;
  margin-bottom: 1.4rem;
}

/* Phones: stack the two selects and give the card a touch less padding. */
@media (max-width: 560px) {
  .step[data-step="2"] {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
  .card { padding: 1.4rem 1.15rem; }
}

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

.dropzone {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  min-height: 3.9rem;
  padding: 0.8rem 0.95rem;
  text-align: start;
  cursor: pointer;
  color: var(--muted-foreground);
  background: color-mix(in oklch, var(--input) 60%, transparent);
  border: 1.5px dashed color-mix(in oklch, var(--foreground) 22%, transparent);
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  overflow: hidden;
}

.dropzone:hover {
  border-color: var(--brand);
  color: var(--foreground);
}

.dropzone .icon { width: 1.35rem; height: 1.35rem; flex-shrink: 0; }

.dz-text { font-size: 0.85rem; line-height: 1.35; }

/* Uploaded-state checkmark badge, floating over the zone's corner */
.dz-check {
  position: absolute;
  top: 0.45rem;
  inset-inline-end: 0.45rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  color: var(--brand-foreground);
  background: var(--brand);
  box-shadow: 0 2px 8px -2px color-mix(in oklch, var(--brand) 60%, transparent);
}

.dz-check svg { width: 0.9rem; height: 0.9rem; }

@media (prefers-reduced-motion: no-preference) {
  .dz-check { animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
  @keyframes pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
}

/* When a file is chosen the zone gets a brand edge + green tint (no thumbnail) */
.upload-field.has-file .dropzone {
  border-style: solid;
  border-color: color-mix(in oklch, var(--brand) 55%, transparent);
  color: var(--brand);
  background: color-mix(in oklch, var(--brand) 7%, transparent);
}


/* ---------- Errors ---------- */

.error {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--destructive);
}

.form-error { margin-bottom: 1rem; font-size: 0.9rem; }

/* ---------- Submit ---------- */

.submit {
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--brand-foreground);
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

.submit:hover { filter: brightness(1.08); }
.submit:active { transform: translateY(1px); }

.submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none;
}

.submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 40%, transparent);
}

/* ---------- Success panel ---------- */

.success { text-align: center; }

.success-icon {
  width: 3rem;
  height: 3rem;
  color: var(--brand);
  margin-bottom: 0.5rem;
}

.success h2 {
  font-family: var(--font-heading);
  margin: 0 0 0.4rem;
}

.success p { margin: 0; color: var(--muted-foreground); }

@media (prefers-reduced-motion: no-preference) {
  .success { animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }
}
