/* Tax tools (Residency Checker, Remittance Checker) — page-specific rules.
   Tokens, header, footer and buttons come from ../../css/site.css.
   Every selector here matches markup the existing script.js relies on. */

/* ── Layout ──────────────────────────────────────────────────────────── */

.app-container {
    max-width: var(--container-tool);
    margin: 0 auto;
    padding: clamp(56px, 8vw, 96px) var(--gutter) var(--section-gap);
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.app-header .tool-meta {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--subtle);
}

.app-header h1 {
    margin: 0;
    font-weight: 600;
    font-size: clamp(36px, 5vw, 56px);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.app-header p {
    margin: 0;
    font-size: 17px;
    color: var(--muted);
}

.hidden {
    display: none !important;
}

.mt-4 {
    margin-top: 24px;
}

/* ── The question card ───────────────────────────────────────────────── */

.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
}

.progress-container {
    height: 3px;
    background: var(--soft);
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--teal);
    transition: width .3s ease;
}

.wizard-step {
    padding: clamp(24px, 4vw, 36px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wizard-step h2,
.wizard-step h3 {
    margin: 0;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.step-description {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
}

.step-description small {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--subtle);
}

/* ── Options: person type, yes/no radios ─────────────────────────────── */

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-btn,
.radio-label {
    position: relative;
    min-height: 52px;
    padding: 0 52px 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--fg);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: border-color .2s, background-color .2s;
}

.option-btn:hover,
.radio-label:hover {
    border-color: var(--strong);
}

/* The radio ring on the right */
.option-btn::after,
.radio-label::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: var(--r-pill);
    box-sizing: border-box;
    border: 1.5px solid var(--strong);
}

.option-btn.selected,
.radio-label.selected,
.radio-label:has(input:checked) {
    background: var(--sel);
    border-color: var(--teal);
}

.option-btn.selected::after,
.radio-label.selected::after,
.radio-label:has(input:checked)::after {
    border: 5px solid var(--teal);
}

/* The native input stays in the DOM for the script; it is only hidden. */
.radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}

.radio-label:focus-within {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

/* Font Awesome is gone; the glyph placeholders the script emits stay hidden. */
.radio-label i,
.option-btn i,
.btn i,
.logic-link i,
.info-card h4 i,
.tax-implications h3 i,
.logic-header h2 i,
.logic-summary h3 i,
.logic-outcome i,
.back-link i,
#result-icon {
    display: none;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label,
.input-area label:not(.radio-label) {
    font-size: 13px;
    font-weight: 500;
}

.text-input,
.input-area input[type="number"],
.input-area input[type="text"],
.input-area select {
    min-height: 52px;
    width: 100%;
    max-width: 280px;
    padding: 0 16px;
    border: 1px solid var(--btnline);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 18px;
}

.input-hint {
    font-size: 13px;
    color: var(--subtle);
}

/* ── Actions ─────────────────────────────────────────────────────────── */

.action-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.center-actions {
    justify-content: center;
}

.btn {
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--r-pill);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: border-color .2s, opacity .2s;
}

.btn.primary {
    background: var(--fg);
    color: var(--bg);
}

.btn.primary:hover {
    opacity: .88;
}

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

.btn.secondary:hover {
    border-color: var(--strong);
}

/* ── Result ──────────────────────────────────────────────────────────── */

.result-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-header h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--teal);
    letter-spacing: 0;
}

.gradient-text {
    margin: 0;
    font-weight: 600;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.1;
    letter-spacing: -0.035em;
    color: var(--fg);
}

.pulse-icon {
    display: none;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-card h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}

.info-card p {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
}

.tax-implications h3 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
}

.impact-list {
    margin: 0;
    padding-left: 20px;
    font-size: 15px;
    color: var(--muted);
}

.impact-list li {
    margin-bottom: 8px;
}

/* ── Decision-logic section ──────────────────────────────────────────── */

.logic-link-container {
    display: flex;
}

.logic-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.logic-link:hover {
    color: var(--fg);
}

.logic-section {
    padding: clamp(24px, 4vw, 36px);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.logic-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logic-header h2 {
    margin: 0;
    font-weight: 600;
    font-size: clamp(22px, 2.6vw, 28px);
    letter-spacing: -0.03em;
}

.logic-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.logic-step-number {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: var(--r-pill);
    background: var(--soft);
    color: var(--fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
}

.logic-step-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logic-step-content h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.logic-step-content p {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
}

.logic-step-content strong {
    color: var(--fg);
    font-weight: 600;
}

.logic-conditions,
.logic-exceptions,
.logic-outcomes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logic-condition,
.logic-exception {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logic-exception {
    flex-direction: row;
    gap: 14px;
}

.exception-icon {
    display: none;
}

.logic-exception h4 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.condition-tag {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--subtle);
}

.logic-or,
.logic-and {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    color: var(--subtle);
    text-align: center;
}

.logic-outcome {
    font-size: 14px;
    color: var(--muted);
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: var(--soft);
}

.logic-answer-tag {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--teal);
}

.logic-summary h3 {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 600;
}

.summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}

.summary-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-card p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.summary-card small {
    font-size: 13px;
    color: var(--subtle);
}

.summary-status {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
}

/* ── Modal (What is LRS?) ────────────────────────────────────────────── */

.floating-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 15;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--btnline);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.floating-btn:hover {
    border-color: var(--strong);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gutter);
    background: color-mix(in srgb, var(--bg) 60%, transparent);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: clamp(24px, 4vw, 36px);
}

.modal-content h2,
.modal-content h3 {
    margin: 0 0 12px;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.modal-body {
    font-size: 15px;
    color: var(--muted);
}

.modal-body p {
    margin: 0 0 12px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--fg);
}

/* ── Error banner ────────────────────────────────────────────────────── */

.error-banner {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-16px);
    z-index: 25;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--fg);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

.error-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Disclaimers and notes ───────────────────────────────────────────── */

.disclaimer-box,
.source-materials-box {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px;
    font-size: 13px;
    color: var(--subtle);
}

.disclaimer-box p,
.source-materials-box p {
    margin: 0 0 8px;
}

.source-materials-box h4 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
}

/* The reference-materials list sits in a plain div inside the box. */
.source-materials-box > div {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 8px;
}

.source-materials-box strong {
    color: var(--fg);
    font-weight: 600;
}

.tool-disclaimer {
    margin: 0;
    font-size: 13px;
    color: var(--subtle);
}

/* ── Animations the script toggles ───────────────────────────────────── */

.fade-in {
    animation: fade-in .25s ease both;
}

.slide-in-right {
    animation: slide-in-right .25s ease both;
}

.slide-in-left {
    animation: slide-in-left .25s ease both;
}

.error-shake {
    animation: error-shake .3s ease both;
}

.spinning {
    animation: spinning .6s linear infinite;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

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

@media (prefers-reduced-motion: reduce) {

    .fade-in,
    .slide-in-right,
    .slide-in-left,
    .error-shake,
    .spinning {
        animation: none;
    }

    .progress-bar {
        transition: none;
    }
}
