/**
 * eFit Tracker Connection Wizard
 *
 * Builds on the helpdesk design tokens (helpdesk.css) and the eFit brand
 * family from dashboard/modules-online/coursera-DESIGN.md (primary #004BB5).
 *
 * WCAG 2.2 AAA palette, every pair verified at >= 7:1 with a contrast
 * script during the 2026-08 redesign:
 *   body ink        #1f2937 on #ffffff          14.68
 *   helper ink      #4b5563 on #ffffff           7.56
 *   primary btn     #ffffff on #004BB5           7.85
 *   link on white   #004BB5 on #ffffff           7.85
 *   info ink        #003a8c on #e0f2fe           9.22
 *   success ink     #064e2b on #d1fae5           8.68
 *   warning ink     #6b4700 on #fef3c7           7.46
 *   danger ink      #7f1d1d on #fee2e2           8.20
 *   hero text       #ffffff on #0b2e93..#1b47c2  7.70 at lightest stop
 * Status is always icon + text (1.4.1). Targets are >= 44px (2.5.5
 * Enhanced). Focus is a 3px ring with offset (2.4.13). Motion honors
 * prefers-reduced-motion.
 */

.tw-wrap {
    max-width: 900px;
    margin: 0 auto;
    /* The site body is 14px; instruction-heavy content reads better at the
       design doc's 16px body size, so the wizard sets its own base. */
    font-size: 1rem;
    line-height: 1.6;
    color: #1f2937;
}

/* 1.4.8 Visual Presentation: keep long text at a readable measure. */
.tw-wrap p,
.tw-wrap li {
    max-width: 75ch;
}

.tw-wrap .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}

/* Shared focus ring (2.4.13 Focus Appearance). */
.tw-wrap a:focus-visible,
.tw-wrap button:focus-visible,
.tw-wrap input:focus-visible,
.tw-wrap summary:focus-visible {
    outline: 3px solid #004BB5;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */

/* The gradient's light end is capped at #1b47c2 so white text keeps 7:1
   everywhere on the band. The heading carries an explicit color because
   the global h1-h6 ink rule outranks inherited white on gradient banners. */
.tw-hero {
    background: linear-gradient(135deg, #0B2E93 0%, #163FC0 55%, #1b47c2 100%);
    border-radius: var(--hd-radius-xl);
    padding: 1.9rem 1.75rem;
    margin-bottom: 1.25rem;
}

.tw-hero h1 {
    color: #ffffff;
    font-size: clamp(1.5rem, 3.5vw, 2.1rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.5rem;
}

.tw-hero p {
    color: #ffffff;
    max-width: 640px;
    margin: 0;
    font-size: 1.05rem;
}

/* ------------------------------------------------------------------ */
/* Notice                                                              */
/* ------------------------------------------------------------------ */

.tw-notice {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: var(--hd-info-light);
    border-left: 5px solid #004BB5;
    border-radius: var(--hd-radius-md);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.25rem;
    color: #1f2937;
}

.tw-notice p { margin: 0; }

.tw-notice-icon {
    color: #003a8c;
    font-size: 1.2rem;
    margin-top: 0.2rem;
}

/* ------------------------------------------------------------------ */
/* Progress stepper                                                    */
/* ------------------------------------------------------------------ */

.tw-progress {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
}

.tw-progress li { flex: 1; display: flex; }

.tw-progress-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.5rem 0.6rem;
    border-radius: var(--hd-radius-full);
    border: 2px solid var(--hd-gray-300);
    background: #ffffff;
    color: #374151;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color var(--hd-transition-fast), background var(--hd-transition-fast);
}

.tw-progress-btn:disabled {
    cursor: not-allowed;
    color: #4b5563;
    background: var(--hd-gray-100);
}

.tw-progress-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.tw-progress .is-active .tw-progress-btn {
    background: #004BB5;
    border-color: #004BB5;
    color: #ffffff;
}

.tw-progress .is-complete .tw-progress-btn {
    background: var(--hd-success-light);
    border-color: #064e2b;
    color: #064e2b;
}

/* Completed steps show a check inside the number circle: state is
   carried by the icon and label, never by color alone. */
.tw-progress .is-complete .tw-progress-num::before {
    content: "\2713";
}
.tw-progress .is-complete .tw-progress-num {
    font-size: 0;
}
.tw-progress .is-complete .tw-progress-num::before {
    font-size: 0.9rem;
}

@media (max-width: 560px) {
    .tw-progress { flex-direction: column; }
}

/* ------------------------------------------------------------------ */
/* Cards + shared bits                                                 */
/* ------------------------------------------------------------------ */

.tw-card {
    background: #ffffff;
    border: 1px solid var(--hd-gray-200);
    border-radius: var(--hd-radius-lg);
    box-shadow: var(--hd-shadow-sm);
    padding: clamp(1.1rem, 3vw, 1.75rem);
    margin-bottom: 1rem;
}

.tw-card h2 {
    font-size: 1.3rem;
    margin-top: 0;
}

.tw-card h2:focus { outline: none; }

.tw-helper {
    color: #4b5563;
    margin: 0.5rem 0 0.9rem;
    font-size: 0.95rem;
}

.tw-error {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    color: #7f1d1d;
    background: var(--hd-danger-light);
    border-radius: var(--hd-radius-md);
    padding: 0.65rem 0.9rem;
    margin: 0.9rem 0 0;
    font-weight: 600;
}

/* Buttons: 44px minimum target (2.5.5 Enhanced). */
.tw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.55rem 1.2rem;
    border-radius: var(--hd-radius-md);
    border: 2px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--hd-transition-fast), border-color var(--hd-transition-fast);
}

.tw-btn-primary {
    background: #004BB5;
    border-color: #004BB5;
    color: #ffffff;
}

.tw-btn-primary:hover { background: #003a8c; border-color: #003a8c; }

.tw-btn-secondary {
    background: #ffffff;
    border-color: #004BB5;
    color: #004BB5;
}

.tw-btn-secondary:hover { background: var(--hd-info-light); color: #003a8c; }

.tw-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: #004BB5;
    text-decoration: underline;
    padding: 0.4rem 0.6rem;
}

.tw-btn-ghost:hover { color: #003a8c; }

.tw-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.15rem;
}

/* ------------------------------------------------------------------ */
/* Step 1: phone choice cards                                          */
/* ------------------------------------------------------------------ */

.tw-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.tw-choice {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

/* The input stretches across the whole label so the hit area always
   matches the visible card. */
.tw-choice input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.tw-choice-body {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 64px;
    padding: 0.9rem 1.1rem;
    border: 2px solid var(--hd-gray-300);
    border-radius: var(--hd-radius-md);
    background: #ffffff;
    transition: border-color var(--hd-transition-fast), background var(--hd-transition-fast);
}

.tw-choice-body > .fa-brands {
    font-size: 1.7rem;
    color: #004BB5;
    flex-shrink: 0;
}

.tw-choice-text { display: flex; flex-direction: column; gap: 0.1rem; }

.tw-choice-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2937;
}

.tw-choice-sub {
    font-size: 0.9rem;
    color: #4b5563;
}

.tw-choice-check {
    margin-left: auto;
    font-size: 1.35rem;
    color: #004BB5;
    visibility: hidden;
}

.tw-choice input:checked + .tw-choice-body {
    border-color: #004BB5;
    background: var(--hd-info-light);
    box-shadow: inset 0 0 0 1px #004BB5;
}

.tw-choice input:checked + .tw-choice-body .tw-choice-sub { color: #1f2937; }

.tw-choice input:checked + .tw-choice-body .tw-choice-check { visibility: visible; }

.tw-choice input:focus-visible + .tw-choice-body {
    outline: 3px solid #004BB5;
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Step 2: search + brand tiles                                        */
/* ------------------------------------------------------------------ */

.tw-filter { margin-bottom: 1rem; }

.tw-filter label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.tw-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 420px;
}

.tw-filter-row { position: relative; }

.tw-filter-icon {
    position: absolute;
    left: 0.85rem;
    color: #4b5563;
    pointer-events: none;
}

.tw-filter-row input {
    flex: 1;
    min-height: 44px;
    padding: 0.5rem 0.75rem 0.5rem 2.4rem;
    border: 2px solid var(--hd-gray-300);
    border-radius: var(--hd-radius-md);
    font-size: 1rem;
    color: #1f2937;
    background: #ffffff;
}

.tw-filter-row input::placeholder { color: #4b5563; opacity: 1; }

.tw-brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 0.7rem;
    margin-bottom: 1.4rem;
}

.tw-brand {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

.tw-brand input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.tw-brand-body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 84px;
    height: 100%;
    padding: 0.8rem 0.95rem;
    border: 2px solid var(--hd-gray-300);
    border-radius: var(--hd-radius-md);
    background: #ffffff;
    transition: border-color var(--hd-transition-fast), background var(--hd-transition-fast);
}

.tw-brand-text { display: flex; flex-direction: column; gap: 0.05rem; }

.tw-brand-name {
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
}

.tw-brand-models {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.3;
}

.tw-brand-tag {
    margin-top: auto;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--hd-radius-full);
}

.tw-brand-tag:empty { display: none; }

.tw-tag-direct,
.tw-tag-supported { background: var(--hd-success-light); color: #064e2b; }
.tw-tag-conditional { background: var(--hd-warning-light); color: #6b4700; }
.tw-tag-unavailable { background: var(--hd-danger-light); color: #7f1d1d; }

.tw-brand input:checked + .tw-brand-body {
    border-color: #004BB5;
    background: var(--hd-info-light);
    box-shadow: inset 0 0 0 1px #004BB5;
}

.tw-brand input:focus-visible + .tw-brand-body {
    outline: 3px solid #004BB5;
    outline-offset: 2px;
}

/* Sync question pills */
.tw-sync {
    border: 1px solid var(--hd-gray-200);
    border-radius: var(--hd-radius-md);
    padding: 1rem 1.1rem 1.1rem;
    margin: 0;
}

.tw-sync legend {
    float: none;
    width: auto;
    font-weight: 700;
    font-size: 1.02rem;
    padding: 0 0.4rem;
    margin-bottom: 0.2rem;
    color: #1f2937;
}

.tw-pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.tw-pill {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.tw-pill input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.tw-pill span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 2px solid var(--hd-gray-300);
    border-radius: var(--hd-radius-full);
    background: #ffffff;
    font-weight: 600;
    color: #1f2937;
    transition: border-color var(--hd-transition-fast), background var(--hd-transition-fast);
}

.tw-pill span i { color: #004BB5; }

.tw-pill input:checked + span {
    border-color: #004BB5;
    background: var(--hd-info-light);
    box-shadow: inset 0 0 0 1px #004BB5;
}

.tw-pill input:focus-visible + span {
    outline: 3px solid #004BB5;
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Step 3: result runbook                                              */
/* ------------------------------------------------------------------ */

.tw-summary-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.9rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--hd-gray-200);
    border-radius: var(--hd-radius-md);
    background: var(--hd-gray-50);
    margin-bottom: 1.1rem;
    font-size: 0.95rem;
}

.tw-summary-item {
    font-weight: 600;
    color: #374151;
}

.tw-summary-item + .tw-summary-item::before {
    content: "\00B7";
    margin-right: 0.9rem;
    color: #4b5563;
}

.tw-banner {
    border-radius: var(--hd-radius-md);
    border-left: 6px solid var(--hd-gray-300);
    padding: 1rem 1.2rem;
    margin-bottom: 1.1rem;
    background: var(--hd-gray-50);
}

.tw-banner h2 {
    font-size: 1.35rem;
    margin: 0.55rem 0 0.45rem;
}

.tw-banner p { margin: 0; }

.tw-banner-direct,
.tw-banner-supported { border-left-color: #064e2b; }
.tw-banner-conditional { border-left-color: #6b4700; }
.tw-banner-unavailable { border-left-color: #7f1d1d; }

.tw-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--hd-radius-full);
    font-weight: 700;
    font-size: 0.95rem;
}

.tw-status-direct,
.tw-status-supported { background: var(--hd-success-light); color: #064e2b; }
.tw-status-conditional { background: var(--hd-warning-light); color: #6b4700; }
.tw-status-unavailable { background: var(--hd-danger-light); color: #7f1d1d; }

.tw-result h3 {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #374151;
}

/* TL;DR box (3.1.5 Reading Level: a simple summary before the detail). */
.tw-tldr {
    border: 1px solid var(--hd-gray-200);
    border-radius: var(--hd-radius-md);
    background: var(--hd-info-light);
    padding: 0.9rem 1.1rem;
    margin-top: 1.1rem;
}

.tw-tldr h3 {
    margin: 0 0 0.4rem;
    color: #003a8c;
}

.tw-tldr h3 i { margin-right: 0.4rem; }

.tw-tldr ol {
    margin: 0;
    padding-left: 1.35rem;
    color: #1f2937;
}

.tw-tldr li { margin: 0.25rem 0; }

/* Connection path: vertical numbered timeline. */
.tw-route {
    list-style: none;
    counter-reset: tw-route;
    margin: 0;
    padding: 0.4rem 0 0.2rem;
}

.tw-route li {
    position: relative;
    counter-increment: tw-route;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    padding: 0.35rem 0 0.85rem 3rem;
}

.tw-route li::before {
    content: counter(tw-route);
    position: absolute;
    left: 0.35rem;
    top: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid #004BB5;
    background: #ffffff;
    color: #004BB5;
    font-weight: 700;
}

/* Connector line between the numbered dots. */
.tw-route li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 1.3rem;
    top: 2.5rem;
    bottom: -0.15rem;
    width: 2px;
    background: var(--hd-gray-300);
}

.tw-route-role {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #4b5563;
}

.tw-route-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 1.02rem;
}

.tw-route-name-efit { color: #004BB5; }

/* Checkable setup steps. */
.tw-steps-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem 1rem;
}

.tw-steps-count {
    margin: 1.5rem 0 0.6rem;
    font-weight: 700;
    color: #003a8c;
    font-size: 0.95rem;
}

.tw-phase-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 1.1rem 0 0.5rem;
}

.tw-do-list {
    list-style: none;
    counter-reset: tw-do;
    margin: 0;
    padding: 0;
}

.tw-do-list li {
    counter-increment: tw-do;
    margin: 0 0 0.45rem;
}

.tw-do {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem 0.55rem 2.9rem;
    border-radius: var(--hd-radius-md);
    cursor: pointer;
    transition: background var(--hd-transition-fast);
}

.tw-do:hover { background: var(--hd-gray-50); }

.tw-do::before {
    content: counter(tw-do);
    position: absolute;
    left: 0.35rem;
    top: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--hd-gray-100);
    color: #374151;
    font-weight: 700;
    font-size: 0.85rem;
}

.tw-do input[type="checkbox"] {
    appearance: auto;
    width: 1.4rem;
    height: 1.4rem;
    margin: 0.15rem 0 0;
    flex-shrink: 0;
    accent-color: #004BB5;
    cursor: pointer;
}

/* The dashboard shell (style.css) draws a legacy fake checkbox as an
   ::after square on all non-.form-check-input checkboxes, which stacks a
   second box next to the native one. Suppress it here. */
.tw-do input[type="checkbox"]::before,
.tw-do input[type="checkbox"]::after {
    content: none !important;
    display: none !important;
}

.tw-do span { color: #1f2937; }

.tw-do input:checked ~ span {
    color: #374151;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

/* Verification checklist */
.tw-checklist {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.tw-checklist li {
    position: relative;
    padding-left: 1.9rem;
    margin: 0.5rem 0;
}

.tw-checklist li::before {
    content: "\2610";
    position: absolute;
    left: 0.15rem;
    top: 0;
    font-size: 1.1rem;
    color: #004BB5;
}

/* Callouts */
.tw-callout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    border-radius: var(--hd-radius-md);
    padding: 0.9rem 1.1rem;
    margin: 1rem 0;
    border-left: 5px solid;
    color: #1f2937;
}

.tw-callout p { margin: 0; }

.tw-callout-icon { font-size: 1.15rem; margin-top: 0.2rem; }

.tw-callout-info {
    background: var(--hd-info-light);
    border-left-color: #003a8c;
}
.tw-callout-info .tw-callout-icon { color: #003a8c; }

.tw-callout-warning {
    background: var(--hd-warning-light);
    border-left-color: #6b4700;
}
.tw-callout-warning .tw-callout-icon { color: #6b4700; }

.tw-callout-danger {
    background: var(--hd-danger-light);
    border-left-color: #7f1d1d;
}
.tw-callout-danger .tw-callout-icon { color: #7f1d1d; }

/* Troubleshooting + links */
.tw-steps {
    padding-left: 1.35rem;
    margin-bottom: 0;
}

.tw-steps li { margin-bottom: 0.55rem; }

details.tw-details {
    border: 1px solid var(--hd-gray-200);
    border-radius: var(--hd-radius-md);
    background: #ffffff;
    margin-top: 1.2rem;
}

details.tw-details summary {
    padding: 0.85rem 1rem;
    cursor: pointer;
    font-weight: 700;
    color: #1f2937;
    min-height: 44px;
}

details.tw-details summary i { color: #004BB5; margin-right: 0.35rem; }

details.tw-details > div { padding: 0 1rem 1rem; }

.tw-links {
    padding-left: 1.35rem;
    margin-bottom: 0;
}

.tw-links li { margin-bottom: 0.55rem; }

.tw-links a,
.tw-help-footer a {
    color: #004BB5;
    text-decoration: underline;
}

.tw-links a:hover,
.tw-help-footer a:hover { color: #003a8c; }

.tw-copy-status {
    color: #064e2b;
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
}

.tw-actions { border-top: 1px solid var(--hd-gray-200); padding-top: 1.15rem; }

.tw-help-footer {
    margin: 1.2rem 0 0;
    color: #374151;
}

.tw-help-footer i { color: #004BB5; margin-right: 0.3rem; }

/* ------------------------------------------------------------------ */
/* Motion + print                                                      */
/* ------------------------------------------------------------------ */

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

/* Print: keep only the result card, show link destinations. */
@media print {
    body * { visibility: hidden; }
    #twResult, #twResult * { visibility: visible; }
    #twResult {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        border: 0;
        box-shadow: none;
        padding: 0;
    }
    .tw-buttons, .tw-copy-status, .tw-summary-strip .tw-btn { display: none !important; }
    details.tw-details { border: 0; }
    details.tw-details[open] > div { padding: 0; }
    .tw-links a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #374151;
    }
}
