/**
 * TDB Forms — Public membership form styles (v3).
 * Sectioned single-page layout with sticky sidebar + card-based multi-selects.
 *
 * Brand: plum #603F5D + green #1C7012, cream/bone backgrounds, Poppins + Open Sans.
 */

/* ---------- Tokens (scoped to .tdbf so they don't leak into the host theme) ---------- */
.tdbf {
    --plum: #603F5D;
    --plum-soft: #7A5475;
    --plum-tint: #F8F2F7;
    --plum-mist: #EFE2EE;
    --green: #1C7012;
    --green-tint: #E8F3E5;
    --ink: #2A2025;
    --ink-soft: #574550;
    --ink-mute: #87787F;
    --cream: #FBF8F3;
    --bone: #F5F0E8;
    --line: #E8DECC;
    --line-soft: #F0E8D8;
    --white: #FFFFFF;
    --red: #B85450;
    --gold: #C9A961;

    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    line-height: 1.55;
    max-width: 1140px;
    margin: 0 auto;
    padding: 24px;
    box-sizing: border-box;
}
.tdbf *, .tdbf *::before, .tdbf *::after { box-sizing: border-box; }

/* ---------- Hero ---------- */
.tdbf-hero {
    text-align: center;
    padding: 32px 16px 40px;
    max-width: 720px;
    margin: 0 auto;
}
.tdbf-hero-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--white);
    padding: 4px;
    box-shadow: 0 4px 12px rgba(96,63,93,0.1);
    margin-bottom: 16px;
}
.tdbf-hero-title {
    font-family: 'Poppins', sans-serif;
    font-size: 34px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 12px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.tdbf-hero-sub {
    font-size: 15px;
    color: var(--ink-soft);
    margin: 0 0 18px;
    line-height: 1.6;
}
.tdbf-hero-meta {
    font-size: 13px;
    color: var(--ink-mute);
    margin: 0;
}
.tdbf-dot { margin: 0 4px; opacity: 0.5; }
.tdbf-req {
    color: var(--red);
    font-style: normal;
    font-weight: 700;
    font-size: 1em;
    margin-left: 1px;
}

/* ---------- Layout: sidebar + main ---------- */
.tdbf-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}
@media (max-width: 900px) {
    .tdbf-layout { grid-template-columns: 1fr; gap: 24px; }
}

/* ---------- Sticky sidebar ---------- */
.tdbf-sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
}
@media (max-width: 900px) {
    .tdbf-sidebar {
        position: relative;
        top: 0;
        margin-bottom: 8px;
    }
}
.tdbf-side-inner {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.tdbf-progress-ring {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line-soft);
}
.tdbf-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bone);
    border-radius: 100px;
    overflow: hidden;
}
.tdbf-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--plum), var(--plum-soft));
    border-radius: 100px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.tdbf-progress-label {
    display: flex;
    flex-direction: column;
    text-align: right;
    font-size: 11px;
    color: var(--ink-mute);
    line-height: 1.2;
}
.tdbf-progress-label strong {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--plum);
}

.tdbf-side-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tdbf-side-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 8px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}
.tdbf-side-item a:hover { background: var(--cream); color: var(--ink); }
.tdbf-side-item.active a {
    background: var(--plum-tint);
    color: var(--plum);
}
.tdbf-side-item.active .tdbf-side-num {
    background: var(--plum);
    color: var(--white);
    border-color: var(--plum);
}
.tdbf-side-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--white);
    color: var(--ink-mute);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s;
}
.tdbf-side-label {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}
.tdbf-side-opt {
    display: block;
    font-size: 10px;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 1px;
    font-weight: 500;
}
.tdbf-side-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--green);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tdbf-side-item.complete .tdbf-side-check {
    opacity: 1;
    transform: scale(1);
}
.tdbf-side-item.complete .tdbf-side-num {
    background: var(--green-tint);
    border-color: var(--green);
    color: var(--green);
}

/* ---------- Sections ---------- */
.tdbf-main { min-width: 0; }
.tdbf-section {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px 36px;
    margin-bottom: 24px;
    scroll-margin-top: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    opacity: 0;
    transform: translateY(8px);
    animation: tdbf-section-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.tdbf-section:nth-child(2) { animation-delay: 0.05s; }
.tdbf-section:nth-child(3) { animation-delay: 0.1s; }
.tdbf-section:nth-child(4) { animation-delay: 0.15s; }
@keyframes tdbf-section-in {
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 600px) {
    .tdbf-section { padding: 24px 22px; border-radius: 16px; }
}

.tdbf-section-optional {
    background: var(--cream);
    border-style: dashed;
}

.tdbf-sec-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line-soft);
}
.tdbf-sec-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--plum);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.tdbf-sec-head h2 {
    margin: 0 0 4px;
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.25;
}
.tdbf-sec-head p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.5;
}
.tdbf-opt-tag {
    display: inline-block;
    background: var(--bone);
    color: var(--ink-mute);
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-left: 6px;
    vertical-align: 2px;
}

/* ---------- Fields ---------- */
.tdbf-field { margin: 0 0 20px; }
.tdbf-field:last-child { margin-bottom: 0; }
.tdbf-field label,
.tdbf-field-label {
    display: block;
    margin-bottom: 7px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
}
.tdbf-help {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--ink-mute);
    line-height: 1.5;
}

.tdbf input[type="text"],
.tdbf input[type="email"],
.tdbf input[type="tel"],
.tdbf input[type="number"],
.tdbf input[type="url"],
.tdbf select,
.tdbf textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bone);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    outline: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}
.tdbf input:focus,
.tdbf select:focus,
.tdbf textarea:focus {
    background: var(--white);
    border-color: var(--plum);
    box-shadow: 0 0 0 4px rgba(96,63,93,0.08);
}
.tdbf input:invalid:not(:placeholder-shown),
.tdbf select:invalid {
    /* don't surface red until user touched */
}
.tdbf input.tdbf-error,
.tdbf select.tdbf-error,
.tdbf textarea.tdbf-error {
    border-color: var(--red);
    background: rgba(184,84,80,0.04);
}
.tdbf textarea {
    resize: vertical;
    min-height: 88px;
    line-height: 1.55;
}
.tdbf select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23574550' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 38px;
}

.tdbf-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 600px) {
    .tdbf-grid-2 { grid-template-columns: 1fr; }
}
.tdbf-grid-2 .tdbf-field { margin-bottom: 0; }

/* ---------- Card-based checkboxes / radios ---------- */
.tdbf-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 8px;
}
.tdbf-cards-compact {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}
.tdbf-cards.tdbf-cards-error {
    padding: 8px;
    margin: 8px -8px;
    background: rgba(184,84,80,0.05);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1.5px var(--red);
}

/* Card layout — use defensive !important + element-qualified selectors.
   WordPress themes (especially Elementor, Gravity Forms wrappers, page builders)
   frequently set `label { display: block !important; }` which collapses our flex
   layout and stacks the checkbox above the text. These rules guarantee our
   flex container wins regardless of host theme. */
.tdbf label.tdbf-card,
.tdbf .tdbf-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bone);
    border: 1.5px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
    user-select: none;
    line-height: 1.35;
    margin: 0; /* host themes love adding label margins */
    width: auto; /* prevent themes from forcing width: 100% */
}
.tdbf .tdbf-card:hover { background: var(--cream); }
.tdbf .tdbf-card:active { transform: scale(0.99); }
.tdbf .tdbf-card input[type="checkbox"],
.tdbf .tdbf-card input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none;
    width: 0;
    height: 0;
}
.tdbf .tdbf-card-mark {
    width: 20px;
    height: 20px;
    min-width: 20px; /* don't let it shrink in tight flex containers */
    border-radius: 6px;
    border: 1.5px solid var(--line);
    background: var(--white);
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
    box-sizing: border-box;
}
.tdbf .tdbf-cards-radio .tdbf-card-mark { border-radius: 50%; }
.tdbf .tdbf-card-mark::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    transform: rotate(-45deg) scale(0);
    margin-top: -2px;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tdbf .tdbf-cards-radio .tdbf-card-mark::after {
    width: 8px;
    height: 8px;
    border: none;
    border-radius: 50%;
    background: var(--white);
    margin-top: 0;
    transform: scale(0);
}
.tdbf .tdbf-card-label {
    flex: 1 1 auto;
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 500;
    display: block !important; /* keep span growing inside flex */
    margin: 0;
}
.tdbf .tdbf-card:has(input:checked) {
    background: var(--plum-tint);
    border-color: var(--plum);
}
.tdbf .tdbf-card:has(input:checked) .tdbf-card-mark {
    background: var(--plum);
    border-color: var(--plum);
}
.tdbf .tdbf-card:has(input:checked) .tdbf-card-mark::after { transform: rotate(-45deg) scale(1); }
.tdbf .tdbf-cards-radio .tdbf-card:has(input:checked) .tdbf-card-mark::after { transform: scale(1); }
.tdbf .tdbf-card:has(input:focus-visible) {
    box-shadow: 0 0 0 4px rgba(96,63,93,0.12);
}

/* "Other" reveal */
.tdbf-other-wrap {
    margin-top: 10px;
    animation: tdbf-slide-in 0.25s ease-out;
}
@keyframes tdbf-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Consent rows (same defensive pattern as cards) ---------- */
.tdbf label.tdbf-consent,
.tdbf .tdbf-consent {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bone);
    border: 1.5px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    margin: 0 0 10px;
    transition: background 0.15s, border-color 0.15s;
    width: auto;
}
.tdbf .tdbf-consent:last-child { margin-bottom: 0; }
.tdbf .tdbf-consent:hover { background: var(--cream); }
.tdbf .tdbf-consent input {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none;
    width: 0;
    height: 0;
}
.tdbf .tdbf-consent-mark {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 6px;
    border: 1.5px solid var(--line);
    background: var(--white);
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
}
.tdbf .tdbf-consent-mark::after {
    content: '';
    width: 11px;
    height: 6px;
    border-left: 2.5px solid var(--white);
    border-bottom: 2.5px solid var(--white);
    transform: rotate(-45deg) scale(0);
    margin-top: -2px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tdbf .tdbf-consent:has(input:checked) {
    background: var(--plum-tint);
    border-color: var(--plum);
}
.tdbf .tdbf-consent:has(input:checked) .tdbf-consent-mark {
    background: var(--plum);
    border-color: var(--plum);
}
.tdbf .tdbf-consent:has(input:checked) .tdbf-consent-mark::after { transform: rotate(-45deg) scale(1); }
.tdbf .tdbf-consent-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px;
    flex: 1 1 auto;
}
.tdbf .tdbf-consent-text strong {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
}
.tdbf .tdbf-consent-text span {
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.5;
}

/* ---------- Submit ---------- */
.tdbf-submit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 32px;
    background: linear-gradient(135deg, var(--plum) 0%, var(--plum-soft) 100%);
    border-radius: 20px;
    color: var(--white);
    margin-top: 8px;
    flex-wrap: wrap;
}
.tdbf-submit-meta {
    font-size: 13px;
    line-height: 1.4;
    color: rgba(255,255,255,0.85);
    flex: 1;
    min-width: 200px;
}
.tdbf-submit-meta.ready {
    color: var(--green-tint);
    font-weight: 500;
}
.tdbf-submit-btn {
    background: var(--white);
    color: var(--plum);
    border: none;
    border-radius: 100px;
    padding: 14px 28px;
    font-family: 'Poppins', sans-serif;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.tdbf-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.tdbf-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.tdbf-submit-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tdbf-submit-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--plum-mist);
    border-top-color: var(--plum);
    border-radius: 50%;
    animation: tdbf-spin 0.7s linear infinite;
}
@keyframes tdbf-spin { to { transform: rotate(360deg); } }

/* ---------- Success ---------- */
.tdbf-success {
    text-align: center;
    padding: 60px 32px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    animation: tdbf-section-in 0.4s ease-out forwards;
}
.tdbf-success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--green-tint);
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.tdbf-success h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}
.tdbf-success p {
    color: var(--ink-soft);
    margin: 0;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}
