/* ============================================================
   Botsan — Contact form styles
   assets/css/forms.css
   ============================================================

   Two jobs, one file:

     1. the hosted page at /f/KEY and the iframe embed
     2. the inline embed, injected into somebody else's website

   Job 2 is why every selector here is prefixed .cf- and why nothing styles a
   bare element. This stylesheet lands inside a stranger's page next to their
   own CSS, and a rule on `input` or `button` would silently restyle their
   site. The customer would blame us and be right.

   Colours come from --cf-accent, set on the wrapper by cf_render_html() from
   the value the owner picked. Everything else is a neutral that reads as
   deliberate on a white card and on a dark one.
   ============================================================ */

.cf-form-wrap {
    --cf-accent: #00346C;
    --cf-text: #0f172a;
    --cf-muted: #64748b;
    --cf-line: #d8dee9;
    --cf-line-strong: #94a3b8;
    --cf-bg: #ffffff;
    --cf-field-bg: #ffffff;
    --cf-error: #dc2626;
    --cf-radius: 10px;

    box-sizing: border-box;
    max-width: 640px;
    margin: 0 auto;
    color: var(--cf-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, "Noto Sans", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
}

.cf-form-wrap *,
.cf-form-wrap *::before,
.cf-form-wrap *::after { box-sizing: border-box; }

/* ── Heading ───────────────────────────────────────────────── */

.cf-form-head { margin-bottom: 1.5rem; }

.cf-form-title {
    margin: 0 0 .5rem;
    font-size: 1.5rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--cf-text);
}

.cf-form-intro {
    margin: 0;
    color: var(--cf-muted);
    font-size: .95rem;
}

/* ── Layout ────────────────────────────────────────────────── */

.cf-form { margin: 0; }

.cf-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.cf-field { min-width: 0; }
.cf-field.cf-full { grid-column: 1 / -1; }

/* One column on a narrow screen — and on a narrow CONTAINER, because the
   inline embed often sits in a 380px sidebar on a 1440px monitor, where a
   media query would still show two columns. */
@media (max-width: 560px) {
    .cf-grid { grid-template-columns: minmax(0, 1fr); }
    .cf-submit { width: 100%; min-height: 48px; font-size: 1rem; }
}
@supports (container-type: inline-size) {
    .cf-form-wrap { container-type: inline-size; }
    @container (max-width: 480px) {
        .cf-grid { grid-template-columns: minmax(0, 1fr); }
        .cf-submit { width: 100%; min-height: 48px; font-size: 1rem; }
    }
}

/* ── Labels and inputs ─────────────────────────────────────── */

.cf-label {
    display: block;
    margin-bottom: .375rem;
    font-size: .8125rem;
    font-weight: 600;
    color: #334155;
}

.cf-req { color: var(--cf-error); }

.cf-input {
    display: block;
    width: 100%;
    padding: .625rem .75rem;
    border: 1px solid var(--cf-line);
    border-radius: var(--cf-radius);
    background: var(--cf-field-bg);
    color: var(--cf-text);
    font: inherit;
    line-height: 1.4;

    /* iOS zooms the page in when a focused field is under 16px. Setting the
       base to 15px and bumping only the control is what keeps the layout
       compact without the zoom. */
    font-size: 16px;

    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s, box-shadow .15s;
}

.cf-input::placeholder { color: #a3aec0; }

.cf-input:hover:not(:focus) { border-color: var(--cf-line-strong); }

.cf-input:focus {
    outline: none;
    border-color: var(--cf-accent);
    /* colour-mix keeps the focus ring in the owner's accent without needing
       a second stored colour. Browsers without it fall back to the plain
       border change above, which is still a visible focus state. */
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cf-accent) 22%, transparent);
}

.cf-textarea { min-height: 130px; resize: vertical; }

.cf-select {
    /* Room for the chevron, which is a background image so no extra element
       is needed inside the customer's markup. */
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    background-size: 1.1em;
    cursor: pointer;
}

/* ── Choices ───────────────────────────────────────────────── */

.cf-choices {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding-top: .125rem;
}

.cf-choice {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 44px;
    padding: .65rem .85rem;
    border: 1px solid var(--cf-line);
    border-radius: var(--cf-radius);
    cursor: pointer;
    font-size: .9375rem;
    line-height: 1.4;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cf-choice:hover { border-color: var(--cf-line-strong); }
.cf-choice:active { transform: scale(0.99); }

.cf-choice input {
    margin: 0;
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--cf-accent);
    flex-shrink: 0;
    cursor: pointer;
}

.cf-choice:has(input:checked) {
    border-color: var(--cf-accent);
    background: color-mix(in srgb, var(--cf-accent) 6%, transparent);
}

.cf-choice-single {
    border: 1px solid transparent;
    padding: .5rem 0;
    min-height: 44px;
}
.cf-choice-single:hover { border-color: transparent; }
.cf-choice-single:active { transform: none; }
.cf-choice-single:has(input:checked) { background: none; }

/* ── Help and errors ───────────────────────────────────────── */

.cf-help {
    margin: .375rem 0 0;
    font-size: .8125rem;
    color: var(--cf-muted);
}

.cf-error {
    margin: .375rem 0 0;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--cf-error);
}

.cf-field.has-error .cf-input,
.cf-field.has-error .cf-choice {
    border-color: var(--cf-error);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cf-error) 15%, transparent);
}

.cf-alert {
    margin: 0 0 1.25rem;
    padding: .75rem 1rem;
    border-radius: var(--cf-radius);
    font-size: .9375rem;
}

.cf-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.cf-alert-ok {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

/* ── Honeypot ──────────────────────────────────────────────── */
/* Not display:none. A well-written bot skips a field that is display:none or
   type=hidden; this one is genuinely in the layout and genuinely invisible,
   and it is removed from the tab order and the accessibility tree by the
   markup around it. */
.cf-hp {
    position: absolute !important;
    left: -9999px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* ── Submit ────────────────────────────────────────────────── */

.cf-actions { margin-top: 1.25rem; }

.cf-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 46px;
    padding: .7rem 1.6rem;
    border: 0;
    border-radius: var(--cf-radius);
    background: var(--cf-accent);
    color: #fff;
    font: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s, transform .05s, box-shadow .15s;
}

.cf-submit:hover { filter: brightness(1.08); }
.cf-submit:active { transform: translateY(1px); }

.cf-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cf-accent) 35%, transparent);
}

.cf-submit[disabled] { opacity: .6; cursor: progress; filter: none; }

.cf-branding {
    margin: 1.25rem 0 0;
    font-size: .75rem;
    color: #94a3b8;
    text-align: center;
}

.cf-branding a { color: inherit; text-decoration: none; border-bottom: 1px solid #cbd5e1; }
.cf-branding a:hover { color: var(--cf-accent); }

/* Loading button spinner */
.cf-submit.is-loading {
    cursor: progress;
    position: relative;
    padding-left: 2.25rem;
}

.cf-submit .cf-spinner {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    margin-top: -0.55rem;
    width: 1.1rem;
    height: 1.1rem;
    animation: cf-spin 0.75s linear infinite;
}

@keyframes cf-spin {
    100% { transform: rotate(360deg); }
}

/* ── The success state (Fillout-style celebratory screen) ───── */

.cf-done {
    padding: 3rem 1.75rem 2.5rem;
    text-align: center;
    position: relative;
    animation: cf-card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    overflow: visible;
}

@keyframes cf-card-enter {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(14px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Animated Circular Checkmark */
.cf-done-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 1.35rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--cf-accent, #00346C) 12%, #f0f7ff);
    color: var(--cf-accent, #00346C);
    position: relative;
    animation: cf-mark-pop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes cf-mark-pop {
    0% {
        transform: scale(0);
        box-shadow: 0 0 0 0 rgba(0, 52, 108, 0.25);
    }
    60% {
        transform: scale(1.15);
        box-shadow: 0 0 0 12px rgba(0, 52, 108, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 52, 108, 0);
    }
}

.cf-done-mark .cf-check-svg {
    width: 32px;
    height: 32px;
    stroke: var(--cf-accent, #00346C);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.cf-done-mark .cf-check-svg polyline {
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
    animation: cf-check-draw 0.5s 0.22s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

@keyframes cf-check-draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Heading & Subtext */
.cf-done-title {
    margin: 0 0 0.65rem;
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--cf-text, #0f172a);
    letter-spacing: -0.02em;
    line-height: 1.25;
    animation: cf-fade-up 0.45s 0.12s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-done-text {
    margin: 0 auto 1.5rem;
    color: var(--cf-muted, #475569);
    font-size: 0.98rem;
    line-height: 1.6;
    max-width: 480px;
    animation: cf-fade-up 0.45s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cf-fade-up {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Branding CTA Pill button (Fillout style "Make your own Fillout") */
.cf-done-cta-wrap {
    margin: 1.25rem 0 0.25rem;
    display: flex;
    justify-content: center;
    animation: cf-fade-up 0.5s 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-done-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1.35rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.88rem;
    color: #334155;
    text-decoration: none;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cf-done-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    border-color: #cbd5e1;
    color: #0f172a;
}

.cf-done-pill .cf-pill-brand {
    font-weight: 800;
    color: #00346C;
    letter-spacing: -0.01em;
}

/* Secondary "Submit another response" button */
.cf-restart-wrap {
    margin-top: 1rem;
    animation: cf-fade-up 0.5s 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-restart-btn {
    background: transparent;
    border: none;
    color: var(--cf-muted, #64748b);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
    padding: 0.35rem 0.65rem;
}

.cf-restart-btn:hover {
    color: var(--cf-text, #0f172a);
}

/* Confetti Canvas Overlay */
.cf-confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
}

/* Floating "Made with Botsan" badge on hosted page */
.cf-floating-badge {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
    font-size: 0.78rem;
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    z-index: 100;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cf-floating-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
    border-color: #cbd5e1;
    color: #0f172a;
}

.cf-floating-badge .cf-fb-brand {
    font-weight: 800;
    color: #00346C;
}

@media (max-width: 600px) {
    .cf-done {
        padding: 2.25rem 1.25rem 1.75rem;
    }
    .cf-done-title {
        font-size: 1.35rem;
    }
    .cf-done-text {
        font-size: 0.92rem;
    }
    .cf-floating-badge {
        bottom: 0.75rem;
        left: 0.75rem;
        font-size: 0.72rem;
        padding: 0.32rem 0.7rem;
    }
}

/* ── The hosted page around the form ───────────────────────── */
/* Only used by /f/KEY and the standalone result page. The inline embed never
   loads these rules against a body it does not own. */

.cf-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, "Noto Sans", sans-serif;
}

.cf-page-inner {
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 1rem 4rem;
}

.cf-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 12px 32px -12px rgba(15, 23, 42, .12);
}

@media (max-width: 560px) {
    .cf-page-inner { padding: 1.5rem 1rem 3rem; }
    .cf-card { padding: 1.5rem 1.25rem; border-radius: 12px; }
}

@media (max-width: 420px) {
    .cf-page-inner { padding: 1rem 0.6rem 2.5rem; }
    .cf-card { padding: 1.25rem 0.85rem; border-radius: 10px; }
}

/* The embed=1 view sits inside an iframe on someone else's page, so it must
   not paint its own background or add a card around a card. */
.cf-page.is-embed { background: transparent; min-height: 0; }
.cf-page.is-embed .cf-page-inner { padding: .25rem; max-width: none; }
.cf-page.is-embed .cf-card { border: 0; box-shadow: none; padding: 0; background: transparent; }

.cf-page-brand {
    display: block;
    margin: 0 auto 1.75rem;
    text-align: center;
}

.cf-page-brand img { height: 34px; width: auto; }

.cf-paused {
    max-width: 480px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #475569;
}

.cf-paused h1 { margin: 0 0 .5rem; font-size: 1.25rem; color: #0f172a; }
.cf-paused p  { margin: 0; font-size: .9375rem; }

/* ── Dark mode ─────────────────────────────────────────────── */
/* Only the hosted page opts in. The inline embed inherits whatever the host
   site does, and forcing a dark card onto a light page is worse than doing
   nothing. */

@media (prefers-color-scheme: dark) {
    .cf-page { background: #0b1220; }

    .cf-page .cf-card {
        background: #111a2e;
        border-color: #1f2b45;
        box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
    }

    .cf-page .cf-form-wrap {
        --cf-text: #e8edf6;
        --cf-muted: #94a3b8;
        --cf-line: #2a3653;
        --cf-line-strong: #3d4c6f;
        --cf-field-bg: #0e1729;
        --cf-error: #f87171;
    }

    .cf-page .cf-label { color: #cbd5e1; }
    .cf-page .cf-input::placeholder { color: #64748b; }
    .cf-page .cf-alert-error { background: #2a1416; border-color: #7f1d1d; color: #fca5a5; }
    .cf-page .cf-branding a { border-bottom-color: #334155; }
    .cf-page .cf-paused { color: #94a3b8; }
    .cf-page .cf-paused h1 { color: #e8edf6; }
    .cf-page .cf-done-pill {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }
    .cf-page .cf-done-pill .cf-pill-brand {
        color: #38bdf8;
    }
    .cf-page .cf-floating-badge {
        background: rgba(15, 23, 42, 0.9);
        border-color: rgba(51, 65, 85, 0.9);
        color: #94a3b8;
    }
    .cf-page .cf-floating-badge .cf-fb-brand {
        color: #38bdf8;
    }
}

/* ────────────────────────────────────────────────────────────
   Security Advisory & Abuse Reporting
   ──────────────────────────────────────────────────────────── */

.cf-security-notice {
    font-size: .75rem;
    color: var(--cf-muted, #64748b);
    text-align: center;
    margin: .9rem 0 .45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    opacity: .88;
    line-height: 1.4;
}

.cf-footer-meta {
    font-size: .8125rem;
    color: var(--cf-muted, #64748b);
    text-align: center;
    margin-top: .4rem;
}

.cf-footer-meta .cf-branding {
    margin: 0;
    display: inline;
}

.cf-footer-dot {
    color: var(--cf-muted, #94a3b8);
    margin: 0 .25rem;
}

.cf-report-link,
.cf-report-btn {
    color: var(--cf-muted, #64748b);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    font-size: .75rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.cf-report-link:hover,
.cf-report-btn:hover {
    color: #0f172a;
    text-decoration-style: solid;
}

/* Native Dialog modal for abuse reporting on /f/KEY */
.cf-report-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.15), 0 8px 10px -6px rgba(0,0,0,.1);
    background: #fff;
    color: #0f172a;
    box-sizing: border-box;
}

.cf-report-dialog::backdrop {
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(2px);
}

.cf-dialog-box {
    padding: 1.25rem;
}

.cf-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: .75rem;
}

.cf-dialog-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: #0f172a;
}

.cf-dialog-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0 .25rem;
}

.cf-dialog-close:hover {
    color: #0f172a;
}

.cf-dialog-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: #334155;
    margin: .75rem 0 .25rem;
}

.cf-dialog-select,
.cf-dialog-input,
.cf-dialog-textarea {
    width: 100%;
    padding: .5rem .75rem;
    font-size: .875rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    box-sizing: border-box;
    font-family: inherit;
}

.cf-dialog-select:focus,
.cf-dialog-input:focus,
.cf-dialog-textarea:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, .15);
}

.cf-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.25rem;
}

.cf-dialog-btn-cancel {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: .5rem .9rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
}

.cf-dialog-btn-submit {
    background: #dc2626;
    border: 1px solid #b91c1c;
    color: #fff;
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
}

.cf-dialog-btn-submit:hover {
    background: #b91c1c;
}

.cf-dialog-msg {
    margin-top: .75rem;
    padding: .65rem .75rem;
    border-radius: 6px;
    font-size: .8125rem;
}

.cf-dialog-msg.is-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.cf-dialog-msg.is-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
