/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #e8e8e8;
    background: #0a0a0a;
    overflow-x: hidden;
    position: relative;
}

body.loading {
    overflow: hidden;
}

html {
    scroll-behavior: smooth;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease-out, visibility 1s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.loading-stars::before,
.loading-stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow:
        25vw 18vh 0 0 #fff, 80vw 30vh 0 0 #fff, 40vw 70vh 0 0 #fff,
        90vw 40vh 0 0 #fff, 15vw 90vh 0 0 #fff, 70vw 60vh 0 0 #fff,
        5vw 50vh 0 0 #fff, 95vw 80vh 0 0 #fff, 35vw 25vh 0 0 #fff,
        60vw 95vh 0 0 #fff, 85vw 15vh 0 0 #fff, 10vw 75vh 0 0 #fff,
        50vw 45vh 0 0 #fff, 75vw 85vh 0 0 #fff, 20vw 65vh 0 0 #fff;
    animation: twinkle 2s infinite ease-in-out alternate;
}

.loading-stars::after {
    width: 1px;
    height: 1px;
    animation: twinkle 1.5s infinite ease-in-out alternate-reverse;
    box-shadow:
        12vw 33vh 0 0 #fff, 87vw 77vh 0 0 #fff, 23vw 12vh 0 0 #fff,
        78vw 45vh 0 0 #fff, 43vw 88vh 0 0 #fff, 67vw 23vh 0 0 #fff,
        18vw 67vh 0 0 #fff, 92vw 8vh 0 0 #fff, 48vw 52vh 0 0 #fff,
        73vw 93vh 0 0 #fff, 3vw 38vh 0 0 #fff, 58vw 18vh 0 0 #fff;
}

.loading-shooting-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.loading-shooting-stars::before,
.loading-shooting-stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: linear-gradient(45deg, #fff, transparent);
    border-radius: 50%;
    animation: shooting 3s linear infinite;
}

.loading-shooting-stars::before {
    top: 20%;
    left: -10%;
    animation-delay: 0s;
}

.loading-shooting-stars::after {
    top: 40%;
    left: -10%;
    animation-delay: 1.5s;
}

.loading-content {
    text-align: center;
    z-index: 10000;
}

.loading-title {
    font-size: 4rem;
    font-weight: bold;
    background: linear-gradient(45deg, #4a9eff, #66b3ff, #80ccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 3rem;
    animation: loadingTitleGlow 2s ease-in-out infinite alternate;
    transform: scale(1);
    transition: all 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.loading-title.shrink {
    transform: scale(0.75) translateY(-200px);
    opacity: 0.8;
}

@keyframes loadingTitleGlow {
    from {
        text-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
        transform: scale(1);
    }
    to {
        text-shadow: 0 0 40px rgba(74, 158, 255, 0.8);
        transform: scale(1.05);
    }
}

.loading-bar-container {
    width: 300px;
    margin: 0 auto;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #66b3ff);
    border-radius: 2px;
    width: 0%;
    animation: loadingProgress 2s ease-out forwards;
    box-shadow: 0 0 10px rgba(74, 158, 255, 0.5);
}

@keyframes loadingProgress {
    0% { width: 0%; }
    25% { width: 40%; }
    60% { width: 75%; }
    85% { width: 95%; }
    100% { width: 100%; }
}

.loading-text {
    color: #b8b8b8;
    font-size: 1rem;
    opacity: 0.8;
    animation: loadingTextPulse 1.5s ease-in-out infinite;
}

@keyframes loadingTextPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Main content initially hidden during loading */
body.loading header,
body.loading main,
body.loading footer {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

body.loaded header,
body.loaded main,
body.loaded footer {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 1s ease-out 0.5s, transform 1s ease-out 0.5s;
}

/* Ensure content is visible by default (in case loading is skipped) */
body:not(.loading) header,
body:not(.loading) main,
body:not(.loading) footer {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Starry Night Background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -2;
}

.stars::before,
.stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow:
        25vw 18vh 0 0 #fff, 80vw 30vh 0 0 #fff, 40vw 70vh 0 0 #fff,
        90vw 40vh 0 0 #fff, 15vw 90vh 0 0 #fff, 70vw 60vh 0 0 #fff,
        5vw 50vh 0 0 #fff, 95vw 80vh 0 0 #fff, 35vw 25vh 0 0 #fff,
        60vw 95vh 0 0 #fff, 85vw 15vh 0 0 #fff, 10vw 75vh 0 0 #fff,
        50vw 45vh 0 0 #fff, 75vw 85vh 0 0 #fff, 20vw 65vh 0 0 #fff,
        65vw 35vh 0 0 #fff, 30vw 55vh 0 0 #fff, 45vw 20vh 0 0 #fff,
        55vw 75vh 0 0 #fff, 15vw 40vh 0 0 #fff, 85vw 60vh 0 0 #fff,
        25vw 80vh 0 0 #fff, 70vw 25vh 0 0 #fff, 40vw 90vh 0 0 #fff,
        80vw 50vh 0 0 #fff, 5vw 20vh 0 0 #fff, 60vw 70vh 0 0 #fff,
        90vw 85vh 0 0 #fff, 35vw 45vh 0 0 #fff, 75vw 10vh 0 0 #fff;
    animation: twinkle 3s infinite ease-in-out alternate;
}

.stars::after {
    width: 1px;
    height: 1px;
    box-shadow:
        12vw 33vh 0 0 #fff, 87vw 77vh 0 0 #fff, 23vw 12vh 0 0 #fff,
        78vw 45vh 0 0 #fff, 43vw 88vh 0 0 #fff, 67vw 23vh 0 0 #fff,
        18vw 67vh 0 0 #fff, 92vw 8vh 0 0 #fff, 48vw 52vh 0 0 #fff,
        73vw 93vh 0 0 #fff, 3vw 38vh 0 0 #fff, 58vw 18vh 0 0 #fff,
        28vw 73vh 0 0 #fff, 83vw 33vh 0 0 #fff, 38vw 58vh 0 0 #fff,
        13vw 83vh 0 0 #fff, 68vw 3vh 0 0 #fff, 93vw 68vh 0 0 #fff,
        8vw 28vh 0 0 #fff, 53vw 78vh 0 0 #fff, 88vw 13vh 0 0 #fff,
        33vw 48vh 0 0 #fff, 78vw 88vh 0 0 #fff, 23vw 8vh 0 0 #fff,
        63vw 63vh 0 0 #fff, 98vw 28vh 0 0 #fff, 18vw 98vh 0 0 #fff;
    animation: twinkle 2s infinite ease-in-out alternate-reverse;
}

@keyframes twinkle {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Shooting Stars */
.shooting-stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.shooting-stars::before,
.shooting-stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: linear-gradient(45deg, #fff, transparent);
    border-radius: 50%;
    animation: shooting 3s linear infinite;
}

.shooting-stars::before {
    top: 10%;
    left: -10%;
    animation-delay: 0s;
}

.shooting-stars::after {
    top: 30%;
    left: -10%;
    animation-delay: 2s;
}

@keyframes shooting {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateX(120vw) translateY(60vh);
        opacity: 0;
    }
}

/* Main Content */
main {
    padding-top: 80px;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
}

.hero-content {
    z-index: 1;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #4a9eff, #66b3ff, #80ccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 20px rgba(74, 158, 255, 0.5); }
    to { text-shadow: 0 0 30px rgba(74, 158, 255, 0.8); }
}

.intro {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #b8b8b8;
    min-height: 1.5em;
    text-align: center;
}

.intro .jp, .intro .en {
    display: block;
    min-height: 1.5em;
}

/* Placeholder Images */
.placeholder-image {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.8), rgba(128, 204, 255, 0.6));
    position: relative;
    overflow: hidden;
}

.placeholder-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.placeholder-image span {
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Project-specific placeholder colors */
.placeholder-image.ai-partner {
    background: linear-gradient(135deg, #4a90e2, #66b3ff);
}

.placeholder-image.ml-research {
    background: linear-gradient(135deg, #50c878, #7dd87d);
}

.placeholder-image.web-app {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
}

.placeholder-image.algorithm {
    background: linear-gradient(135deg, #9b59b6, #b97dd8);
}

.placeholder-image.mobile-app {
    background: linear-gradient(135deg, #f39c12, #f5b042);
}

.placeholder-image.data-analysis {
    background: linear-gradient(135deg, #1abc9c, #48c9b0);
}

/* Blog-specific placeholder colors */
.placeholder-image.tensorflow {
    background: linear-gradient(135deg, #4a90e2, #66b3ff);
}

.placeholder-image.react-hooks {
    background: linear-gradient(135deg, #61dafb, #85e3fc);
}

.placeholder-image.dynamic-programming {
    background: linear-gradient(135deg, #9b59b6, #b97dd8);
}

.placeholder-image.nlp-tutorial {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
}

.placeholder-image.nodejs-api {
    background: linear-gradient(135deg, #50c878, #7dd87d);
}

.placeholder-image.graph-algorithm {
    background: linear-gradient(135deg, #f39c12, #f5b042);
}

/* Profile placeholder */
.placeholder-image.profile {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    font-size: 1rem;
}

/* Blog image specific height */
.blog-image .placeholder-image {
    height: 200px;
}

/* Animation utilities */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: #4a9eff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #66b3ff;
}

/* Hidden elements for language switching - Default to Japanese */
.en {
    display: none;
}

.jp {
    display: block;
}

/* Language switching based on body class */
body.lang-jp .en {
    display: none !important;
}

body.lang-jp .jp {
    display: block !important;
}

body.lang-en .en {
    display: block !important;
}

body.lang-en .jp {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    main {
        padding-top: 120px;
    }

    .hero h1 {
        font-size: 1.7rem;
    }

    .intro {
        font-size: 1rem;
    }

    .loading-title {
        font-size: 2.5rem;
    }

    .loading-bar-container {
        width: 250px;
    }
}
