/* Copyright 2024-2026 Kohei Torii, Tokushima University */

.loading {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background:
        radial-gradient(circle at 15% 15%, rgba(0, 145, 255, 0.2) 0%, rgba(0, 145, 255, 0) 32%),
        radial-gradient(circle at 85% 80%, rgba(0, 54, 145, 0.18) 0%, rgba(0, 54, 145, 0) 38%),
        rgba(247, 250, 255, 0.94);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 1;
    z-index: 1400;
}

.loading.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-panel {
    width: min(92vw, 500px);
    border-radius: 24px;
    padding: 2rem 1.8rem 1.5rem;
    text-align: center;
    backdrop-filter: blur(8px);
    background: linear-gradient(170deg, rgba(255, 255, 255, 0.96), rgba(242, 247, 255, 0.94));
    border: 1px solid rgba(67, 124, 223, 0.16);
    box-shadow:
        0 24px 48px rgba(0, 60, 155, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.loading-orb {
    position: relative;
    width: 92px;
    height: 92px;
    margin: 0 auto 1rem;
}

.loading-orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #0075ff;
    border-left-color: rgba(0, 117, 255, 0.46);
}

.loading-orb-ring.ring-1 {
    animation: loading-orbit 1.6s linear infinite;
}

.loading-orb-ring.ring-2 {
    inset: 12px;
    border-top-color: #004fc9;
    border-left-color: rgba(0, 79, 201, 0.42);
    animation: loading-orbit-reverse 1.05s linear infinite;
}

.loading-orb-core {
    position: absolute;
    inset: 24px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 28%, #9ad4ff 0%, #2f8bff 42%, #0c4ab8 100%);
    box-shadow:
        0 10px 20px rgba(13, 77, 178, 0.38),
        inset 0 1px 2px rgba(255, 255, 255, 0.45);
    animation: loading-core-pulse 1.8s ease-in-out infinite;
}

.loading-text {
    color: #08306f;
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
    font-weight: 700;
    margin: 0.2rem 0 0.15rem;
    text-align: center;
}

.loading-subtext {
    font-size: 0.98rem;
    color: #234a84;
    margin-bottom: 0.8rem;
    min-height: 1.5rem;
}

.loading-pulse-track {
    width: 100%;
    height: 8px;
    background: rgba(0, 105, 225, 0.12);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto 0.9rem;
}

.loading-pulse-fill {
    display: block;
    height: 100%;
    width: 34%;
    border-radius: 999px;
    background: linear-gradient(90deg, #35c0ff 0%, #0f74ff 45%, #1653cf 100%);
    animation: loading-track-move 1.45s ease-in-out infinite;
}

.loading-tip {
    margin: 0;
    font-size: 0.84rem;
    color: #4e6691;
}

@keyframes loading-orbit {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes loading-orbit-reverse {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

@keyframes loading-core-pulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

@keyframes loading-track-move {
    0% {
        transform: translateX(-110%);
    }

    50% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(260%);
    }
}

@media (max-width: 576px) {
    .loading-panel {
        padding: 1.7rem 1.05rem 1.2rem;
        border-radius: 18px;
    }

    .loading-orb {
        width: 78px;
        height: 78px;
        margin-bottom: 0.8rem;
    }

    .loading-orb-core {
        inset: 21px;
    }
}

/* Image zoom modal styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s;
    justify-content: center;
    align-items: center;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-modal-content {
    display: block;
    width: 90%;
    max-width: 1920px;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: modalZoomIn 0.3s;
}

@keyframes modalZoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 1001;
}

.image-modal-close:hover,
.image-modal-close:focus {
    color: #bbb;
    text-decoration: none;
}

/* Add a pointer cursor to clickable images */
.clickable-image {
    cursor: zoom-in;
}

/* Rich run button */
#sendButton {
    position: relative;
    overflow: hidden;
    border: none !important;
    border-radius: 50% !important;
    width: 138px !important;
    height: 138px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
    color: #ffffff !important;
    background:
        radial-gradient(circle at 28% 26%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 42%),
        linear-gradient(140deg, #0086f8 0%, #005eea 48%, #0644b2 100%);
    box-shadow:
        0 14px 30px rgba(7, 79, 200, 0.35),
        inset 0 2px 2px rgba(255, 255, 255, 0.35),
        inset 0 -6px 12px rgba(0, 40, 110, 0.25);
    transition: transform 0.2s ease, box-shadow 0.25s ease, filter 0.25s ease;
    animation: send-button-float 2.6s ease-in-out infinite;
}

#sendButton::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

#sendButton::after {
    content: "";
    position: absolute;
    width: 62%;
    height: 62%;
    top: 10%;
    left: -48%;
    transform: rotate(25deg);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
    animation: send-button-shine 2.8s ease-in-out infinite;
    pointer-events: none;
}

#sendButton .run-button-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    z-index: 1;
}

#sendButton .run-button-icon {
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

#sendButton .run-button-label {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
}

#sendButton .run-button-sub {
    margin-top: 0.22rem;
    font-size: 0.58rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.92;
}

#sendButton:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 18px 34px rgba(7, 79, 200, 0.42),
        inset 0 2px 2px rgba(255, 255, 255, 0.4),
        inset 0 -6px 12px rgba(0, 40, 110, 0.32);
    filter: saturate(1.08);
}

#sendButton:active {
    transform: translateY(1px) scale(0.985);
    box-shadow:
        0 9px 18px rgba(7, 79, 200, 0.38),
        inset 0 1px 2px rgba(255, 255, 255, 0.25),
        inset 0 -8px 14px rgba(0, 31, 95, 0.34);
}

#sendButton:focus-visible {
    outline: 3px solid rgba(40, 152, 255, 0.5);
    outline-offset: 4px;
}

#sendButton:disabled {
    border-color: #6c757d !important;
    background-color: #6c757d !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
    animation: none !important;
}

#sendButton:disabled::after {
    animation: none !important;
}

#sendButton:disabled .run-button-sub,
#sendButton:disabled .run-button-icon {
    opacity: 0.75;
}

@keyframes send-button-shine {
    0% {
        left: -48%;
    }

    55% {
        left: 118%;
    }

    100% {
        left: 118%;
    }
}

@keyframes send-button-float {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-1.5px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #sendButton,
    #sendButton::after {
        animation: none;
    }
}