/* Design tokens: see DESIGN.md. Restrained palette, tinted neutrals, one accent. */
:root {
    --page: oklch(0.984 0.004 250);
    --surface: oklch(0.998 0.002 250);
    --surface-sunken: oklch(0.972 0.005 250);
    --ink: oklch(0.27 0.021 260);
    --ink-muted: oklch(0.52 0.017 260);
    --line: oklch(0.912 0.007 260);
    --line-strong: oklch(0.84 0.01 260);
    --accent: oklch(0.48 0.148 262);
    --accent-hover: oklch(0.42 0.15 262);
    --accent-soft: oklch(0.955 0.02 262);
    --on-accent: oklch(0.99 0.004 262);
    --focus: oklch(0.58 0.17 262);
    --danger: oklch(0.55 0.19 25);
    --danger-ink: oklch(0.42 0.15 25);
    --danger-soft: oklch(0.965 0.03 25);
    --success: oklch(0.6 0.12 155);
    --success-ink: oklch(0.4 0.09 155);
    --success-soft: oklch(0.965 0.03 155);

    --dot-size: 18px;
    --dot-gap: 10px; /* padding between the connector line and the circles */
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background: var(--page);
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 1px 2px oklch(0.27 0.02 260 / 0.04), 0 12px 32px -20px oklch(0.27 0.02 260 / 0.35);
    overflow: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Honeypot: kept off-screen, never display:none */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* Header Styles */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    background: var(--surface);
    color: var(--ink);
    padding: 36px 40px 28px;
    border-bottom: 1px solid var(--line);
}

.form-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.form-header h2 {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--ink-muted);
}

.form-header p {
    font-size: 0.9rem;
    color: var(--ink-muted);
    margin-top: 6px;
}

/* Letterhead business-identity block (matches the legacy PDF letterhead) */
.header-identity {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    font-style: normal;
    text-align: right;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--ink-muted);
}

.header-identity .entity-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
}

.header-identity .entity-ta {
    margin-bottom: 4px;
    font-weight: 700;
    color: var(--ink);
}

.header-identity .entity-ta .ta {
    font-weight: 400;
    color: var(--ink-muted);
}

.header-identity a {
    color: var(--ink-muted);
}

.header-identity a:hover {
    color: var(--accent);
}

/* Footer business identification (legal entity + ABN) */
.entity-line {
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    color: var(--ink-muted);
}

.form-footer .entity-line {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--ink);
}

/* Progress stepper: soft dotted connectors with a gap either side, small
   hollow/dot circles, labels beneath (SEEK-style). */
.progress-bar {
    display: flex;
    list-style: none;
    background: var(--surface);
    padding: 28px 24px 24px;
    border-bottom: 1px solid var(--line);
}

.progress-step {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-muted);
    transition: color 0.2s ease;
}

/* dotted connector to the next step, inset so it never touches the circles */
.progress-step::after {
    content: "";
    position: absolute;
    top: calc(var(--dot-size) / 2);
    left: calc(50% + var(--dot-size) / 2 + var(--dot-gap));
    width: calc(100% - var(--dot-size) - 2 * var(--dot-gap));
    border-top: 2px dotted var(--line-strong);
    transform: translateY(-1px);
}

.progress-step:last-child::after {
    display: none;
}

/* the circle: hollow ring by default */
.progress-step::before {
    content: "";
    z-index: 1;
    display: grid;
    place-items: center;
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--line-strong);
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    color: var(--on-accent);
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* active: accent ring with a centre dot, like a selected radio */
.progress-step.active {
    color: var(--ink);
    font-weight: 650;
}

.progress-step.active::before {
    border-color: var(--accent);
    background: radial-gradient(circle at center, var(--accent) 0 34%, var(--surface) 42%);
}

/* completed: solid accent with a tick */
.progress-step.completed::before {
    content: "\2713";
    border-color: var(--accent);
    background: var(--accent);
}

.progress-step.clickable {
    cursor: pointer;
}

.progress-step.clickable:hover::before {
    border-color: var(--accent);
}

/* Form Styles */
.application-form {
    padding: 40px;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

h3 {
    color: var(--ink);
    margin-bottom: 24px;
    font-size: 1.35rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

h4 {
    color: var(--ink-muted);
    margin: 28px 0 14px 0;
    font-size: 0.8rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Form Groups */
.form-group {
    margin-bottom: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
}

.required::after {
    content: " *";
    color: var(--danger);
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--ink-muted);
    opacity: 0.7;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Validation states: applied by JS only, never on the pristine form */
.invalid {
    border-color: var(--danger);
}

.invalid:focus {
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-error {
    display: block;
    margin-top: 6px;
    color: var(--danger-ink);
    font-size: 0.85rem;
    font-weight: 600;
}

.error-summary {
    margin-top: 24px;
    padding: 15px 18px;
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger-ink);
}

.error-summary:empty {
    display: none;
}

.error-summary ul {
    margin: 10px 0 0 20px;
}

.error-summary li {
    margin-bottom: 5px;
}

/* Checkbox Styles */
input[type="checkbox"] {
    margin-right: 10px;
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--accent);
    vertical-align: -2px;
}

label input[type="checkbox"] + span {
    margin-left: 4px;
    font-weight: 500;
}

/* Collection Notice */
.collection-notice {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 28px;
    font-size: 0.9rem;
    color: var(--ink-muted);
    max-width: 70ch;
}

.collection-notice h4 {
    margin: 0 0 8px 0;
    font-size: 0.8rem;
    color: var(--ink-muted);
}

.collection-notice a {
    color: var(--accent);
    font-weight: 600;
}

/* Explainers and Notes */
.explainer,
.guarantee-note {
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 18px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--ink);
}

.personal-warning {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 28px;
    font-weight: 600;
    color: var(--danger-ink);
}

/* Director and Reference Sections (inset panels, no nested cards) */
.director-section,
.reference-section {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    padding: 24px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.director-section h4:first-child,
.reference-section h4:first-child {
    margin-top: 0;
}

.director-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.director-header h4 {
    margin: 0;
}

/* Terms Section */
.terms-section {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    padding: 24px;
    border-radius: 10px;
    margin-bottom: 28px;
}

.terms-section h4 {
    margin-top: 0;
}

.terms-box {
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.terms-version {
    font-size: 0.8rem;
    color: var(--ink-muted);
    margin-bottom: 20px;
}

.terms-error {
    margin-bottom: 20px;
}

.terms-error p {
    color: var(--danger-ink);
    font-weight: 600;
    margin-bottom: 10px;
}

/* Signature Section */
.signature-section {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    padding: 24px;
    border-radius: 10px;
    margin-bottom: 28px;
}

.signature-section h4 {
    margin-top: 0;
}

.signature-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.toggle-btn {
    padding: 9px 18px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.toggle-btn:hover {
    background: var(--accent-soft);
}

.toggle-btn.active {
    background: var(--accent);
    color: var(--on-accent);
}

.signature-pad-container {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.signature-pad {
    border: 2px dashed var(--line-strong);
    border-radius: 8px;
    width: 100%;
    height: 200px;
    cursor: crosshair;
    background: var(--page);
    touch-action: none;
    margin-bottom: 15px;
}

.signature-pad:hover {
    border-color: var(--accent);
    background: var(--surface);
}

.signature-pad.invalid {
    border-color: var(--danger);
}

.typed-signature-preview {
    min-height: 70px;
    margin-bottom: 20px;
    padding: 10px 20px;
    border: 2px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    display: flex;
    align-items: center;
    font-family: 'Segoe Script', 'Brush Script MT', 'Lucida Handwriting', cursive;
    font-style: italic;
    font-size: 1.8rem;
    color: var(--ink);
    overflow-wrap: anywhere;
}

/* Turnstile */
.turnstile-container {
    margin-bottom: 25px;
}

.turnstile-container:empty {
    margin-bottom: 0;
}

/* Button Styles */
.btn-primary,
.btn-secondary,
.btn-clear {
    padding: 12px 26px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-secondary:hover {
    background: var(--accent-soft);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-clear {
    background: var(--surface);
    color: var(--ink-muted);
    border-color: var(--line-strong);
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-clear:hover {
    color: var(--danger-ink);
    border-color: var(--danger);
}

/* Step hint (non-blocking navigation) */
.step-hint {
    margin-top: 24px;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.step-hint:empty {
    display: none;
}

/* Form Navigation */
.form-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

/* Save and continue later */
.save-draft-row {
    margin-top: 18px;
    text-align: center;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 4px 8px;
}

.btn-link:hover {
    color: var(--accent-hover);
}

.draft-link-panel {
    margin: 15px auto 0;
    max-width: 560px;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px 20px;
    font-size: 0.9rem;
    text-align: left;
}

.draft-link-panel .draft-link-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.draft-send-intro {
    margin-top: 16px;
}

.draft-send-status:not(:empty) {
    margin-top: 10px;
    font-weight: 600;
    color: var(--accent-hover);
}

.draft-link-panel input {
    flex: 1;
}

.draft-banner {
    background: var(--accent-soft);
    color: var(--ink);
    padding: 14px 30px;
    text-align: center;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--line);
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 60px;
    color: var(--ink-muted);
}

.spinner {
    border: 3px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success Message */
.success-message {
    background: var(--success-soft);
    color: var(--success-ink);
    padding: 36px;
    text-align: center;
    border: 1px solid var(--success);
    border-radius: 10px;
    margin: 40px;
}

.success-message h3 {
    color: var(--success-ink);
    margin-bottom: 15px;
}

.success-message p {
    margin-bottom: 10px;
}

/* Status Panels (guarantee page states) */
.status-panel {
    margin: 40px;
    padding: 36px;
    text-align: center;
    border-radius: 10px;
    border: 1px solid;
}

.status-panel h3 {
    margin-bottom: 15px;
}

.status-info {
    background: var(--accent-soft);
    border-color: var(--line);
    color: var(--ink);
}

.status-info h3 {
    color: var(--ink);
}

.status-error {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger-ink);
}

.status-error h3 {
    color: var(--danger-ink);
}

.status-panel a,
.success-message a {
    color: inherit;
    font-weight: 600;
}

/* Footer */
.form-footer {
    padding: 22px 40px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.form-footer a {
    color: var(--accent);
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 16px 10px;
    }

    .form-header {
        flex-direction: column;
        gap: 18px;
        padding: 28px 24px 22px;
    }

    .header-identity {
        text-align: left;
    }

    .application-form {
        padding: 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .progress-bar {
        padding: 22px 8px 18px;
    }

    .progress-step {
        font-size: 0.7rem;
        gap: 8px;
    }

    .form-navigation {
        flex-direction: column-reverse;
        gap: 12px;
    }

    .form-navigation .btn-primary,
    .form-navigation .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    :root {
        --dot-size: 16px;
        --dot-gap: 6px;
    }

    .form-header h1 {
        font-size: 1.25rem;
    }

    .progress-step {
        font-size: 0.62rem;
    }

    .success-message,
    .status-panel {
        margin: 24px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
        border: none;
        border-radius: 0;
    }

    .progress-bar,
    .form-navigation,
    .save-draft-row,
    .form-footer,
    .signature-toggle,
    .terms-error,
    .btn-clear {
        display: none;
    }

    .form-step {
        display: block !important;
        page-break-after: always;
    }

    .form-step:last-child {
        page-break-after: avoid;
    }

    .terms-box {
        max-height: none;
        overflow: visible;
    }
}
