/* HeyHi design system: popups (<dialog class="dialog">) and the contact form inside shared/_contact_dialog.
 * A dialog is a light sheet over whatever band opened it, so it sets the day tokens itself. */

.dialog {
  --fg: var(--day-text); --muted: var(--day-muted); --faint: var(--day-faint);
  --line: var(--day-line); --line-strong: var(--day-line-strong);
  --surface: var(--day-1); --surface-2: var(--day-2);
  --accent-text: var(--voice-deep); --signal-text: var(--signal-deep); --ok-text: var(--ok-deep); --no-text: var(--no-deep);
  width: min(600px, calc(100% - 24px)); max-width: none; max-height: calc(100dvh - 24px);
  margin: auto; padding: 0; border: 0; overflow: visible;
  background: transparent; color: var(--fg); color-scheme: light;
}
.dialog::backdrop { background: rgba(0, 10, 22, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog[open] { animation: dialog-in 0.35s var(--ease); }
.dialog[open]::backdrop { animation: dialog-fade 0.3s ease; }
.dialog :focus-visible { outline-color: var(--voice-deep); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes dialog-fade { from { opacity: 0; } }

/* The panel scrolls when the screen is short; the <dialog> around it has no padding, so a click on the dialog
   itself is a click on the backdrop (dialogs#closeOnBackdrop). */
.dialog-panel {
  position: relative; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(22px, 4.4vw, 38px);
  border-radius: var(--r-lg); background: var(--day-1);
  box-shadow: 0 0 0 1px rgba(5, 26, 48, 0.08), 0 40px 120px -20px rgba(0, 8, 20, 0.6);
}
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-title { padding-top: 3px; font-size: clamp(1.55rem, 1.35rem + 0.8vw, 1.9rem); font-stretch: 110%; font-weight: 740; letter-spacing: -0.03em; line-height: 1.1; }
.dialog-close {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; margin: -2px -6px 0 0; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.dialog-close:hover { background: var(--day-0); border-color: var(--line-strong); }
.dialog-close .icon { width: 18px; height: 18px; }
.dialog-subtitle { margin-top: 10px; max-width: 32em; font-size: 15.5px; line-height: 1.55; color: var(--muted); }

/* ---------- The contact form ---------- */
.contact-form { container-type: inline-size; display: grid; gap: 18px; margin-top: clamp(22px, 3vw, 28px); }

/* Paired fields sit side by side once the form is wide enough */
.form-row { display: grid; gap: 18px; }
@container (min-width: 30rem) { .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.form-field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.form-label { font-size: 13.5px; font-weight: 620; line-height: 1.3; color: var(--fg); }
.form-optional { font-weight: 450; color: var(--faint); }

/* 16px text, so phones don't zoom in on a field */
.form-input {
  width: 100%; min-width: 0; min-height: 46px; padding: 11px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--day-1);
  font-size: 16px; line-height: 1.4; color: var(--fg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:hover { border-color: color-mix(in srgb, var(--day-line-strong) 70%, var(--day-muted)); }
.form-input:focus { outline: none; border-color: var(--voice-deep); box-shadow: 0 0 0 3px color-mix(in srgb, var(--voice) 30%, transparent); }
.form-input[aria-invalid="true"] { border-color: var(--no-deep); }
.form-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--no) 28%, transparent); }
textarea.form-input { min-height: 116px; resize: vertical; line-height: 1.5; }

/* A select draws its own chevron from the icon sprite, and reads as a hint until something is chosen */
.form-select { position: relative; display: block; }
.form-select .form-input { appearance: none; padding-right: 42px; cursor: pointer; text-overflow: ellipsis; }
.form-select .form-input:has(option[value=""]:checked) { color: var(--faint); }
.form-select option { color: var(--day-text); }
.form-select__icon { position: absolute; top: 50%; right: 14px; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }

.form-error { font-size: 13px; font-weight: 520; line-height: 1.45; color: var(--no-deep); }

/* People never see the trap field; bots fill it in */
.form-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-top: 4px; }
.form-note { flex: 1 1 14rem; max-width: 21rem; font-size: 13px; line-height: 1.5; color: var(--muted); }
.form-note a { color: var(--accent-text); font-weight: 560; text-underline-offset: 2px; white-space: nowrap; }
.form-submit { flex: none; min-width: 10.5rem; }
@container (max-width: 29.99rem) {
  .form-foot { flex-direction: column-reverse; align-items: stretch; }
  .form-submit { width: 100%; }
  .form-note { flex: none; max-width: none; text-align: center; }
}

.form-status { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14.5px; line-height: 1.5; animation: dialog-fade 0.3s ease; }
.form-status-error { color: var(--no-deep); background: color-mix(in srgb, var(--no) 9%, var(--day-1)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--no-deep) 22%, transparent); }
.form-status-success { color: var(--ok-deep); background: color-mix(in srgb, var(--ok) 12%, var(--day-1)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok-deep) 22%, transparent); }

/* Once sent, the form gives way to the confirmation and a button to close the dialog */
.form-sent-icon, .form-done { display: none; }
.contact-form.is-sent { gap: 14px; justify-items: start; margin-top: 22px; }
.contact-form.is-sent > :not(.form-status, .form-done, .form-sent-icon) { display: none; }
.contact-form.is-sent .form-sent-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  background: color-mix(in srgb, var(--ok) 20%, var(--day-1)); color: var(--ok-deep); animation: dialog-in 0.4s var(--ease);
}
.form-sent-icon .icon { width: 26px; height: 26px; }
.contact-form.is-sent .form-status { padding: 0; background: none; box-shadow: none; font-size: 1.2rem; font-weight: 620; letter-spacing: -0.01em; color: var(--fg); }
.contact-form.is-sent .form-done { display: inline-flex; margin-top: 10px; }
.dialog-panel:has(.contact-form.is-sent) .dialog-subtitle { display: none; }
