/*
 * TG Ref Signup — Form Styles
 * ════════════════════════════════════════════════════════════
 * Brand-aligned styles for the Client Partner referral form.
 * Tokens sourced from: brand/design-tokens.css
 * ════════════════════════════════════════════════════════════
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ━━ Brand Tokens ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
:root {
    --tonkin-maroon:       #80004B;
    --tonkin-maroon-light: #A3336F;
    --tonkin-maroon-dark:  #5C0036;
    --tonkin-navy:         #0B2265;
    --tonkin-blue:         #0039A6;
    --tonkin-pink:         #EC008C;

    --text-primary:   #1A1A2E;
    --text-secondary: #4A5568;
    --text-dim:       #8B95A5;
    --text-inverse:   #FFFFFF;

    --bg-page:     #E8E9EA;
    --bg-card:     #FFFFFF;
    --bg-card-alt: #F9F9F9;
    --bg-divider:  #E2E8F0;

    --color-success: #0D9F6E;
    --color-error:   #D32F2F;
    --color-warning: #C97A1E;
    --color-info:    #0039A6;

    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    --font-primary: 'Inter', 'Segoe UI', -apple-system, sans-serif;
}

/* ━━ Reset & Base ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

/* ━━ Accessibility Utilities ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: var(--tonkin-maroon);
    color: white;
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ━━ Page Layout ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.page-wrapper {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ━━ Header ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.header {
    background: linear-gradient(135deg, var(--tonkin-maroon) 0%, var(--tonkin-maroon-dark) 100%);
    padding: 1.5rem 1.25rem;
    text-align: center;
    color: var(--text-inverse);
}

.header__logo {
    height: 96px;
    width: auto;
    margin-bottom: 0.25rem;
}

.header__subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.85;
    letter-spacing: 0.5px;
}

.header__accent {
    height: 4px;
    background: linear-gradient(90deg, var(--tonkin-navy), var(--tonkin-blue));
    width: 100%;
}

/* ━━ Content Area ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.content {
    flex: 1;
    background: var(--bg-card);
    padding: 1.25rem;
}

/* ━━ Partner Banner ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.partner-banner {
    background: #E8F5E9;
    border: 1px solid #A5D6A7;
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.partner-banner__logo {
    max-height: 60px;
    max-width: 200px;
    margin: 0 auto 0.5rem;
    display: block;
}

.partner-banner__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2E7D32;
    margin-bottom: 0.125rem;
}

.partner-banner__subtitle {
    font-size: 0.75rem;
    color: #4A5568;
}

/* ━━ Form ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.form__legend {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.form__row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0;
}

.form__group {
    margin-bottom: 1rem;
    flex: 1;
}

.form__label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.form__label--required::after {
    content: " *";
    color: var(--color-error);
}

.form__input,
.form__select {
    width: 100%;
    height: 48px;
    padding: 0 0.75rem;
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1.5px solid var(--bg-divider);
    border-radius: var(--radius-md);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form__select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%234A5568' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form__input::placeholder {
    color: var(--text-dim);
}

.form__input:focus,
.form__select:focus {
    outline: none;
    border-color: var(--tonkin-maroon);
    box-shadow: 0 0 0 3px rgba(128, 0, 75, 0.15);
}

.form__input:focus-visible,
.form__select:focus-visible {
    outline: 2px solid var(--tonkin-maroon);
    outline-offset: 2px;
}

/* Radio group (homeowner) */
.form__fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.form__radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form__radio-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.form__radio {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    accent-color: var(--tonkin-maroon);
    cursor: pointer;
}

.form__radio:focus-visible {
    outline: 2px solid var(--tonkin-maroon);
    outline-offset: 2px;
}

/* Validation states */
.form__input--error,
.form__select--error {
    border-color: var(--color-error);
}

.form__input--error:focus,
.form__select--error:focus {
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

.form__error {
    display: none;
    font-size: 0.75rem;
    color: var(--color-error);
    margin-top: 0.25rem;
    line-height: 1.3;
}

.form__error--visible {
    display: block;
}

/* ━━ Honeypot (hidden from users) ━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.form__honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* ━━ Privacy & Consent ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.privacy-notice {
    background: var(--bg-card-alt);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.privacy-notice a {
    color: var(--tonkin-maroon);
    text-decoration: underline;
}

.consent {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.consent__checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--tonkin-maroon);
    cursor: pointer;
}

.consent__label {
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
    cursor: pointer;
}

.consent__label a {
    color: var(--tonkin-maroon);
    text-decoration: underline;
}

.consent__error {
    display: none;
    font-size: 0.75rem;
    color: var(--color-error);
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.consent__error--visible {
    display: block;
}

/* ━━ Turnstile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.turnstile-container {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

/* ━━ Submit Button ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.btn-submit {
    width: 100%;
    height: 52px;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: linear-gradient(135deg, var(--tonkin-maroon) 0%, var(--tonkin-maroon-light) 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
    opacity: 0.92;
}

.btn-submit:active:not(:disabled) {
    transform: scale(0.99);
}

.btn-submit:focus-visible {
    outline: 2px solid var(--tonkin-maroon);
    outline-offset: 2px;
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-submit__spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-submit--loading .btn-submit__spinner {
    display: inline-block;
}

.btn-submit--loading .btn-submit__text {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ━━ Error Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.error-summary {
    display: none;
    background: #FDECEA;
    border: 1px solid #F5C6CB;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    color: var(--color-error);
}

.error-summary--visible {
    display: block;
}

/* ━━ Success Screen ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.success-screen {
    display: none;
    text-align: center;
    padding: 2rem 1rem;
}

.success-screen--visible {
    display: block;
}

.success-screen__icon {
    width: 64px;
    height: 64px;
    background: var(--color-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.success-screen__icon svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: white;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.success-screen__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.success-screen__message {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.success-screen__detail {
    font-size: 0.8125rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ━━ Error Screen (server errors) ━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.server-error {
    display: none;
    background: #FDECEA;
    border: 1px solid #F5C6CB;
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.server-error--visible {
    display: block;
}

.server-error__message {
    font-size: 0.8125rem;
    color: var(--color-error);
    line-height: 1.4;
}

/* ━━ Invalid Partner / Not Active ━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.invalid-state {
    display: none;
    text-align: center;
    padding: 2rem 1rem;
}

.invalid-state--visible {
    display: block;
}

.invalid-state__icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.invalid-state__title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.invalid-state__message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ━━ Footer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.footer {
    padding: 1rem 1.25rem;
    text-align: center;
    background: var(--bg-card);
}

.footer__protection {
    font-size: 0.6875rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.footer__protection a {
    color: var(--tonkin-maroon);
    text-decoration: underline;
}

.footer__brand-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--tonkin-maroon), var(--tonkin-navy), var(--tonkin-blue));
    border-radius: 2px;
    margin-bottom: 0.75rem;
}

.footer__company {
    font-size: 0.6875rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.footer__company a {
    color: var(--text-dim);
    text-decoration: none;
}

/* ━━ Postcode-first layout ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.form__group--postcode {
    flex: 0 0 110px;
}

/* ━━ Responsive ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 360px) {
    .form__row {
        flex-direction: column;
        gap: 0;
    }
}

@media (min-width: 481px) {
    body {
        padding: 1.5rem 1rem;
    }

    .page-wrapper {
        border-radius: var(--radius-lg);
        overflow: hidden;
        box-shadow: var(--shadow-lg);
        min-height: auto;
    }
}
