:root {
    --fg-color: #f8f8f8;
    --bg-overlay: rgba(0, 0, 0, 0.4);
    --accent-color: #ccc;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: rgba(248, 248, 248, 0.08);
    --card-hover: rgba(248, 248, 248, 0.16);
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    height: 100%;
    font-family: "Noto Sans JP", sans-serif;
    overflow-x: hidden;
    color: var(--fg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Zen Loading Screen */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 1s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.bg {
    background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), url('img/bg.jpg');
    min-height: 100vh;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    padding: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
}

.bg.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.content {
    color: var(--fg-color);
    text-align: center;
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px var(--shadow-color);
}

/* Profile section */
.profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    opacity: 0;
    animation: subtleFadeIn 0.8s ease-out 0.5s forwards;
}

.profile-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px var(--shadow-color);
    position: relative;
    transition: all var(--transition-speed) ease;
}

.profile-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.profile:hover .profile-image {
    transform: scale(1.05);
    border-color: var(--fg-color);
}

.profile:hover .profile-image img {
    transform: scale(1.1);
}

/* Description */
.description {
    color: var(--accent-color);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    max-width: 350px;
    opacity: 0;
    animation: subtleFadeIn 0.8s ease-out 0.7s forwards;
}

.description h4 {
    color: var(--fg-color);
    font-weight: 400;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-family: "Noto Serif JP", serif;
    letter-spacing: 0.02em;
}

.description p {
    margin-bottom: 0.5rem;
    font-weight: 300;
}

/* Wave animation */
.wave {
    display: inline-block;
    animation: wave 2.5s infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* Sparkle animation */
.sparkle {
    display: inline-block;
    animation: sparkle 1.5s infinite;
}

@keyframes sparkle {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Links */
.links {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 2rem auto;
    opacity: 0;
    animation: subtleFadeIn 0.8s ease-out 0.9s forwards;
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    background: var(--card-bg);
    border-radius: 12px;
    text-decoration: none;
    color: var(--fg-color);
    transition: all var(--transition-speed) ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    font-weight: 300;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(10px);
}

.link-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
                rgba(248, 248, 248, 0) 0%, 
                rgba(248, 248, 248, 0.05) 50%, 
                rgba(248, 248, 248, 0) 100%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    z-index: 1;
}

.link-card:hover::before {
    transform: translateX(100%);
}

.link-card:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: var(--fg-color);
}

.link-card i {
    font-size: 1.2rem;
    z-index: 2;
    color: var(--fg-color);
    width: 24px;
    text-align: center;
    display: flex;
    justify-content: center;
    transition: color var(--transition-speed) ease;
}

.link-card span {
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    z-index: 2;
}

/* Individual link animations */
.links .link-card:nth-child(1) {
    animation: slideIn 0.5s ease-out 1.0s forwards;
}
.links .link-card:nth-child(2) {
    animation: slideIn 0.5s ease-out 1.1s forwards;
}
.links .link-card:nth-child(3) {
    animation: slideIn 0.5s ease-out 1.2s forwards;
}
.links .link-card:nth-child(4) {
    animation: slideIn 0.5s ease-out 1.3s forwards;
}
.links .link-card:nth-child(5) {
    animation: slideIn 0.5s ease-out 1.4s forwards;
}

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

/* Footer */
.footer {
    color: var(--accent-color);
    font-size: 0.8rem;
    text-align: center;
    width: 100%;
    padding: 0 1rem;
    font-weight: 300;
    opacity: 0;
    animation: subtleFadeIn 0.8s ease-out 1.5s forwards;
}

.footer a {
    color: var(--fg-color);
    text-decoration: none;
    position: relative;
    transition: color var(--transition-speed) ease;
    border-bottom: 1px solid transparent;
}

.footer a:hover {
    color: var(--fg-color);
    border-bottom-color: var(--fg-color);
}

/* Kanji Signature */
.kanji-signature {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: "Noto Serif JP", serif;
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--accent-color);
    writing-mode: vertical-rl;
    text-orientation: upright;
    z-index: 10;
    opacity: 0.7;
    transition: opacity var(--transition-speed) ease;
    line-height: 1.2;
}

.kanji-signature:hover {
    opacity: 1;
}

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

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .bg {
        padding: 1rem;
        background-attachment: scroll;
    }
    
    .content {
        max-width: 340px;
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }
    
    .profile-image {
        width: 100px;
        height: 100px;
    }
    
    .description {
        font-size: 0.85rem;
    }
    
    .description h4 {
        font-size: 1rem;
    }
    
    .link-card {
        padding: 0.7rem 1rem;
    }
    
    .link-card i {
        font-size: 1.1rem;
    }
    
    .link-card span {
        font-size: 0.9rem;
    }
    
    .kanji-signature {
        font-size: 1rem;
        bottom: 15px;
        right: 15px;
    }
}

/* Focus styles for accessibility */
.link-card:focus {
    outline: 2px solid var(--fg-color);
    outline-offset: 2px;
}

/* Monochrome 2025 Spotify Widget */
#now-playing {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    
    /* 2025 Glassmorphism Container */
    background: rgba(248, 248, 248, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(248, 248, 248, 0.15);
    border-radius: 50px;
    padding: 12px 20px 12px 16px;
    
    /* Typography */
    font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: var(--fg-color);
    text-align: center;
    white-space: nowrap;
    max-width: 90vw;
    
    /* 2025 Smooth Animations */
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(20px) scale(0.95);
}

/* Show with modern entrance animation */
#now-playing:not(:empty) {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* Audio Visualizer Bars */
#now-playing::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 14px;
    background: 
        linear-gradient(to top, var(--fg-color) 0%, var(--fg-color) 100%),
        linear-gradient(to top, var(--fg-color) 0%, var(--fg-color) 100%),
        linear-gradient(to top, var(--fg-color) 0%, var(--fg-color) 100%),
        linear-gradient(to top, var(--fg-color) 0%, var(--fg-color) 100%);
    background-size: 2px 100%, 2px 100%, 2px 100%, 2px 100%;
    background-position: 0 100%, 4px 100%, 8px 100%, 12px 100%;
    background-repeat: no-repeat;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

/* Animated bars when playing */
#now-playing.playing::before {
    animation: audioBars 1.2s ease-in-out infinite;
    opacity: 1;
}

@keyframes audioBars {
    0% { 
        background-size: 2px 30%, 2px 60%, 2px 40%, 2px 80%; 
    }
    25% { 
        background-size: 2px 80%, 2px 40%, 2px 90%, 2px 30%; 
    }
    50% { 
        background-size: 2px 60%, 2px 100%, 2px 50%, 2px 70%; 
    }
    75% { 
        background-size: 2px 40%, 2px 30%, 2px 80%, 2px 90%; 
    }
    100% { 
        background-size: 2px 30%, 2px 60%, 2px 40%, 2px 80%; 
    }
}

/* Content wrapper to make space for audio bars */
#now-playing .spotify-content {
    padding-left: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modern hover effects */
#now-playing:hover {
    background: rgba(248, 248, 248, 0.08);
    border-color: rgba(248, 248, 248, 0.25);
    transform: translateX(-50%) translateY(-4px) scale(1.02);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(248, 248, 248, 0.1);
}

#now-playing:hover::before {
    opacity: 1;
}

/* Link styling */
#now-playing a {
    color: var(--fg-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

#now-playing a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--fg-color);
    transition: width 0.3s ease;
}

#now-playing a:hover {
    color: var(--fg-color);
    transform: translateY(-1px);
}

#now-playing a:hover::after {
    width: 100%;
}

/* State-specific styling */
#now-playing .error {
    color: var(--accent-color);
    opacity: 0.8;
}

#now-playing .info {
    color: var(--accent-color);
    opacity: 0.9;
}

#now-playing .loading {
    color: var(--accent-color);
    opacity: 0.7;
}

/* Loading state with subtle pulse */
#now-playing.loading {
    animation: modernPulse 2s ease-in-out infinite;
}

#now-playing.loading::before {
    animation: loadingBars 1s ease-in-out infinite;
}

@keyframes modernPulse {
    0%, 100% { 
        opacity: 0.8; 
        transform: translateX(-50%) scale(1);
    }
    50% { 
        opacity: 1; 
        transform: translateX(-50%) scale(1.01);
    }
}

@keyframes loadingBars {
    0%, 100% { 
        background-size: 2px 20%, 2px 40%, 2px 30%, 2px 50%; 
        opacity: 0.5;
    }
    50% { 
        background-size: 2px 60%, 2px 80%, 2px 70%, 2px 90%; 
        opacity: 0.8;
    }
}

/* Authentication required state */
#now-playing.auth-required {
    border-color: rgba(248, 248, 248, 0.2);
}

#now-playing.auth-required::before {
    animation: staticBars 0.8s ease-in-out infinite alternate;
}

@keyframes staticBars {
    0% { 
        background-size: 2px 30%, 2px 30%, 2px 30%, 2px 30%; 
        opacity: 0.4;
    }
    100% { 
        background-size: 2px 50%, 2px 50%, 2px 50%, 2px 50%; 
        opacity: 0.7;
    }
}

/* 2025 Mobile Design */

@media (max-width: 768px) {
    #now-playing {
        bottom: 20px; /* Much closer to bottom */
        left: 15px;
        right: 15px;
        transform: translateX(0);
        border-radius: 20px; /* Smaller radius */
        padding: 6px 12px 6px 10px; /* Much more compact */
        font-size: 11px; /* Smaller text */
        max-width: none;
        
        /* Less visible background */
        background: rgba(248, 248, 248, 0.03);
        border-color: rgba(248, 248, 248, 0.1);
        opacity: 0.8; /* Slightly transparent by default */
    }
    
    #now-playing::before {
        left: 10px;
        width: 12px; /* Smaller bars */
        height: 8px;
        background-size: 1px 100%, 1px 100%, 1px 100%, 1px 100%;
        background-position: 0 100%, 2.5px 100%, 5px 100%, 7.5px 100%;
        opacity: 0.6; /* More subtle bars */
    }
    
    #now-playing .spotify-content {
        padding-left: 18px; /* Less padding */
        gap: 4px;
    }
    
    #now-playing:hover {
        transform: translateY(-1px) scale(1.01); /* Less dramatic hover */
        opacity: 1;
        background: rgba(248, 248, 248, 0.05);
    }
    
    #now-playing:not(:empty) {
        transform: translateX(0) translateY(0) scale(1);
    }
    
    #now-playing.loading {
        transform: translateX(0) scale(1);
    }
    
    /* Kanji signature moves up to avoid overlap */
    .kanji-signature {
        bottom: 55px !important; /* Move well above the widget */
        right: 15px !important;
        font-size: 0.9rem !important;
        opacity: 0.5 !important; /* More subtle */
    }
    
    @keyframes modernPulse {
        0%, 100% { 
            opacity: 0.7; 
            transform: translateX(0) scale(1);
        }
        50% { 
            opacity: 0.9; 
            transform: translateX(0) scale(1.005); /* Very subtle pulse */
        }
    }
}

/* Extra small screens - even more compact */
@media (max-width: 480px) {
    #now-playing {
        bottom: 15px; /* Very close to bottom */
        left: 10px;
        right: 10px;
        font-size: 10px; /* Even smaller text */
        padding: 5px 10px 5px 8px; /* Very compact */
        border-radius: 15px;
        
        /* Almost invisible background */
        background: rgba(248, 248, 248, 0.02);
        border-color: rgba(248, 248, 248, 0.08);
        opacity: 0.7;
    }
    
    #now-playing::before {
        left: 8px;
        width: 10px; /* Even smaller bars */
        height: 6px;
        background-size: 1px 100%, 1px 100%, 1px 100%, 1px 100%;
        background-position: 0 100%, 2px 100%, 4px 100%, 6px 100%;
        opacity: 0.5;
    }
    
    #now-playing .spotify-content {
        padding-left: 16px;
        gap: 2px;
    }
    
    /* Move kanji signature higher */
    .kanji-signature {
        bottom: 50px !important; /* Even higher */
        right: 12px !important;
        font-size: 0.8rem !important;
        opacity: 0.4 !important;
    }
    
    /* Make all text more compact */
    #now-playing a, 
    #now-playing span {
        font-weight: 600; /* Lighter weight */
        letter-spacing: -0.02em; /* Tighter spacing */
    }
}

/* Ultra compact for very small screens */
@media (max-width: 375px) {
    #now-playing {
        bottom: 12px;
        left: 8px;
        right: 8px;
        font-size: 9px;
        padding: 4px 8px 4px 6px;
        border-radius: 12px;
        opacity: 0.6; /* Very subtle */
    }
    
    #now-playing::before {
        left: 6px;
        width: 8px;
        height: 5px;
        background-size: 0.8px 100%, 0.8px 100%, 0.8px 100%, 0.8px 100%;
        background-position: 0 100%, 1.5px 100%, 3px 100%, 4.5px 100%;
        opacity: 0.4;
    }
    
    #now-playing .spotify-content {
        padding-left: 14px;
        gap: 1px;
    }
    
    .kanji-signature {
        bottom: 45px !important;
        right: 10px !important;
        font-size: 0.7rem !important;
        opacity: 0.3 !important;
    }
    
    /* Auto-hide after a few seconds on tiny screens */
    #now-playing {
        animation: fadeToBackground 6s ease-in-out forwards;
    }
    
    #now-playing:hover,
    #now-playing:active {
        animation: none;
        opacity: 1 !important;
    }
}

@keyframes fadeToBackground {
    0%, 60% { opacity: 0.6; }
    100% { opacity: 0.2; }
}
