/* Modal styles */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: #fff7ed;
    /* orange-50 */
    padding: 2rem;
    border: 2px solid #292524;
    /* stone-800 */
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    max-width: 90%;
    width: 500px;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-backdrop.visible .modal-content {
    transform: scale(1);
}

/* Ensure message modal is always on top */
#message-modal {
    z-index: 10000 !important;
}

.apply-modal-backdrop {
    position: fixed;
    inset: 0;
    right: 0;
    background: linear-gradient(to bottom, #0b224f, #1d133f);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    width: 100%;
    height: 100%;
    transform: translateX(100%);
    transform-origin: right center;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
    will-change: transform;
}

.apply-modal-backdrop.visible {
    transform: translateX(0);
    pointer-events: auto;
    opacity: 1;
}

.apply-modal-backdrop.visible .modal-content {
    transform: scale(1);

}

.apply-modal-backdrop:not(.visible) {
    overflow: hidden;
}

#apply-close-btn {
    position: fixed !important;
    top: 1rem !important;
    right: 1rem !important;
    background: #fff7ed;
    color: #292524;
    width: 4vw;
    height: 4vw;
    min-width: 50px;
    min-height: 50px;
    align-content: center;
    font-weight: bold;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    z-index: 100;
}

#apply-close-btn:hover {
    background: #fff;
    border: 2px solid #5a3ac7;
    color: #5a3ac7;
    transition: 0.1s ease;
}

/* Sections container for page turn effect */
#apply-sections-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
}

/* Apply sections base styles */
.apply-section {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
                opacity 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
                visibility 0s 0.8s;
    z-index: 1;
}

/* Section 1 - starts visible, flips out to the left */
#apply-section-1 {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
}

#apply-section-1.page-turn-out {
    transform: rotateY(-180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 1;
}

/* Section 2 - starts hidden on the right, flips in */
#apply-section-2 {
    transform: rotateY(180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#apply-section-2.page-turn-in {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
    transition-delay: 0s;
}

#apply-section-2.page-turn-out {
    transform: rotateY(-180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 1;
}

/* Section 3 - starts hidden on the right, flips in */
#apply-section-3 {
    transform: rotateY(180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#apply-section-3.page-turn-in {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
    transition-delay: 0s;
}

#apply-section-3.page-turn-out {
    transform: rotateY(-180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 1;
}

/* Custom validation styles */
.field-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.input-error {
    border-color: #ef4444 !important;
    background-color: #fee;
}

.input-error:focus {
    border-color: #dc2626 !important;
}

/* Snow effect */
.snow-container {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.snowflake {
    position: absolute;
    top: -50px;
    color: rgba(255, 255, 255, 0.15);
    font-size: 2em;
    user-select: none;
    pointer-events: none;
    animation: fall linear infinite;
}

@keyframes fall {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.15;
    }
    90% {
        opacity: 0.15;
    }
    100% {
        transform: translateY(100vh) translateX(50px) rotate(360deg);
        opacity: 0;
    }
}

/* Lamplight glow for apply modal buttons */
.apply-modal-backdrop button,
.apply-modal-backdrop input[type="submit"] {
    position: relative;
    box-shadow: 0 0 20px rgba(255, 247, 237, 0.3),
                0 0 40px rgba(255, 247, 237, 0.15),
                0 10px 15px -3px rgb(0 0 0 / 0.1);
    animation: lamplight-pulse 3s ease-in-out infinite;
}

@keyframes lamplight-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 247, 237, 0.3),
                    0 0 40px rgba(255, 247, 237, 0.15),
                    0 10px 15px -3px rgb(0 0 0 / 0.1);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 247, 237, 0.4),
                    0 0 50px rgba(255, 247, 237, 0.2),
                    0 10px 15px -3px rgb(0 0 0 / 0.1);
    }
}

.apply-modal-backdrop button:hover,
.apply-modal-backdrop input[type="submit"]:hover {
    animation: lamplight-pulse 1.5s ease-in-out infinite;
}

/* Craft cards grid */
.craft-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.craft-card {
    background: rgba(255, 247, 237, 0.9);
    border: 2px solid #292524;
    border-radius: 8px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.craft-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 247, 237, 1);
    border-color: #5a3ac7;
}

.craft-card.selected {
    background: #5a3ac7;
    border-color: #5a3ac7;
    transform: scale(1.05);
}

.craft-card.selected .craft-label {
    color: #fff7ed;
}

.craft-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.craft-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: #292524;
    font-family: 'Inter', sans-serif;
}

/* Craft description container */
.craft-description-container {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                margin-top 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0;
}

.craft-description-container.expanded {
    max-height: 400px;
    opacity: 1;
    margin-top: 1.5rem;
}

#craft-description {
    background: rgba(255, 247, 237, 0.95);
}

#craft-continue-btn {
    display: block;
    margin: 0 auto;
}

/* Section 4 - starts hidden on the right, flips in */
#apply-section-4 {
    transform: rotateY(180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#apply-section-4.page-turn-in {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
    transition-delay: 0s;
}

#apply-section-4.page-turn-out {
    transform: rotateY(-180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 1;
}

/* Section 5 - starts hidden on the right, flips in */
#apply-section-5 {
    transform: rotateY(180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#apply-section-5.page-turn-in {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
    transition-delay: 0s;
}

/* Darkening effect for section 5 */
.apply-modal-backdrop.soul-chapter {
    background: linear-gradient(to bottom, #06152f, #0f0820);
    transition: background 1s ease;
}

.apply-modal-backdrop.soul-chapter .snowflake {
    animation-duration: 25s !important;
}

/* Soul question styling */
#soul-question {
    background: rgba(255, 247, 237, 0.95);
    border: 2px solid #78350f;
    font-size: 1.125rem;
    line-height: 1.8;
    font-family: 'Merriweather', serif;
}

/* Section 6 - starts hidden on the right, flips in */
#apply-section-6 {
    transform: rotateY(180deg);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#apply-section-6.page-turn-in {
    transform: rotateY(0deg);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 2;
    transition-delay: 0s;
}

/* Toggle buttons */
.toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.toggle-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 247, 237, 0.6);
    border: 2px solid #d6d3d1;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.875rem;
    color: #57534e;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-btn:hover {
    background: rgba(255, 247, 237, 0.9);
    border-color: #a8a29e;
    transform: translateY(-2px);
}

.toggle-btn.active {
    background: #5a3ac7;
    border-color: #5a3ac7;
    color: #fff7ed;
    transform: scale(1.05);
}

.toggle-btn.active:hover {
    background: #4c2fb8;
    border-color: #4c2fb8;
}

/* Corkboard styling */
.corkboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.pinned-note {
    position: relative;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #d4a574;
    border-radius: 2px;
    padding: 1.5rem 1rem 1rem 1rem;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transform: rotate(-1deg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pinned-note:nth-child(even) {
    transform: rotate(1deg);
}

.pinned-note:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 3px 5px 12px rgba(0, 0, 0, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Pushpin at top */
.pushpin {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c92a2a);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
                inset -2px -2px 4px rgba(0, 0, 0, 0.2);
}

.pushpin::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.3;
}

.note-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    color: #78350f;
    margin-bottom: 0.5rem;
    text-align: center;
}

.note-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    border: none;
    border-bottom: 2px dashed #d4a574;
    padding: 0.5rem 0.25rem;
    font-size: 0.875rem;
    color: #78350f;
    transition: all 0.2s;
}

.note-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: #92400e;
}

.note-input::placeholder {
    color: #a16207;
    opacity: 0.5;
}

/* File upload note styling */
.file-upload-note {
    grid-column: span 2;
}

.file-input {
    display: none;
}

.file-upload-label {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    border: 2px dashed #d4a574;
    border-radius: 4px;
    text-align: center;
    font-size: 0.875rem;
    color: #78350f;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-label:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: #92400e;
}

.file-list {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #78350f;
}

.file-list-item {
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.25rem;
    border-radius: 2px;
}

@media (max-width: 640px) {
    .corkboard {
        grid-template-columns: 1fr;
    }

    .file-upload-note {
        grid-column: span 1;
    }
}

/* Envelope Animation */
.envelope-backdrop {
    position: fixed;
    inset: 0;
    background: linear-gradient(to bottom, #0b224f, #1d133f);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.envelope-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.envelope-container {
    position: relative;
    width: 300px;
    height: 200px;
    margin-bottom: 3rem;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.envelope-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f3e5d3 0%, #e8d5c1 100%);
    border: 2px solid #c4a57b;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(135deg, #e8d5c1 0%, #d4c0a8 100%);
    border: 2px solid #c4a57b;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    transform-origin: top center;
    transform: rotateX(180deg);
    z-index: 2;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.letter {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(0);
    z-index: 1;
}

.snowflake-icon {
    font-size: 3rem;
    color: #5a3ac7;
    opacity: 0.3;
}

/* Animation states */
.envelope-backdrop.animating .envelope-flap {
    animation: open-flap 1s ease forwards;
}

@keyframes open-flap {
    0% {
        transform: rotateX(180deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

/* Envelope message */
.envelope-message {
    text-align: center;
    color: #fff7ed;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 2s, transform 0.8s ease 2s;
}

.envelope-backdrop.animating .envelope-message {
    opacity: 1;
    transform: translateY(0);
}

.envelope-title {
    font-size: 2rem;
    font-family: 'Merriweather', serif;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #fff7ed;
}

.envelope-subtitle {
    font-size: 1.25rem;
    font-family: 'Merriweather', serif;
    margin-bottom: 1rem;
    color: #fde68a;
}

.envelope-text {
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1rem;
    color: #e7e5e4;
}

.envelope-footer {
    font-size: 1.125rem;
    font-style: italic;
    font-family: 'Merriweather', serif;
    color: #d6d3d1;
    margin-top: 2rem;
}

.envelope-close-btn {
    margin-top: 2rem;
    padding: 0.75rem 2rem;
    background: rgba(255, 247, 237, 0.9);
    border: 2px solid #78350f;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #78350f;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 247, 237, 0.3),
                0 0 40px rgba(255, 247, 237, 0.15);
    animation: lamplight-pulse 3s ease-in-out infinite;
}

.envelope-close-btn:hover {
    background: #fff7ed;
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(255, 247, 237, 0.4),
                0 0 50px rgba(255, 247, 237, 0.2);
}

/* Resume Upload Sections */
.quick-apply-container {
    padding: 1rem 0;
}

.resume-upload-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease, opacity 0.5s ease, margin-top 0.5s ease;
    margin-top: 0;
}

.resume-upload-section.visible {
    max-height: 200px;
    opacity: 1;
    margin-top: 1rem;
}

.resume-file-input {
    display: none;
}

.resume-upload-label,
.resume-upload-label-full {
    display: block;
    width: 100%;
    padding: 1rem;
    background: rgba(255, 247, 237, 0.8);
    border: 2px dashed #d6d3d1;
    border-radius: 8px;
    text-align: center;
    font-size: 0.875rem;
    color: #57534e;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.resume-upload-label:hover,
.resume-upload-label-full:hover {
    background: rgba(255, 247, 237, 1);
    border-color: #a8a29e;
    transform: translateY(-2px);
}

.resume-upload-box {
    background: rgba(255, 255, 255, 0.5);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e7e5e4;
}

.resume-status {
    margin-top: 0.5rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    border-radius: 4px;
}

.resume-status.success {
    background: #d1fae5;
    color: #065f46;
}

.resume-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.resume-status.processing {
    background: #fef3c7;
    color: #92400e;
}