/* ==========================================================================
   "Start a project" popup
   Used on every page. Built from the site tokens (--surface, --ink, --line…),
   so it follows light and dark mode automatically.
   ========================================================================== */

/* Stop the page behind the popup from scrolling. */
html.pb-lock {
  overflow: hidden;
}

/* The <dialog> is only the frame and backdrop; .pb-panel is the visible card. */
.pb {
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  margin: auto; /* the site-wide `* { margin: 0 }` reset would otherwise pin it top-left */
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}
.pb::backdrop {
  background: rgba(6, 9, 20, 0.7);
  backdrop-filter: blur(6px);
}
.pb[open] {
  animation: pb-in 0.45s var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
}
.pb[open]::backdrop {
  animation: pb-fade 0.3s ease;
}
@keyframes pb-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
}
@keyframes pb-fade {
  from {
    opacity: 0;
  }
}

.pb-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 880px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r, 26px);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  outline: none;
}

/* Close (X) -------------------------------------------------------------- */
.pb-x {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 0.3s var(--ease, ease),
    background 0.2s,
    color 0.2s;
}
.pb-x:hover {
  background: var(--ink);
  color: var(--bg);
  transform: rotate(90deg);
}
.pb-x:focus-visible,
.pb-chips input:focus-visible + span {
  outline: 3px solid var(--a);
  outline-offset: 2px;
}
/* Fields: a soft ring instead of a heavy outline */
.pb input:focus-visible,
.pb select:focus-visible,
.pb textarea:focus-visible {
  outline: none;
  border-color: var(--a);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 22%, transparent);
}

/* Header ----------------------------------------------------------------- */
.pb-head {
  padding: 24px 72px 2px 28px;
}
.pb-head h2 {
  margin: 0;
  font-family: Outfit, Figtree, system-ui, sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

/* Form ------------------------------------------------------------------- */
.pb-form {
  display: flex;
  flex-direction: column;
  min-height: 0; /* lets .pb-body scroll instead of growing the panel */
}
.pb-body {
  flex: 1;
  padding: 12px 28px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pb-field {
  min-width: 0;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.pb-field label,
.pb-field legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-family: Figtree, system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}
.pb-opt {
  margin-left: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}
.pb-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.pb-row3 {
  grid-template-columns: 1.15fr 1fr 1fr;
}
.pb input[type='text'],
.pb input[type='email'],
.pb select,
.pb textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-family: Figtree, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  transition: border-color 0.2s;
}
.pb input:hover,
.pb select:hover,
.pb textarea:hover {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
}
.pb textarea {
  min-height: 92px;
  resize: vertical;
}
.pb select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238e97b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.pb ::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

/* Project-type chips */
.pb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.pb-chips label {
  position: relative;
  margin: 0;
}
.pb-chips input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.pb-chips span {
  display: block;
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-family: Figtree, system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s;
}
.pb-chips span:hover {
  border-color: var(--ink);
}
.pb-chips input:checked + span {
  background: var(--sel, var(--ink));
  border-color: var(--sel, var(--ink));
  color: var(--on-a, var(--bg));
}

/* Footer: actions + status ---------------------------------------------- */
.pb-foot {
  padding: 12px 28px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.pb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pb .pb-actions .btn {
  justify-content: center;
  padding: 12px 20px;
  font-family:
    Figtree,
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}
.pb-actions .btn:first-child {
  flex: 1 1 160px;
}
.pb .pb-wa {
  background: #25d366;
  border-color: #25d366;
  color: #08210f;
}
.pb .pb-wa:hover {
  background: #1fbd5b;
  border-color: #1fbd5b;
  color: #08210f;
}
.pb-ico {
  flex: none;
}
.pb-status {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.pb-status.pb-error {
  color: #d6336c;
}

/* Phones: slide up from the bottom as a sheet --------------------------- */
@media (max-width: 640px) {
  .pb {
    width: 100vw;
    margin: auto 0 0;
  }
  .pb-panel {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
  }
  .pb[open] {
    animation-name: pb-sheet;
  }
  @keyframes pb-sheet {
    from {
      transform: translateY(40px);
      opacity: 0;
    }
  }
  .pb-head {
    padding: 20px 64px 0 20px;
  }
  .pb-body {
    padding: 10px 20px 2px;
  }
  .pb-foot {
    padding: 10px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .pb textarea {
    min-height: 80px;
  }
  .pb-row {
    gap: 0 10px;
  }
  /* Company on its own line, budget and timeline side by side */
  .pb-row3 {
    grid-template-columns: 1fr 1fr;
  }
  .pb-row3 .pb-field:first-child {
    grid-column: 1 / -1;
  }
  .pb-actions {
    gap: 8px;
  }
  .pb-actions .btn {
    flex: 1 1 calc(50% - 4px);
    padding: 11px 16px;
  }
  .pb-actions .btn:first-child {
    flex-basis: 100%;
  }
  /* The footer note is desktop-only; live messages (Copied…) still show. */
  .pb-status:not(.pb-live) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb[open],
  .pb[open]::backdrop {
    animation: none;
  }
  .pb-x:hover {
    transform: none;
  }
}
