@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
    --c-primary-navy: #28487F;
    --c-accent-orange: #FD7636;
    --c-white: #FFFFFF;
    --c-off-white: #F8FAFC;
    --c-charcoal: #0C1829;
    --c-slate: #545D70;
    --c-light-slate: #94A3B8;
    --c-border: #E2E8F0;
    --c-bg: var(--c-primary-navy);
    --c-card-bg: var(--c-white);
    --c-text-main: var(--c-charcoal);
    --c-agree-deep: #33a474;
    --c-agree-light: #88c0a7;
    --c-neutral: #cbd5e1;
    --c-disagree-light: #e0a3a3;
    --c-disagree-deep: #be4b49;
    --t-fast: 0.1s ease-out;
    --t-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    caret-color: transparent;
    /* Disable caret globally except inputs */
}

body {
    font-family: 'Outfit', 'Noto Sans KR', sans-serif;
    background-color: var(--c-bg);
    background-image: radial-gradient(at 0% 0%, rgba(40, 72, 127, 0.8) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(20, 40, 80, 0.9) 0px, transparent 50%);
    color: var(--c-text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    /* Prevent accidental text selection on UI */
}

.container {
    width: 100%;
    max-width: 640px;
    padding: 20px;
}

main,
.code-input-section,
.precaution-section {
    background-color: var(--c-card-bg);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
    min-height: 580px;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: cardEntrance 0.6s ease-out forwards;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header h1 {
    color: var(--c-white);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 1.5rem;
}

.header-progress {
    margin-bottom: 2rem;
}

.question-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--c-light-slate);
    margin-bottom: 6px;
    display: block;
}

.progress-container {
    width: 100%;
    height: 5px;
    background-color: #F1F5F9;
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--c-primary-navy), var(--c-accent-orange));
    width: 0%;
    transition: width 0.5s ease;
}

#question-content {
    min-height: 160px;
    margin-bottom: 1.5rem;
}

.question-text {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--c-charcoal);
    line-height: 1.4;
    margin-bottom: 12px;
    user-select: text;
    /* Allow reading question text */
}

.question-additional {
    font-size: 1rem;
    color: var(--c-slate);
    line-height: 1.6;
    user-select: text;
}

.likert-scale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3rem 0;
    position: relative;
    padding: 0 5px;
}

.likert-scale::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--c-border);
    z-index: 0;
}

.likert-circle {
    border-radius: 50%;
    border: 3px solid var(--c-border);
    background: var(--c-white);
    cursor: pointer;
    z-index: 1;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none !important;
}

.size-large {
    width: 62px;
    height: 62px;
}

.size-medium {
    width: 44px;
    height: 44px;
}

.size-small {
    width: 30px;
    height: 30px;
}

.double-circle {
    position: relative;
    border-width: 4px;
}

.double-circle::after {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px;
    right: 6px;
    border: 2.5px solid var(--c-border);
    border-radius: 50%;
    transition: all 0.2s;
}

.disagree-deep {
    border-color: var(--c-disagree-deep);
}

.disagree-deep:hover,
.disagree-deep.selected {
    background: var(--c-disagree-deep);
}

.agree-deep {
    border-color: var(--c-agree-deep);
}

.agree-deep:hover,
.agree-deep.selected {
    background: var(--c-agree-deep);
}

.disagree-light {
    border-color: var(--c-disagree-light);
}

.disagree-light:hover,
.disagree-light.selected {
    background: var(--c-disagree-light);
}

.agree-light {
    border-color: var(--c-agree-light);
}

.agree-light:hover,
.agree-light.selected {
    background: var(--c-agree-light);
}

.neutral {
    border-color: var(--c-neutral);
}

.neutral:hover,
.neutral.selected {
    background: var(--c-neutral);
}

.double-circle::after {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px;
    right: 6px;
    border: 2px solid inherit;
    /* Will match parent color automatically */
    border-radius: 50%;
    transition: all 0.2s;
    border-color: inherit;
}

.disagree-deep.double-circle::after {
    border-color: var(--c-disagree-deep);
}

.agree-deep.double-circle::after {
    border-color: var(--c-agree-deep);
}

.selected.double-circle::after {
    border-color: rgba(255, 255, 255, 0.8);
}

.selected {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.likert-labels {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.85rem;
    margin-top: -15px;
    margin-bottom: 20px;
    padding: 0 10px;
    /* Counter-adjust to match button edges */
}

.likert-labels span {
    flex: 1;
    text-align: center;
}

.label-disagree {
    color: var(--c-disagree-deep);
    text-align: left !important;
}

.label-agree {
    color: var(--c-agree-deep);
    text-align: right !important;
}

.label-neutral {
    color: var(--c-light-slate);
}

.slide-out {
    opacity: 0;
    transform: translateX(-30px);
    transition: 0.2s;
}

.slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.option-btn {
    padding: 16px 20px;
    border: 2px solid var(--c-border);
    border-radius: 12px;
    background: var(--c-white);
    color: var(--c-charcoal);
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0s, border-color 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    outline: none !important;
}

.option-btn:hover {
    border-color: var(--c-primary-navy);
    background: var(--c-off-white);
}

.option-btn.selected {
    border-color: var(--c-primary-navy) !important;
    background: rgba(40, 72, 127, 0.08);
    color: var(--c-primary-navy);
    font-weight: 600;
}

.text-input {
    width: 100%;
    padding: 18px;
    border: 2px solid var(--c-border);
    border-radius: 14px;
    font-size: 1.15rem;
    margin-top: 1rem;
    caret-color: var(--c-primary-navy);
    /* Enable caret only for inputs */
    transition: border-color 0.2s;
    user-select: text;
}

.text-input:focus {
    outline: none;
    border-color: var(--c-primary-navy);
    box-shadow: 0 0 0 4px rgba(40, 72, 127, 0.05);
}

.textarea-input {
    min-height: 160px;
    line-height: 1.5;
    resize: none;
    font-family: inherit;
}

.navigation-buttons {
    display: flex;
    gap: 12px;
    margin-top: 2rem;
}

.nav-btn {
    flex: 1;
    padding: 18px;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    outline: none;
}

.next-btn {
    background: var(--c-primary-navy);
    color: var(--c-white);
}

.next-btn:disabled {
    background: var(--c-border);
    cursor: not-allowed;
}

.btn-submit {
    background: var(--c-accent-orange) !important;
    box-shadow: 0 6px 20px rgba(253, 118, 54, 0.4);
}

#error-message {
    color: var(--c-disagree-deep);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1.2rem;
    min-height: 2.5rem;
    line-height: 1.6;
    text-align: center;
}

.milestone-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through unless it's a blocking loading */
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    /* Top margin + side padding for mobile */
    z-index: 9999;
}

.milestone-content {
    background: white;
    padding: 14px 28px;
    border-radius: 24px;
    border: 2px solid var(--c-primary-navy);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: toastIn 0.4s ease-out forwards;
    max-width: 90%;
    /* Prevent cutoff on thin screens */
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-30px);
    }
}

.milestone-percent {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--c-accent-orange);
}

/* Unified Toast-Style Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 24, 41, 0.4);
    /* Thinner dim for toast feel */
    display: none;
    justify-content: center;
    align-items: flex-start;
    /* Place toast at the top */
    padding-top: 40px;
    z-index: 10001;
}

.toast-content {
    background: white;
    padding: 14px 28px;
    border-radius: 24px;
    border: 2px solid var(--c-primary-navy);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: toastIn 0.4s ease-out forwards;
    max-width: 90%;
    /* Center & limit width on mobile */
    margin: 0 auto;
}

.loading-toast {
    border-color: var(--c-accent-orange);
    /* Differentiate loading with orange */
}

.loader-small {
    width: 20px;
    height: 20px;
    border: 3px solid var(--c-border);
    border-bottom-color: var(--c-accent-orange);
    border-radius: 50%;
    animation: rotation 0.8s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Resume Progress Modal */
#resume-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 24, 41, 0.88);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10005;
    padding: 20px;
}

.resume-card {
    background: white;
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: 28px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    animation: cardEntrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.resume-card h3 {
    color: var(--c-primary-navy);
    margin-bottom: 0.8rem;
    font-size: 1.35rem;
}

.resume-card p {
    color: var(--c-slate);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.resume-buttons {
    display: flex;
    gap: 12px;
}

.resume-btn {
    flex: 1;
    padding: 16px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.resume-btn.primary {
    background: var(--c-primary-navy);
    color: white;
}

.resume-btn.secondary {
    background: var(--c-off-white);
    color: var(--c-slate);
    border: 2px solid var(--c-border);
}

.resume-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

@media (max-width: 480px) {

    main,
    .code-input-section,
    .precaution-section {
        padding: 30px 24px;
        min-height: 520px;
    }

    .question-text {
        font-size: 1.3rem;
    }

    .size-large {
        width: 54px;
        height: 54px;
    }

    .milestone-content,
    .toast-content {
        min-width: unset;
        width: 85%;
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

/* Compact Layout for Mobile Keyboard Safety */
@media (max-width: 480px) {
    #quiz-container.has-text-input main {
        min-height: auto !important;
        padding-top: 20px !important;
        padding-bottom: 20px !important;
        margin-top: 5px !important;
    }

    #quiz-container.has-text-input .header-progress {
        margin-bottom: 0.5rem !important;
    }

    #quiz-container.has-text-input #question-content {
        min-height: auto !important;
        margin-bottom: 0.5rem !important;
    }

    #quiz-container.has-text-input .question-text {
        font-size: 1.1rem !important;
        margin-bottom: 5px !important;
    }

    #quiz-container.has-text-input .text-input {
        padding: 12px !important;
        font-size: 0.95rem !important;
    }

    #quiz-container.has-text-input .navigation-buttons {
        margin-top: 1rem !important;
    }
}