/* ============================================================
   Modal & Form styles
   Loaded after styles.css. Uses the same design tokens.
   ============================================================ */

/* -------------------- Backdrop & dialog -------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 32px 32px 28px;
    transform: translateY(20px) scale(0.98);
    transition: transform 0.25s ease;
}
.modal-backdrop.open .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.modal-close:hover {
    background: var(--canvas-2);
    color: var(--ink);
}
.modal-close:focus-visible {
    outline: 2px solid var(--teal-500);
    outline-offset: 2px;
}
.modal-close svg { width: 18px; height: 18px; }

/* -------------------- Header -------------------- */
.modal-header {
    margin-bottom: 22px;
    padding-right: 36px; /* leave room for close button */
}
.modal-header h2 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.25;
}
.modal-header p {
    margin: 0;
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.55;
}

/* -------------------- Form body -------------------- */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-row {
    display: grid;
    gap: 16px;
}
.form-row.two-col {
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) {
    .form-row.two-col {
        grid-template-columns: 1fr;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.005em;
}
.form-field label .req {
    color: var(--rose);
    margin-left: 2px;
}
.form-field input,
.form-field select,
.form-field textarea {
    font-family: var(--font);
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 13px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    width: 100%;
    line-height: 1.4;
}
.form-field textarea {
    min-height: 90px;
    resize: vertical;
    font-family: var(--font);
}
.form-field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6275' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 12px 12px;
    cursor: pointer;
}
.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover {
    border-color: rgba(20,30,50,0.18);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(20,165,134,0.18);
}

/* Validation state */
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
    border-color: var(--rose);
    background: rgba(240,80,110,0.04);
}
.form-field.has-error input:focus,
.form-field.has-error select:focus,
.form-field.has-error textarea:focus {
    box-shadow: 0 0 0 3px rgba(240,80,110,0.16);
}
.form-error {
    font-size: 12px;
    color: var(--rose);
    margin-top: 2px;
    line-height: 1.4;
    display: none;
}
.form-field.has-error .form-error { display: block; }

/* Honeypot — keep it visually hidden but still focusable to avoid
   "this is a fake field" detection */
.hp-field {
    position: absolute !important;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* -------------------- Submit row -------------------- */
.form-submit {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    /* The button itself uses .btn .btn-primary .btn-lg from styles.css */
}
.form-submit[disabled],
.form-submit.is-loading {
    opacity: 0.75;
    cursor: progress;
    pointer-events: none;
}
.form-submit .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    animation: form-spin 0.7s linear infinite;
}
.form-submit.is-loading .spinner { display: inline-block; }
.form-submit.is-loading .label,
.form-submit.is-loading .btn-arrow { display: none; }
@keyframes form-spin { to { transform: rotate(360deg); } }

.form-foot {
    margin: 4px 0 0;
    font-size: 11px;
    color: var(--ink-faint);
    text-align: center;
    line-height: 1.5;
}
.form-foot a { color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--line); }
.form-foot a:hover { color: var(--teal-700); text-decoration-color: var(--teal-700); }

/* -------------------- Global form-level alert -------------------- */
.form-alert {
    display: none;
    padding: 11px 14px;
    border-radius: 10px;
    background: rgba(240,80,110,0.08);
    border: 1px solid rgba(240,80,110,0.22);
    color: #9f1239;
    font-size: 13px;
    line-height: 1.5;
}
.form-alert.is-visible { display: block; }

/* -------------------- Success state -------------------- */
/* The `hidden` attribute is the source of truth, set by JS. Without this
   rule, our `display: flex` below would override the browser default
   `[hidden] { display: none }` user-agent style and the success block
   would appear alongside the form. */
.form-success[hidden] { display: none !important; }
.form-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 8px 4px;
}
.form-success .icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 10px 22px -8px rgba(13,138,114,0.55);
}
.form-success .icon svg { width: 26px; height: 26px; }
.form-success h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.form-success p {
    margin: 0;
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.6;
    max-width: 360px;
}
.form-success .close-cta {
    margin-top: 22px;
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.form-success .close-cta:hover {
    background: var(--canvas-2);
    border-color: rgba(20,30,50,0.18);
}

/* When success is showing, hide the form */
.modal-form.is-hidden { display: none; }

/* Locks body scroll while modal is open */
html.modal-open, body.modal-open {
    overflow: hidden;
}
