/* ===========================================
   TAR MODAL SYSTEM v3.2 — Kaufen Form
   Extracted from v3.2 template for Kaufen form
   =========================================== */

/* ===========================================
   TAR DESIGN TOKENS
   v3.2 — Optimized
   =========================================== */
:root {
    /* Brand Colors */
    --tar-white: #fff;
    --tar-cream: #f7f5f2;
    --tar-cream-warm: #f5f2ee;
    --tar-graphite: #3d3937;
    --tar-brown-100: #5c4338;
    --tar-brown-80: #73574a;
    --tar-brown-60: #8a7065;
    --tar-copper: #b8926a;
    --tar-copper-light: #c9a880;

    /* Neutral Scale — Refined */
    --tar-gray-100: #f3f4f6;
    --tar-gray-200: #e5e7eb;
    --tar-gray-300: #d1d5db;
    --tar-gray-400: #9ca3af;
    --tar-gray-500: #6b7280;
    --tar-gray-600: #4b5563;

    /* Semantic */
    --tar-error: #b44533;
    --tar-error-bg: #fdf6f5;
    --tar-error-border: #e8c5bf;
    --tar-success-color: #4a7c59;
    --tar-success-bg: #f4f9f5;

    /* Modal Tokens */
    --modal-width-sm: 480px;
    --modal-width-md: 560px;
    --modal-width-lg: 660px;
    --modal-radius: 2px;

    /* v3.2: Layered shadow for realistic depth */
    --modal-shadow:
        0 2px 4px rgb(0 0 0 / 4%), 0 8px 24px rgb(0 0 0 / 12%), 0 24px 72px rgb(0 0 0 / 28%);
    --modal-backdrop: rgb(61 57 55 / 72%);
    --modal-backdrop-blur: 5px;

    /* Spacing */
    --sp-header-x: 52px;
    --sp-header-y: 44px;
    --sp-body-x: 52px;
    --sp-body-y: 36px;
    --sp-footer-x: 52px;
    --sp-footer-y: 22px;

    /* Typography */
    --font: 'Jost', sans-serif;

    /* Transitions */
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --duration: 180ms;
    --duration-slow: 300ms;
}

/* ===========================================
   MODAL OVERLAY & BASE
   =========================================== */
.tar-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(var(--modal-backdrop-blur));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--duration) var(--ease),
        visibility var(--duration) var(--ease);
}

.tar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.tar-modal {
    background: var(--tar-white);
    border-radius: var(--modal-radius);
    box-shadow: var(--modal-shadow);
    width: 100%;
    max-width: var(--modal-width-md);
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.96) translateY(16px);
    transition: transform var(--duration) var(--ease);
}

.tar-modal--lg {
    max-width: var(--modal-width-lg);
}

.tar-overlay.is-open .tar-modal {
    transform: scale(1) translateY(0);
}

/* ===========================================
   MODAL HEADER
   =========================================== */
.tar-modal__header {
    padding: var(--sp-header-y) var(--sp-header-x) 0;
    position: relative;
    flex-shrink: 0;
}

.tar-modal__close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--tar-gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--duration) var(--ease),
        color var(--duration) var(--ease);
    z-index: 10;
}

.tar-modal__close:hover {
    background: var(--tar-gray-100);
    color: var(--tar-graphite);
}

.tar-modal__close svg {
    width: 18px;
    height: 18px;
}

.tar-modal__badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--tar-copper);
    margin-bottom: 12px;
}

.tar-modal__badge::before {
    content: '';
    width: 18px;
    height: 1px;
    background: var(--tar-copper);
    opacity: 0.4;
}

.tar-modal__title {
    font-size: 26px;
    font-weight: 500;
    color: var(--tar-graphite);
    line-height: 1.25;
    margin-bottom: 8px;
    padding-right: 60px;
}

.tar-modal__subtitle {
    font-size: 14px;
    color: var(--tar-gray-500);
    line-height: 1.5;
    margin-bottom: 32px;
    max-width: 400px;
}

/* ===========================================
   PROGRESS BAR (Legacy - kept for backwards compatibility)
   =========================================== */
.tar-modal__progress {
    margin-bottom: 36px;
}

.tar-modal__progress-track {
    height: 2px;
    background: var(--tar-gray-200);
    border-radius: 1px;
    overflow: hidden;
    margin-bottom: 12px;
}

.tar-modal__progress-bar {
    height: 100%;
    background: var(--tar-brown-80);
    border-radius: 1px;
    transition: width var(--duration-slow) var(--ease);
}

.tar-modal__progress-labels {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.tar-modal__progress-label {
    font-size: 10.5px;
    font-weight: 500;
    color: var(--tar-gray-400);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex: 1;
    text-align: center;
    transition: color var(--duration) var(--ease);
}

.tar-modal__progress-label:first-child {
    text-align: left;
}

.tar-modal__progress-label:last-child {
    text-align: right;
}

.tar-modal__progress-label.is-active {
    color: var(--tar-brown-80);
}

/* ===========================================
   TAB NAVIGATION (v3.2 - Clickable Tabs)
   =========================================== */
.tar-modal__tabs {
    display: flex;
    gap: 0;
    margin-bottom: 36px;
    border-bottom: 1px solid var(--tar-gray-200);
}

.tar-tab {
    flex: 1;
    padding: 14px 8px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tar-gray-400);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition:
        color var(--duration) var(--ease),
        border-color var(--duration) var(--ease);
    position: relative;
    margin-bottom: -1px;
}

.tar-tab:hover:not(.is-active) {
    color: var(--tar-gray-600);
}

.tar-tab.is-active {
    color: var(--tar-brown-80);
    border-bottom-color: var(--tar-brown-80);
}

.tar-tab:focus-visible {
    outline: 2px solid var(--tar-brown-80);
    outline-offset: -2px;
}

/* Tab step number indicator */
.tar-tab__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 600;
    color: var(--tar-gray-400);
    background: var(--tar-gray-100);
    border-radius: 50%;
    margin-right: 6px;
    transition:
        color var(--duration) var(--ease),
        background var(--duration) var(--ease);
}

.tar-tab.is-active .tar-tab__step {
    color: var(--tar-white);
    background: var(--tar-brown-80);
}

.tar-tab.is-completed .tar-tab__step {
    color: var(--tar-white);
    background: var(--tar-success-color);
}

.tar-tab.is-completed .tar-tab__step::before {
    content: '\2713';
    font-size: 10px;
}

/* Hide step number when completed */
.tar-tab.is-completed .tar-tab__step-num {
    display: none;
}

.tar-modal__divider {
    height: 1px;
    background: var(--tar-gray-200);
    margin-top: 32px;
    margin-left: calc(var(--sp-header-x) * -1);
    margin-right: calc(var(--sp-header-x) * -1);
}

/* ===========================================
   MODAL BODY
   =========================================== */
.tar-modal__body-wrap {
    flex: 1;
    overflow: hidden auto;
}

.tar-modal__body {
    padding: var(--sp-body-y) var(--sp-body-x);
}

/* ===========================================
   STEP STRUCTURE
   =========================================== */
.tar-step {
    display: none;
}

.tar-step.is-active {
    display: block;
}

.tar-step__title {
    font-size: 20px;
    font-weight: 500;
    color: var(--tar-graphite);
    margin-bottom: 6px;
    line-height: 1.3;
}

.tar-step__desc {
    font-size: 14px;
    color: var(--tar-gray-500);
    line-height: 1.5;
    margin-bottom: 32px;
}

.tar-section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--tar-graphite);
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

/* ===========================================
   FORM COMPONENTS
   =========================================== */

/* Form Field Wrapper */
.tar-field {
    margin-bottom: 24px;
}

.tar-field:last-child {
    margin-bottom: 0;
}

/* Form Rows (Grid Layout) */
.tar-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.tar-form-row:last-child {
    margin-bottom: 0;
}

.tar-form-row--3col {
    grid-template-columns: repeat(3, 1fr);
}

/* Labels */
.tar-label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--tar-graphite);
    margin-bottom: 6px;
    line-height: 1.4;
}

.tar-label__req {
    color: var(--tar-error);
    margin-left: 2px;
}

.tar-label__opt {
    color: var(--tar-gray-400);
    font-weight: 400;
}

.tar-label__hint {
    color: var(--tar-gray-400);
    font-weight: 400;
    margin-left: 4px;
}

/* Input Fields */
.tar-input {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--tar-graphite);
    background: var(--tar-white);
    border: 1.5px solid var(--tar-gray-300);
    border-radius: 0;
    transition:
        border-color var(--duration) var(--ease),
        box-shadow var(--duration) var(--ease);
}

.tar-input:focus {
    outline: none;
    border-color: var(--tar-brown-80);
    box-shadow: 0 0 0 3px rgb(115 87 74 / 8%);
}

.tar-input::placeholder {
    color: var(--tar-gray-400);
}

/* Textarea */
.tar-textarea {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--tar-graphite);
    background: var(--tar-white);
    border: 1.5px solid var(--tar-gray-300);
    border-radius: 0;
    resize: vertical;
    min-height: 80px;
    transition:
        border-color var(--duration) var(--ease),
        box-shadow var(--duration) var(--ease);
}

.tar-textarea:focus {
    outline: none;
    border-color: var(--tar-brown-80);
    box-shadow: 0 0 0 3px rgb(115 87 74 / 8%);
}

/* Select */
.tar-select {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--tar-graphite);
    background: var(--tar-white);
    border: 1.5px solid var(--tar-gray-300);
    border-radius: 0;
    appearance: none;
    transition:
        border-color var(--duration) var(--ease),
        box-shadow var(--duration) var(--ease);
    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='%23d1d5db' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    cursor: pointer;
}

.tar-select:focus {
    outline: none;
    border-color: var(--tar-brown-80);
    box-shadow: 0 0 0 3px rgb(115 87 74 / 8%);
    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='%2373574a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Field Help Text */
.tar-field__help {
    font-size: 12px;
    color: var(--tar-gray-500);
    margin-top: 5px;
    line-height: 1.4;
}

/* ===========================================
   VALIDATION & ERROR STATES
   =========================================== */
.tar-field.has-error .tar-input,
.tar-field.has-error .tar-select,
.tar-field.has-error .tar-textarea {
    border-color: var(--tar-error);
    background: var(--tar-error-bg);
}

.tar-field.has-error .tar-input:focus,
.tar-field.has-error .tar-select:focus {
    box-shadow: 0 0 0 3px rgb(180 69 51 / 8%);
}

.tar-field.has-error .tar-label {
    color: var(--tar-error);
}

.tar-field__error {
    display: none;
    font-size: 12px;
    color: var(--tar-error);
    margin-top: 5px;
    line-height: 1.4;
}

.tar-field.has-error .tar-field__error {
    display: block;
}

/* ===========================================
   TYPE CARDS (Radio Cards)
   =========================================== */
.tar-card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.tar-card-grid--3col {
    grid-template-columns: repeat(3, 1fr);
}

.tar-type-card {
    padding: 20px 12px;
    background: var(--tar-white);
    border: 1.5px solid var(--tar-gray-300);
    cursor: pointer;
    transition:
        border-color var(--duration) var(--ease),
        background var(--duration) var(--ease),
        transform var(--duration) var(--ease);
    text-align: center;
    font-family: inherit;
    color: var(--tar-graphite);
}

.tar-type-card:hover {
    border-color: var(--tar-brown-80);
    transform: translateY(-1px);
}

.tar-type-card.is-selected {
    border-color: var(--tar-brown-80);
    background: rgb(115 87 74 / 3%);
}

.tar-type-card__label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
}

/* ===========================================
   CHECKBOXES
   =========================================== */
.tar-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    margin-top: 8px;
    position: relative;
}

.tar-checkbox input[type='checkbox'] {
    /* Position over the visual checkbox box for click interception */
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.tar-checkbox__box {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1.5px solid var(--tar-gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition:
        border-color var(--duration) var(--ease),
        background var(--duration) var(--ease);
}

.tar-checkbox__box svg {
    width: 11px;
    height: 11px;
    stroke: var(--tar-white);
    stroke-width: 2.5;
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--duration) var(--ease);
}

.tar-checkbox:hover .tar-checkbox__box {
    border-color: var(--tar-gray-400);
}

.tar-checkbox input:checked + .tar-checkbox__box {
    background: var(--tar-brown-80);
    border-color: var(--tar-brown-80);
}

.tar-checkbox input:checked + .tar-checkbox__box svg {
    opacity: 1;
    transform: scale(1);
}

.tar-checkbox input:focus-visible + .tar-checkbox__box {
    outline: 2px solid var(--tar-brown-80);
    outline-offset: 2px;
}

.tar-field.has-error .tar-checkbox__box {
    border-color: var(--tar-error);
}

.tar-checkbox__text {
    font-size: 12.5px;
    color: var(--tar-gray-500);
    line-height: 1.5;
}

.tar-checkbox__text a {
    color: var(--tar-brown-80);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--duration) var(--ease);
}

.tar-checkbox__text a:hover {
    border-bottom-color: var(--tar-brown-80);
}

/* Checkbox Grid Layout */
.tar-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 16px;
}

.tar-checkbox-grid--regions {
    grid-template-columns: repeat(2, 1fr);
}

/* ===========================================
   MODAL FOOTER
   =========================================== */
.tar-modal__footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-footer-y) var(--sp-footer-x);
    background: var(--tar-cream);
    border-top: 1px solid var(--tar-gray-200);
    gap: 16px;
}

.tar-modal__ssl {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--tar-gray-500);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.tar-modal__ssl svg {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.tar-modal__step-info {
    font-size: 11px;
    color: var(--tar-gray-400);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.tar-modal__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* ===========================================
   BUTTONS
   =========================================== */

/* Ghost Button */
.tar-btn-ghost {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--tar-gray-500);
    background: transparent;
    border: none;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: color var(--duration) var(--ease);
    white-space: nowrap;
}

.tar-btn-ghost:hover {
    color: var(--tar-graphite);
}

/* Primary Button */
.tar-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 28px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: 0.03em;
    color: var(--tar-white);
    background: var(--tar-brown-80);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition:
        background var(--duration) var(--ease),
        opacity var(--duration) var(--ease);
    white-space: nowrap;
    position: relative;
}

.tar-btn-primary:hover {
    background: var(--tar-brown-100);
}

.tar-btn-primary:focus-visible {
    outline: 2px solid var(--tar-brown-80);
    outline-offset: 2px;
}

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

.tar-btn-primary svg {
    width: 14px;
    height: 14px;
}

/* Loading State */
.tar-btn-primary.is-loading {
    color: transparent;
    pointer-events: none;
}

.tar-btn-primary.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgb(255 255 255 / 30%);
    border-top-color: var(--tar-white);
    border-radius: 50%;
    animation: btnSpin 600ms linear infinite;
}

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

/* ===========================================
   SUCCESS STATE
   =========================================== */
.tar-success {
    text-align: center;
    padding: 48px 20px 32px;
}

.tar-success__icon {
    width: 52px;
    height: 52px;
    border: 2px solid var(--tar-brown-80);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
    color: var(--tar-brown-80);
    animation: successPop 400ms var(--ease-out) forwards;
}

@keyframes successPop {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }

    60% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tar-success__icon svg {
    width: 22px;
    height: 22px;
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
    animation: checkDraw 500ms 200ms var(--ease-out) forwards;
}

@keyframes checkDraw {
    to {
        stroke-dashoffset: 0;
    }
}

.tar-success__title {
    font-size: 22px;
    font-weight: 500;
    color: var(--tar-graphite);
    margin-bottom: 10px;
    line-height: 1.25;
}

.tar-success__text {
    font-size: 14px;
    color: var(--tar-gray-500);
    line-height: 1.6;
    max-width: 340px;
    margin: 0 auto;
}

/* ===========================================
   RESPONSIVE: TABLET
   =========================================== */
@media (width <= 1024px) {
    :root {
        --sp-header-x: 36px;
        --sp-header-y: 36px;
        --sp-body-x: 36px;
        --sp-body-y: 28px;
        --sp-footer-x: 36px;
    }

    .tar-modal__title {
        font-size: 23px;
    }

    .tar-modal__close {
        top: 16px;
        right: 16px;
    }
}

/* ===========================================
   RESPONSIVE: MOBILE
   =========================================== */
@media (width <= 767px) {
    .tar-overlay {
        padding: 0;

        /* v3.2: safe areas */
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
            env(safe-area-inset-left);
    }

    .tar-modal {
        max-width: 100% !important;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
    }

    :root {
        --sp-header-x: 24px;
        --sp-header-y: 28px;
        --sp-body-x: 24px;
        --sp-body-y: 24px;
        --sp-footer-x: 24px;
        --sp-footer-y: 16px;
    }

    .tar-modal__title {
        font-size: 21px;
        padding-right: 48px;
    }

    .tar-modal__subtitle {
        font-size: 13px;
    }

    .tar-modal__close {
        top: 14px;
        right: 14px;
    }

    .tar-modal__badge::before {
        width: 16px;
    }

    .tar-modal__progress {
        margin-top: 24px;
        gap: 4px;
    }

    .tar-modal__progress-label {
        font-size: 9px;
    }

    /* Tab navigation mobile */
    .tar-modal__tabs {
        margin-bottom: 24px;
    }

    .tar-tab {
        font-size: 9px;
        padding: 10px 4px;
        letter-spacing: 0.05em;
    }

    .tar-tab__step {
        width: 16px;
        height: 16px;
        font-size: 9px;
        margin-right: 4px;
    }

    .tar-modal__divider {
        margin-top: 24px;
    }

    .tar-card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tar-card-grid--3col {
        grid-template-columns: repeat(3, 1fr);
    }

    .tar-type-card {
        padding: 14px 8px;
    }

    .tar-type-card__label {
        font-size: 12px;
    }

    /* v3.2: FIX — form-row must keep gap for stacked fields */
    .tar-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .tar-form-row > .tar-field {
        margin-bottom: 20px;
    }

    .tar-form-row > .tar-field:last-child {
        margin-bottom: 0;
    }

    .tar-form-row--3col {
        grid-template-columns: 1fr;
    }

    .tar-modal__footer {
        flex-direction: column;
        gap: 10px;

        /* v3.2: safe area bottom */
        padding-bottom: max(var(--sp-footer-y), env(safe-area-inset-bottom));
    }

    .tar-modal__actions {
        width: 100%;
        flex-direction: column-reverse;
        gap: 6px;
        margin-left: 0;
    }

    .tar-btn-primary {
        width: 100%;
        justify-content: center;
        padding: 15px;
    }

    .tar-btn-ghost {
        width: 100%;
        text-align: center;
    }

    .tar-modal__ssl {
        text-align: center;
        order: 1;
    }

    .tar-modal__step-info {
        order: -1;
        text-align: center;
    }
}

/* ===========================================
   RESPONSIVE: SMALL MOBILE
   =========================================== */
@media (width <= 374px) {
    .tar-modal__title {
        font-size: 19px;
    }

    .tar-type-card__label {
        font-size: 11px;
    }

    .tar-card-grid--3col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===========================================
   ACCESSIBILITY
   =========================================== */
.tar-modal *:focus-visible {
    outline: 2px solid var(--tar-brown-80);
    outline-offset: 2px;
}

/* v3.2: Override for inputs (they use box-shadow instead) */
.tar-input:focus-visible,
.tar-select:focus-visible,
.tar-textarea:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }
}

@media (prefers-contrast: high) {
    .tar-type-card,
    .tar-input,
    .tar-select,
    .tar-textarea {
        border-width: 2px;
    }

    .tar-modal__progress-bar {
        height: 4px;
    }
}

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

/* ===========================================
   CONDITIONAL DISPLAY (International)
   =========================================== */
.tar-form__group[data-international-show='false'] {
    display: none !important;
}

.tar-form__group[data-international-show='true'] {
    display: block;
}

/* ===========================================
   DARK MODE (via prefers-color-scheme)
   =========================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --tar-white: #1a1918;
        --tar-cream: #2a2624;
        --tar-cream-warm: #252220;
        --tar-graphite: #e8e6e3;
        --tar-gray-100: #2a2826;
        --tar-gray-200: #3a3836;
        --tar-gray-300: #4a4846;
        --tar-gray-400: #6a6866;
        --tar-gray-500: #9a9896;
        --tar-gray-600: #cacac8;
        --tar-error-bg: #2a1f1d;
        --tar-success-bg: #1d2a1f;
        --modal-backdrop: rgb(0 0 0 / 85%);
    }

    .tar-modal {
        box-shadow:
            0 2px 4px rgb(0 0 0 / 20%),
            0 8px 24px rgb(0 0 0 / 30%),
            0 24px 72px rgb(0 0 0 / 40%);
    }

    .tar-select {
        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='%236a6866' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }

    .tar-select:focus {
        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='%23c9a880' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }
}
