/* ===== Aviation-themed Error Pages - Common Styles ===== */

:root {
    --err-bg-deep: #0a0e1a;
    --err-bg-mid: #111827;
    --err-cloud: rgba(255, 255, 255, 0.03);
    --err-text: #e8e0d4;
    --err-text-dim: rgba(232, 224, 212, 0.45);
    --err-text-mid: rgba(232, 224, 212, 0.7);
    --err-accent: #f6dc9f;
    --err-accent-dim: rgba(246, 220, 159, 0.5);
    --err-gold: #dab584;
}

body {
    background-color: var(--err-bg-deep);
    overflow-x: hidden;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    color: var(--err-text);
}

/* ===== Main Container ===== */

.error_main {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.error_container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ===== Sky Background Layers ===== */

.error_sky {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.error_sky::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 120%, rgba(30, 58, 95, 0.5) 0%, transparent 60%),
                radial-gradient(ellipse at 20% 80%, rgba(26, 35, 60, 0.4) 0%, transparent 50%);
}

/* ===== Stars ===== */

.error_stars {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.error_star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: starTwinkle 3s ease-in-out infinite;
}

@keyframes starTwinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ===== Clouds ===== */

.error_clouds {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.error_cloud {
    position: absolute;
    background: radial-gradient(ellipse, rgba(255,255,255,0.06) 0%, transparent 70%);
    border-radius: 50%;
    animation: cloudDrift 30s linear infinite;
}

.error_cloud:nth-child(1) {
    width: 500px; height: 120px;
    top: 20%; left: -200px;
    animation-duration: 40s;
}

.error_cloud:nth-child(2) {
    width: 350px; height: 80px;
    top: 45%; left: -150px;
    animation-duration: 55s;
    animation-delay: -15s;
}

.error_cloud:nth-child(3) {
    width: 600px; height: 100px;
    top: 70%; left: -250px;
    animation-duration: 45s;
    animation-delay: -25s;
}

@keyframes cloudDrift {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 600px)); }
}

/* ===== Altimeter / Instrument ===== */

.error_instrument {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 5;
    opacity: 0.15;
    pointer-events: none;
}

.error_instrument svg {
    width: 120px;
    height: 120px;
}

/* ===== Content ===== */

.error_content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 120px 24px 80px;
    max-width: 640px;
    animation: errorContentFadeIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes errorContentFadeIn {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Error Code ===== */

.error_code {
    font-family: "Noto Sans JP", sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--err-text-dim);
    margin-bottom: 8px;
}

.error_altitude {
    font-family: "Zen Old Mincho", serif;
    font-weight: 900;
    font-size: 72px;
    color: var(--err-accent);
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 4px;
    text-shadow: 0 0 40px rgba(246, 220, 159, 0.2);
    animation: altitudeGlow 4s ease-in-out infinite;
}

@keyframes altitudeGlow {
    0%, 100% { text-shadow: 0 0 40px rgba(246, 220, 159, 0.15); }
    50% { text-shadow: 0 0 60px rgba(246, 220, 159, 0.3); }
}

.error_altitude_unit {
    font-family: "Noto Sans JP", sans-serif;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0.2em;
    color: var(--err-text-dim);
    margin-bottom: 24px;
}

/* ===== Title ===== */

.error_title {
    font-family: "Zen Old Mincho", serif;
    font-weight: 900;
    font-size: 28px;
    color: var(--err-text);
    letter-spacing: 0.08em;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* ===== Message ===== */

.error_message {
    font-family: "Shippori Mincho", serif;
    font-weight: 500;
    font-size: 15px;
    color: var(--err-text-mid);
    line-height: 2;
    margin-bottom: 8px;
}

/* ===== Divider ===== */

.error_divider {
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--err-accent-dim), transparent);
    margin: 28px 0;
}

/* ===== Event Date ===== */

.error_date {
    font-family: "Zen Old Mincho", serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--err-accent);
    line-height: 1.6;
}

.error_date span {
    font-family: "Noto Sans JP", sans-serif;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0.15em;
    color: var(--err-text-dim);
}

/* ===== Back Button ===== */

.error_back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 36px;
    padding: 12px 28px;
    font-family: "Shippori Mincho", serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--err-accent);
    text-decoration: none;
    border: 1px solid var(--err-accent-dim);
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}

.error_back::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(246, 220, 159, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.error_back:hover {
    border-color: var(--err-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(246, 220, 159, 0.1);
}

.error_back:hover::before {
    opacity: 1;
}

.error_back .back_arrow {
    font-size: 16px;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.error_back span:last-child {
    position: relative;
    z-index: 1;
}

.error_back:hover .back_arrow {
    transform: translateX(-3px);
}

/* ===== Floating Particles ===== */

.error_particles {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.error_particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(246, 220, 159, 0.3);
    border-radius: 50%;
    animation: particleRise 8s linear infinite;
}

.error_particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 7s; }
.error_particle:nth-child(2) { left: 25%; animation-delay: -2s; animation-duration: 9s; }
.error_particle:nth-child(3) { left: 40%; animation-delay: -4s; animation-duration: 6s; }
.error_particle:nth-child(4) { left: 55%; animation-delay: -1s; animation-duration: 10s; }
.error_particle:nth-child(5) { left: 70%; animation-delay: -3s; animation-duration: 8s; }
.error_particle:nth-child(6) { left: 85%; animation-delay: -5s; animation-duration: 7s; }
.error_particle:nth-child(7) { left: 15%; animation-delay: -6s; animation-duration: 11s; }
.error_particle:nth-child(8) { left: 60%; animation-delay: -7s; animation-duration: 9s; }

@keyframes particleRise {
    from {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) scale(1);
    }
    90% {
        opacity: 0.6;
    }
    to {
        transform: translateY(-20vh) scale(0.5);
        opacity: 0;
    }
}

/* ===== Horizon Line ===== */

.error_horizon {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 5%, rgba(246, 220, 159, 0.1) 30%, rgba(246, 220, 159, 0.15) 50%, rgba(246, 220, 159, 0.1) 70%, transparent 95%);
    z-index: 3;
}

/* ===== Page-specific Gradient Overrides ===== */

/* 404 - Above the clouds - deep indigo */
.error_container.error_404 {
    background: linear-gradient(180deg, #070b15 0%, #0d1526 30%, #152040 60%, #1a2a50 100%);
}

/* 500 - Instrument failure - dark red tint */
.error_container.error_500 {
    background: linear-gradient(180deg, #0a0808 0%, #1a0f0f 30%, #1f1215 60%, #151020 100%);
}

/* 503 - Turbulence - stormy purple */
.error_container.error_503 {
    background: linear-gradient(180deg, #08070f 0%, #110f20 30%, #1a1530 60%, #15102a 100%);
}

/* 403 - Restricted airspace - dark teal */
.error_container.error_403 {
    background: linear-gradient(180deg, #060d0f 0%, #0a181c 30%, #0f2028 60%, #0d1a22 100%);
}

/* ===== Status-specific icon colors ===== */

.error_500 .error_altitude { color: #ff8a80; text-shadow: 0 0 40px rgba(255,138,128,0.2); }
.error_500 .error_date { color: #ff8a80; }
.error_500 .error_back { color: #ff8a80; border-color: rgba(255,138,128,0.3); }
.error_500 .error_back:hover { border-color: #ff8a80; box-shadow: 0 8px 24px rgba(255,138,128,0.1); }
.error_500 .error_divider { background: linear-gradient(90deg, transparent, rgba(255,138,128,0.4), transparent); }
.error_500 .error_particle { background: rgba(255,138,128,0.3); }

.error_503 .error_altitude { color: #b39ddb; text-shadow: 0 0 40px rgba(179,157,219,0.2); }
.error_503 .error_date { color: #b39ddb; }
.error_503 .error_back { color: #b39ddb; border-color: rgba(179,157,219,0.3); }
.error_503 .error_back:hover { border-color: #b39ddb; box-shadow: 0 8px 24px rgba(179,157,219,0.1); }
.error_503 .error_divider { background: linear-gradient(90deg, transparent, rgba(179,157,219,0.4), transparent); }
.error_503 .error_particle { background: rgba(179,157,219,0.3); }

.error_403 .error_altitude { color: #80cbc4; text-shadow: 0 0 40px rgba(128,203,196,0.2); }
.error_403 .error_date { color: #80cbc4; }
.error_403 .error_back { color: #80cbc4; border-color: rgba(128,203,196,0.3); }
.error_403 .error_back:hover { border-color: #80cbc4; box-shadow: 0 8px 24px rgba(128,203,196,0.1); }
.error_403 .error_divider { background: linear-gradient(90deg, transparent, rgba(128,203,196,0.4), transparent); }
.error_403 .error_particle { background: rgba(128,203,196,0.3); }

.error_418 .error_altitude { color: #477f33; text-shadow: 0 0 40px rgba(128,203,196,0.2); }
.error_418 .error_date { color: #477f33; }
.error_418 .error_back { color: #477f33; border-color: rgba(128,203,196,0.3); }
.error_418 .error_back:hover { border-color: #477f33; box-shadow: 0 8px 24px rgba(128,203,196,0.1); }
.error_418 .error_divider { background: linear-gradient(90deg, transparent, rgba(128,203,196,0.4), transparent); }
.error_418 .error_particle { background: rgba(128,203,196,0.3); }

/* ===== 503 Turbulence Effect ===== */

.error_503 .error_content {
    animation: errorContentFadeIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) both,
               turbulenceShake 6s ease-in-out 2s infinite;
}

@keyframes turbulenceShake {
    0%, 100% { transform: translateX(0) translateY(0); }
    15% { transform: translateX(-1px) translateY(0.5px); }
    30% { transform: translateX(1px) translateY(-0.5px); }
    45% { transform: translateX(-0.5px) translateY(1px); }
    60% { transform: translateX(0.5px) translateY(-1px); }
    75% { transform: translateX(-1px) translateY(0.5px); }
}

/* ===== 500 Glitch Effect ===== */

.error_500 .error_altitude {
    animation: altitudeGlow 4s ease-in-out infinite, instrumentGlitch 8s step-end infinite;
}

@keyframes instrumentGlitch {
    0%, 97%, 100% { opacity: 1; transform: none; }
    97.5% { opacity: 0.8; transform: translateX(2px); }
    98% { opacity: 1; transform: translateX(-1px); }
    98.5% { opacity: 0.6; transform: translateX(1px) skewX(1deg); }
    99% { opacity: 1; transform: none; }
}

/* ===== 403 Lock Pulse ===== */

.error_403 .error_lock_icon {
    display: inline-block;
    margin-bottom: 16px;
    animation: lockPulse 3s ease-in-out infinite;
}

@keyframes lockPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* ===== Responsive: PC ===== */

@media screen and (min-width: 1024px) {
    .error_altitude {
        font-size: 96px;
    }

    .error_title {
        font-size: 34px;
    }

    .error_message {
        font-size: 16px;
    }

    .error_instrument svg {
        width: 160px;
        height: 160px;
    }

    .error_cloud:nth-child(1) { width: 800px; height: 180px; }
    .error_cloud:nth-child(2) { width: 600px; height: 130px; }
    .error_cloud:nth-child(3) { width: 900px; height: 160px; }
}

/* ===== Responsive: Tablet ===== */

@media screen and (min-width: 768px) and (max-width: 1023px) {
    .error_altitude {
        font-size: 84px;
    }

    .error_title {
        font-size: 30px;
    }
}

/* ===== Responsive: Small mobile ===== */

@media screen and (max-width: 400px) {
    .error_altitude {
        font-size: 56px;
    }

    .error_title {
        font-size: 22px;
    }

    .error_message {
        font-size: 13px;
    }

    .error_back {
        font-size: 13px;
        padding: 10px 22px;
    }

    .error_date {
        font-size: 14px;
    }

    .error_date span {
        font-size: 11px;
    }

    .error_content {
        padding: 100px 20px 60px;
    }

    .error_instrument {
        bottom: 20px;
        right: 20px;
    }

    .error_instrument svg {
        width: 80px;
        height: 80px;
    }
}

/* ===== Override header/footer for dark theme ===== */

.error_main ~ footer .footer_container {
    background-color: var(--err-bg-mid);
}
