@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #020617;
    /* より深いブルーブラック */
    --bg-sub: rgba(15, 23, 42, 0.7);
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --white: #ffffff;
    --primary: #3b82f6;
    --secondary: #1d4ed8;
    --border: rgba(59, 130, 246, 0.15);
    --bg-note: rgba(59, 130, 246, 0.15);
    --bg-feature: #030712;
    --grid-color: rgba(59, 130, 246, 0.08);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    margin: 0;
    overflow-x: hidden;
}

/* --- Navbar Styles --- */
.site-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10000;
    display: flex;
    justify-content: center;
}

.nav-container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--white);
    font-weight: 800;
    font-size: 1.2rem;
    transition: opacity 0.2s;
}

.nav-brand:hover {
    opacity: 0.8;
}

.brand-icon {
    color: var(--primary);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--white);
    background: rgba(59, 130, 246, 0.15);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        z-index: 10001;
        /* Keep button above overlay */
    }

    .hamburger {
        width: 24px;
        height: 18px;
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .hamburger span {
        display: block;
        height: 2px;
        width: 100%;
        background: var(--white);
        border-radius: 2px;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: left center;
    }

    /* Hamburger to X Animation */
    .menu-toggle.active .hamburger span:nth-child(1) {
        transform: rotate(45deg);
    }

    .menu-toggle.active .hamburger span:nth-child(2) {
        opacity: 0;
        transform: translateX(10px);
    }

    .menu-toggle.active .hamburger span:nth-child(3) {
        transform: rotate(-45deg);
    }

    /* Advanced Full-screen Menu Overlay */
    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        gap: 2rem;

        display: flex;
        opacity: 0;
        visibility: hidden;
        /* Circular reveal from top right */
        clip-path: circle(0px at calc(100% - 40px) 30px);
        transition: opacity 0.4s ease, clip-path 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
    }

    .nav-links.active {
        opacity: 1;
        visibility: visible;
        clip-path: circle(150vh at calc(100% - 40px) 30px);
    }

    /* Staggered entry animation for links */
    .nav-link {
        font-size: 1.5rem;
        text-align: center;
        width: 100%;
        padding: 1rem;
        opacity: 0;
        transform: translateY(20px);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        background: transparent;
        box-shadow: none;
    }

    .nav-links.active .nav-link {
        opacity: 1;
        transform: translateY(0);
    }

    .nav-links.active .nav-link:nth-child(1) {
        transition-delay: 0.1s;
    }

    .nav-links.active .nav-link:nth-child(2) {
        transition-delay: 0.2s;
    }

    .nav-links.active .nav-link:nth-child(3) {
        transition-delay: 0.3s;
    }
}

/* --- Loader (Initial) --- */
#loader-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Background Canvas & Grid --- */
.hero-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg);
    /* 青いグリッド状の模様 */
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: center center;
}

#hero-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(30, 58, 138, 0.3) 0%, transparent 70%);
}

/* --- Global Layout --- */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 80px 2rem 0;
}

header {
    height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;

    .meta-label {
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.5em;
        color: var(--primary);
        text-transform: uppercase;
        margin-bottom: 2rem;
        animation: fadeInDown 1s ease;
    }

    h1 {
        font-size: clamp(4rem, 12vw, 8rem);
        font-weight: 800;
        letter-spacing: -0.06em;
        line-height: 0.85;
        color: var(--white);
        margin-bottom: 2.5rem;
        background: linear-gradient(180deg, #fff 0%, #3b82f6 100%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: fadeInUp 1s ease;
    }

    .power-data {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text-light);
        background: var(--bg-note);
        border: 1px solid var(--border);
        padding: 0.5rem 1.5rem;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-top: 1rem;
        animation: fadeInUp 1.2s ease;

        .apex-tag {
            color: var(--white);
            font-weight: 800;
            letter-spacing: 0.1em;
        }
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    color: var(--primary);
    text-align: center;
    margin-bottom: 4rem;
    font-weight: 700;
}

.category-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;

    button {
        background: var(--bg-note);
        border: 1px solid var(--border);
        color: var(--text-light);
        padding: 0.5rem 1.5rem;
        border-radius: 9999px;
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover {
            color: var(--white);
            border-color: var(--primary);
            background: rgba(59, 130, 246, 0.2);
        }

        &.active {
            background: var(--primary);
            color: var(--white);
            border-color: var(--primary);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        }
    }
}

/* --- Bento Grid (Catalog) --- */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    padding-bottom: 10rem;

    .card {
        background: var(--bg-sub);
        backdrop-filter: blur(20px);
        border: 1px solid var(--border);
        border-radius: 2rem;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        grid-column: span 4;
        transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);

        &:hover {
            border-color: var(--primary);
            transform: translateY(-10px);
            box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
        }

        &.wide {
            grid-column: span 8;
        }

        &.full {
            grid-column: span 12;
        }

        @media (max-width: 1024px) {
            grid-column: span 6 !important;
        }

        @media (max-width: 768px) {
            grid-column: span 12 !important;
        }

        .card-preview {
            height: 200px;
            background: var(--bg-feature);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1.5rem;
            position: relative;
            overflow: hidden;
            /* Prevent bleeding */
            max-width: 100%;
            border-bottom: 1px solid var(--border);
        }

        .card-preview>* {
            box-sizing: border-box;
            /* Ensure padding doesn't cause overflow */
            max-width: 100%;
        }

        .card-body {
            padding: 2.5rem;
            flex-grow: 1;

            .tag {
                font-size: 0.65rem;
                font-weight: 800;
                text-transform: uppercase;
                letter-spacing: 0.1em;
                color: var(--primary);
                background: var(--bg-note);
                padding: 0.25rem 0.75rem;
                border-radius: 4px;
                margin-bottom: 1.25rem;
                display: inline-block;
            }

            h3 {
                font-size: 1.5rem;
                font-weight: 600;
                color: var(--white);
                margin-bottom: 1rem;
            }

            .explanation {
                font-size: 0.875rem;
                color: var(--text-light);
                margin-bottom: 2rem;
            }

            .prompt-area {
                background: rgba(0, 0, 0, 0.4);
                border-radius: 1rem;
                padding: 1.25rem;
                border: 1px solid rgba(59, 130, 246, 0.1);

                .prompt-header {
                    display: flex;
                    justify-content: space-between;
                    font-size: 0.7rem;
                    font-weight: 700;
                    color: var(--primary);
                    margin-bottom: 0.75rem;
                    text-transform: uppercase;
                }

                code {
                    font-size: 0.8rem;
                    color: var(--text);
                    line-height: 1.6;
                    display: block;
                    opacity: 0.9;
                }

                .copy-trigger {
                    color: var(--primary);
                    cursor: pointer;

                    &:hover {
                        text-decoration: underline;
                    }
                }
            }
        }
    }
}

/* --- Custom Component Visuals --- */
.burger-icon {
    width: 30px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    span {
        height: 2px;
        background: var(--primary);
        border-radius: 2px;
    }
}

.mega-preview {
    width: 80%;
    height: 60%;
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 10px;

    .m-box {
        background: var(--border);
        border-radius: 4px;
    }
}

.skeleton-preview {
    width: 80%;

    .line {
        height: 10px;
        background: var(--border);
        margin-bottom: 8px;
        border-radius: 4px;
        animation: pulse 1.5s infinite;
    }

    @keyframes pulse {
        0% {
            opacity: 0.4;
        }

        50% {
            opacity: 0.1;
        }

        100% {
            opacity: 0.4;
        }
    }
}

.grain-preview {
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
    opacity: 0.05;
}

/* --- Footer & Copyright Section --- */
footer {
    border-top: 1px solid var(--border);
    padding: 8rem 0 4rem;
    background: rgba(10, 12, 16, 0.8);

    .footer-grid {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 4rem;
        margin-bottom: 6rem;

        .footer-info {
            grid-column: span 6;

            h2 {
                font-size: 1.5rem;
                font-weight: 800;
                color: var(--primary);
                margin-bottom: 1.5rem;
            }

            p {
                color: var(--text-light);
                font-size: 0.875rem;
                max-width: 400px;
            }
        }

        .footer-links {
            grid-column: span 3;

            h4 {
                color: var(--white);
                font-size: 0.875rem;
                font-weight: 700;
                margin-bottom: 2rem;
            }

            ul {
                list-style: none;
                padding: 0;

                li {
                    margin-bottom: 1rem;

                    a {
                        color: var(--text-light);
                        font-size: 0.875rem;

                        &:hover {
                            color: var(--primary);
                        }
                    }
                }
            }
        }
    }

    .copyright-area {
        padding-top: 3rem;
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: var(--text-light);
        font-size: 0.75rem;

        @media (max-width: 768px) {
            flex-direction: column;
            gap: 1rem;
            text-align: center;
        }
    }
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-weight: 700;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
    transform: translateY(200%);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    &.show {
        transform: translateY(0);
    }
}