/* ============================================================
   THE PROFIT PROTECTION CHECKLIST - Trimble Light Theme
   ============================================================ */

:root {
    --trimble: #0063a3;
    --trimble-dark: #004d80;
    --trimble-light: #e8f4fb;

    --s1: #4da2d3;
    --s1-light: #ecf5fb;
    --s2: #217cbb;
    --s2-light: #e6f0f8;
    --s3: #004f83;
    --s3-light: #e0eaf2;
    --s4: #003054;
    --s4-light: #e6ebf0;

    --green: #1e8a44;
    --amber: #f59e0b;
    --red: #ef4444;

    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-alt: #f7f9fb;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.03);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.07), 0 12px 40px rgba(0,0,0,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ======================== APP CONTAINER ======================== */

.app-container {
    width: 1100px;
    height: 700px;
    background: var(--surface);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ======================== PROGRESS BAR ======================== */

.progress-bar {
    background: var(--surface);
    padding: 16px 40px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.4s, transform 0.4s;
}

.progress-bar.hidden {
    display: none;
}

.progress-sections {
    display: flex;
    gap: 12px;
}

.progress-group {
    flex: 1;
    position: relative;
}

.progress-group[data-section="1"] { --seg-color: var(--s1); }
.progress-group[data-section="2"] { --seg-color: var(--s2); }
.progress-group[data-section="3"] { --seg-color: var(--s3); }
.progress-group[data-section="4"] { --seg-color: var(--s4); }

.progress-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    margin-bottom: 6px;
    transition: color 0.3s;
}

.progress-group.active .progress-label {
    color: var(--text);
}

.progress-group.done .progress-label {
    color: var(--seg-color);
}

.progress-segments {
    display: flex;
    gap: 3px;
}

.seg {
    height: 5px;
    flex: 1;
    background: var(--border);
    border-radius: 3px;
    transition: background 0.4s ease;
    position: relative;
    overflow: hidden;
}

.seg.filled {
    background: var(--seg-color);
}

.seg.current {
    background: var(--border);
}

.seg.current::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--seg-color);
    border-radius: 3px;
    animation: segPulse 1.8s ease-in-out infinite;
}

@keyframes segPulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
}

/* ======================== STEPS / TRANSITIONS ======================== */

.step {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.45s ease, transform 0.45s ease;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.step.active {
    position: relative;
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
    flex: 1;
    min-height: 0;
}

.step.exit-left {
    transform: translateX(-50px);
    opacity: 0;
}

.step.exit-right {
    transform: translateX(50px);
    opacity: 0;
}

/* ======================== WELCOME SCREEN ======================== */

.step-welcome {
    background: var(--surface);
    color: var(--text);
    padding: 0;
}

.welcome-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 48px 0;
    flex-shrink: 0;
}

.trimble-logo {
    height: 32px;
    width: auto;
}

.welcome-content {
    display: flex;
    flex: 1;
    padding: 20px 52px 48px;
    gap: 40px;
    align-items: center;
}

.welcome-text {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--trimble-light);
    color: var(--trimble);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 99, 163, 0.15);
    width: fit-content;
}

.welcome-text h1 {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin-bottom: 18px;
    color: var(--text);
    animation: fadeInUp 0.7s ease 0.2s both;
}

.welcome-subtitle {
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-muted);
    max-width: 440px;
    margin-bottom: 28px;
    animation: fadeInUp 0.7s ease 0.35s both;
}

.welcome-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 36px;
    animation: fadeInUp 0.7s ease 0.45s both;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat svg { color: var(--trimble); }

.btn-start {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--trimble);
    color: #fff;
    border: none;
    padding: 14px 34px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 2px 12px rgba(0, 99, 163, 0.25);
    animation: fadeInUp 0.7s ease 0.55s both;
    font-family: inherit;
}

.btn-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 99, 163, 0.35);
    background: var(--trimble-dark);
}

.btn-start:active { transform: translateY(0); }

.welcome-visual {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    animation: fadeIn 0.8s ease 0.4s both;
    max-width: 420px;
}

.illustration-img {
    display: flex;
    align-items: center;
    justify-content: center;
}

.illustration-img img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.welcome-preview-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 280px;
}

.preview-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface-alt);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.preview-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--card-color);
    flex-shrink: 0;
}

/* ======================== QUESTION STEPS ======================== */

#questionContainer {
    display: contents;
}

.step-question {
    padding: 0 48px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.question-layout {
    display: flex;
    gap: 40px;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
}

.question-main {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 0;
}

.question-visual {
    flex: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 400px;
}

.question-visual .illustration-img {
    width: 100%;
}

.question-visual .illustration-img img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--section-color);
    margin-bottom: 6px;
}

.section-tag .tag-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--section-color);
}

.question-number {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.question-text {
    font-size: 19px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 28px;
    max-width: 560px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: var(--surface);
}

.option:hover {
    border-color: var(--section-color);
    background: var(--section-light);
}

.option.selected {
    border-color: var(--section-color);
    background: var(--section-light);
    box-shadow: 0 0 0 1px var(--section-color);
}

.option input[type="radio"] {
    display: none;
}

.option-radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.option:hover .option-radio { border-color: var(--section-color); }

.option.selected .option-radio {
    border-color: var(--section-color);
    background: var(--section-color);
}

.option.selected .option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
}

.option-label {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text);
}

.option.selected .option-label {
    color: var(--text);
    font-weight: 600;
}

/* ======================== NAVIGATION BAR ======================== */

.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 48px 20px;
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.nav-bar.hidden { display: none; }

.btn-back, .btn-next {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    border: none;
}

.btn-back {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}

.btn-back:hover {
    color: var(--text);
    border-color: var(--text-light);
}

.btn-back.invisible {
    visibility: hidden;
}

.btn-next {
    background: var(--trimble);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 99, 163, 0.2);
}

.btn-next:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 99, 163, 0.3);
    background: var(--trimble-dark);
}

.btn-next:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-next:not(:disabled) {
    animation: subtleGlow 2.5s ease-in-out infinite;
}

@keyframes subtleGlow {
    0%, 100% { box-shadow: 0 2px 10px rgba(0, 99, 163, 0.2); }
    50% { box-shadow: 0 4px 20px rgba(0, 99, 163, 0.35); }
}

/* ======================== RESULTS SCREEN ======================== */

.step-results {
    background: var(--surface-alt);
    color: var(--text);
    padding: 18px 24px 16px;
    display: flex;
    flex-direction: column;
}

.results-header {
    text-align: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.results-header h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 4px;
}

.results-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.scorecard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* ======================== SCORECARD CARDS ======================== */

.scorecard-card {
    perspective: 1200px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.scorecard-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.scorecard-card.peeking .card-inner {
    animation: peekFront 0.5s ease;
}

.scorecard-card.flipped.peeking .card-inner {
    animation: peekBack 0.5s ease;
}

@keyframes peekFront {
    0%   { transform: rotateY(0deg); }
    40%  { transform: rotateY(18deg); }
    100% { transform: rotateY(0deg); }
}

@keyframes peekBack {
    0%   { transform: rotateY(180deg); }
    40%  { transform: rotateY(162deg); }
    100% { transform: rotateY(180deg); }
}

.card-front, .card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-back {
    transform: rotateY(180deg);
}

/* FRONT */
.card-front {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-color-bar {
    height: 5px;
    flex-shrink: 0;
}

.card-front-body {
    padding: 12px 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
}

.card-section-title {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.card-front-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.gauge-container {
    width: 210px;
    height: 115px;
    flex-shrink: 0;
}

.gauge-container svg {
    width: 100%;
    height: 100%;
}

.card-status {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 4px 0 6px;
}

.card-status.status-green { color: var(--green); }
.card-status.status-amber { color: var(--amber); }
.card-status.status-red { color: var(--red); }

.card-diagnosis-brief {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
}

.card-flip-hint {
    font-size: 11px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.card-flip-hint svg {
    width: 13px;
    height: 13px;
}

/* BACK */
.card-back {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-back-body {
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.card-back-body::-webkit-scrollbar { width: 4px; }
.card-back-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.card-back-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.card-back-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.card-back-section-label.diagnosis-label { color: var(--trimble); }
.card-back-section-label.reality-label { color: var(--text-light); margin-top: 10px; }
.card-back-section-label.insight-label { color: var(--amber); margin-top: 10px; }

.card-back-text {
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
}

/* ======================== RESULTS FOOTER ======================== */

.results-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

.overall-score {
    display: flex;
    align-items: center;
    gap: 12px;
}

.overall-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.overall-value {
    font-size: 20px;
    font-weight: 800;
}

.overall-bar {
    width: 180px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.overall-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1.2s ease;
}

.results-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-restart {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-restart:hover {
    color: var(--text);
    border-color: var(--text-light);
}

.btn-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--trimble);
    color: #fff;
    border: none;
    padding: 14px 30px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 99, 163, 0.2);
    font-family: inherit;
}

.btn-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 99, 163, 0.3);
    background: var(--trimble-dark);
}

/* ======================== GAUGE SVG ======================== */

.gauge-needle {
    transform-origin: 100px 95px;
    transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gauge-arc {
    stroke-linecap: round;
}

/* ======================== ANIMATIONS ======================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.card-animate {
    animation: scaleIn 0.5s ease both;
}

.card-animate:nth-child(1) { animation-delay: 0.1s; }
.card-animate:nth-child(2) { animation-delay: 0.25s; }
.card-animate:nth-child(3) { animation-delay: 0.4s; }
.card-animate:nth-child(4) { animation-delay: 0.55s; }

/* ======================== RESPONSIVE / TABLET ======================== */

@media (max-width: 1099px) {
    body {
        align-items: stretch;
        min-height: 100vh;
    }

    .app-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
    }
}

/* ======================== MOBILE ======================== */

@media (max-width: 768px) {

    /* Welcome */
    .welcome-header {
        padding: 18px 20px 0;
    }

    .trimble-logo {
        height: 26px;
    }

    .welcome-content {
        flex-direction: column;
        padding: 16px 24px 32px;
        gap: 20px;
        align-items: stretch;
    }

    .welcome-text {
        order: 2;
        text-align: center;
        align-items: center;
    }

    .welcome-text h1 {
        font-size: 26px;
        line-height: 1.2;
        margin-bottom: 14px;
    }

    .welcome-subtitle {
        font-size: 14px;
        margin-bottom: 22px;
    }

    .welcome-badge {
        margin: 0 auto;
    }

    .welcome-stats {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 24px;
        align-items: center;
    }

    .welcome-visual {
        order: 1;
        width: 90%;
        max-width: 90%;
        margin: 0 auto;
    }

    .btn-start {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 15px;
    }

    /* Progress bar */
    .progress-bar {
        padding: 12px 16px 10px;
    }

    .progress-sections {
        gap: 6px;
    }

    .progress-label {
        font-size: 9px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
    }

    .progress-meta {
        font-size: 10px;
        margin-top: 6px;
    }

    /* Question screens */
    .step-question {
        padding: 0 20px;
    }

    .question-layout {
        flex-direction: column;
        gap: 14px;
        align-items: stretch;
        padding: 16px 0 8px;
    }

    .question-visual {
        flex: 0 0 auto;
        width: 90%;
        max-width: 90%;
        margin: 0 auto;
    }

    .question-main {
        flex: 1 1 auto;
        padding: 0;
    }

    .question-text {
        font-size: 16px;
        line-height: 1.45;
        margin-bottom: 16px;
    }

    .section-tag {
        font-size: 10px;
    }

    .question-number {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .option {
        padding: 12px 14px;
        gap: 10px;
        border-width: 1.5px;
    }

    .option-label {
        font-size: 14px;
        line-height: 1.4;
    }

    .option-radio {
        width: 20px;
        height: 20px;
    }

    /* Navigation */
    .nav-bar {
        padding: 10px 16px 14px;
    }

    .btn-back, .btn-next {
        padding: 11px 18px;
        font-size: 13px;
    }

    /* Results screen */
    .step-results {
        padding: 16px 16px 14px;
    }

    .results-header {
        margin-bottom: 14px;
    }

    .results-header h2 {
        font-size: 20px;
    }

    .results-subtitle {
        font-size: 12px;
        line-height: 1.4;
    }

    .scorecard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        flex: none;
    }

    .scorecard-card {
        min-height: 320px;
    }

    .gauge-container {
        width: 200px;
        height: 110px;
    }

    .card-section-title {
        font-size: 14px;
    }

    .card-status {
        font-size: 12px;
    }

    .card-diagnosis-brief {
        font-size: 13px;
    }

    .card-back-title {
        font-size: 14px;
    }

    .card-back-section-label {
        font-size: 11px;
    }

    .card-back-text {
        font-size: 12px;
        line-height: 1.4;
    }

    /* Results footer */
    .results-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding-top: 14px;
        margin-top: 12px;
    }

    .overall-score {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 14px;
        text-align: center;
    }

    .overall-label {
        font-size: 12px;
    }

    .overall-value {
        font-size: 18px;
    }

    .overall-bar {
        flex: 0 0 100%;
        width: 100%;
        max-width: 260px;
        margin: 0 auto;
    }

    .results-buttons {
        justify-content: center;
    }

    .btn-restart {
        flex: 1;
        justify-content: center;
        padding: 12px 18px;
        font-size: 13px;
    }
}

/* ======================== SMALL MOBILE ======================== */

@media (max-width: 380px) {
    .welcome-header {
        padding: 16px 16px 0;
    }

    .welcome-content {
        padding: 12px 16px 24px;
    }

    .welcome-text h1 {
        font-size: 22px;
    }

    .progress-label {
        display: none;
    }

    .progress-meta {
        margin-top: 4px;
    }

    .step-question {
        padding: 0 16px;
    }

    .question-text {
        font-size: 15px;
    }

    .gauge-container {
        width: 180px;
        height: 100px;
    }
}
