/* V5 Cozy Lab Design - Complete (With Maron Updates) */

:root {
    /* Palette: Warm & Friendly (Day) */
    --c-bg: #FFFBF0;
    --c-surface: #FFFFFF;
    --c-text: #2D3436;
    --c-text-light: #636E72;
    --c-primary: #FF7675;
    --c-primary-dark: #D63031;
    --c-accent: #FFEAA7;
    --c-secondary: #55EFC4;

    /* Tag Colors */
    --c-tag-tool: #74B9FF;
    --c-tag-app: #A29BFE;
    --c-tag-article: #55EFC4;
    --c-tag-education: #FDCB6E;

    /* Spacing & Radius */
    --sp-sm: 1rem;
    --sp-md: 2rem;
    --sp-lg: 4rem;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-btn: 50px;

    /* Font */
    --font-base: 'M PLUS Rounded 1c', sans-serif;
    --font-en: 'Outfit', sans-serif;
    
    /* Header Height */
    --header-height: 70px;
}

/* Dark Mode Variables */
body.dark-mode {
    --c-bg: #2D3436;
    --c-surface: #353B48;
    --c-text: #DFE6E9;
    --c-text-light: #B2BEC3;
    --c-primary: #FF7675;
    --c-accent: #FDCB6E;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-base);
    background-color: var(--c-bg);
    color: var(--c-text);
    line-height: 1.8;
    background-image: radial-gradient(#dfe6e9 1px, transparent 1px);
    background-size: 24px 24px;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-image: radial-gradient(#636e72 1px, transparent 1px);
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 var(--sp-sm);
}

/* Typography */
h1, h2, h3 {
    font-weight: 800;
    line-height: 1.3;
}

.section-title {
    font-family: var(--font-en);
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: var(--sp-sm);
    color: var(--c-primary);
}

.section-desc {
    text-align: center;
    margin-bottom: var(--sp-lg);
    color: var(--c-text-light);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    border-radius: var(--radius-btn);
    font-weight: 700;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.btn:active {
    transform: translateY(2px) !important;
    box-shadow: none !important;
}

.btn-primary {
    background-color: var(--c-primary);
    color: white;
    box-shadow: 0 4px 0 var(--c-primary-dark);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--c-primary-dark);
}

.btn-secondary {
    background-color: var(--c-surface);
    color: var(--c-text);
    border: 2px solid var(--c-text);
    box-shadow: 0 4px 0 var(--c-text);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--c-text);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: rgba(255, 251, 240, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s;
}

body.dark-mode .header {
    background: rgba(45, 52, 54, 0.9);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 1.4rem;
}

.logo-icon {
    font-size: 1.6rem;
}

.nav-list {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    font-weight: 700;
    color: var(--c-text-light);
    transition: all 0.2s;
    position: relative;
}

.nav-link:hover {
    color: var(--c-primary);
}

/* ★ Active Link Style (Scroll Spy) */
.nav-link.active {
    color: var(--c-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--c-primary);
    border-radius: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Theme Toggle */
.theme-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s;
    padding: 0.5rem;
    border-radius: 50%;
}

.theme-btn:hover {
    transform: rotate(15deg) scale(1.1);
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .theme-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    background: none;
    border: none;
    cursor: pointer;
}

.bar {
    width: 100%;
    height: 3px;
    background: var(--c-text);
    border-radius: 3px;
    transition: 0.3s;
}

/* Mobile Nav */
.mobile-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    background: var(--c-bg);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-nav-list {
    list-style: none;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.mobile-nav-link {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Hero Section */
.hero {
    padding: 140px 0 80px;
    min-height: 80vh;
    display: flex;
    align-items: center;
    flex-direction: column; /* Changed for News Ticker placement */
    justify-content: center;
}

.hero-container {
    display: flex;
    align-items: center;
    gap: 3rem;
    width: 100%; /* Ensure container takes width */
}

.hero-content {
    flex: 1;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.highlight {
    color: var(--c-primary);
    font-family: var(--font-en);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--c-text-light);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
}

.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* CSS Art: Cozy Lab (Interactive) */
.cozy-lab-art {
    width: 300px;
    height: 300px;
    background: var(--c-surface);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s;
}

.cozy-lab-art:active {
    transform: scale(0.95);
}

.art-flask {
    width: 120px;
    height: 160px;
    background: var(--c-accent);
    border: 4px solid var(--c-text);
    border-radius: 40px 40px 60px 60px;
    transform: rotate(-10deg);
    transition: background-color 0.3s;
}

.art-bubble {
    position: absolute;
    background: var(--c-surface);
    border: 3px solid var(--c-text);
    border-radius: 50%;
}

.b1 {
    width: 30px;
    height: 30px;
    top: 20%;
    left: 30%;
    animation: float 3s infinite;
}

.b2 {
    width: 20px;
    height: 20px;
    top: 10%;
    right: 30%;
    animation: float 4s infinite 1s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ★ News Ticker (Optional if you added HTML) */
.news-ticker {
    background: var(--c-surface);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    max-width: 600px;
    margin: -2rem auto 3rem; /* Adjust positioning */
    border: 1px solid rgba(0,0,0,0.05);
    z-index: 2;
    position: relative;
}

/* Projects Section */
.section {
    padding: var(--sp-lg) 0;
}

/* Search & Filter Controls */
.projects-controls {
    max-width: 600px;
    margin: 0 auto 3rem;
    text-align: center;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-btn);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    background: var(--c-surface);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    font-family: var(--font-base);
    color: var(--c-text);
    outline: none;
    transition: 0.3s;
}

.search-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.filter-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1.5rem;
    border: none;
    background: var(--c-surface);
    border-radius: 20px;
    font-weight: 700;
    color: var(--c-text-light);
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.filter-btn.active, .filter-btn:hover {
    background: var(--c-primary);
    color: white;
    transform: translateY(-2px);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--c-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 2px solid transparent;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--c-primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.card-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-tag {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 10px;
    color: white;
    font-weight: 700;
}

/* NEW Badge */
.badge-new {
    background: var(--c-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 118, 117, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(255, 118, 117, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 118, 117, 0); }
}

.tag-tool { background: var(--c-tag-tool); }
.tag-app { background: var(--c-tag-app); }
.tag-article { background: var(--c-tag-article); }
.tag-education { background: var(--c-tag-education); color: var(--c-text); }

.card-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.card-text {
    font-size: 0.95rem;
    color: var(--c-text-light);
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.card-link {
    color: var(--c-primary);
    font-weight: 700;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}

.card-link:hover {
    border-bottom-color: var(--c-primary);
}

/* No Results Message */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--c-text-light);
    font-weight: 700;
    width: 100%;
    grid-column: 1 / -1;
}

/* About Section */
.about-card {
    background: var(--c-surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    max-width: 800px;
    margin: 0 auto;
}

.about-content p {
    margin-bottom: 1.5rem;
}

/* Links Section */
.links-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.link-card {
    background: var(--c-surface);
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: 0.3s;
}

.link-card:hover {
    transform: translateY(-5px);
    color: var(--c-primary);
}

.link-icon {
    font-size: 2.5rem;
}

.link-name {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 0;
    color: var(--c-text-light);
    font-size: 0.9rem;
}

/* ★ Scroll to Top Button (Maron Ver.) */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--c-surface);
    color: var(--c-text);
    border: 2px solid var(--c-primary);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-5px);
    background: var(--c-bg);
    box-shadow: 0 6px 15px rgba(255, 118, 117, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .nav {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    .hero-container {
        flex-direction: column-reverse;
        text-align: center;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-actions {
        justify-content: center;
    }

    .cozy-lab-art {
        width: 240px;
        height: 240px;
    }
}

/* --- Phase 2 Features --- */

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--c-bg);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s, visibility 0.5s;
}

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

.loader-content {
    text-align: center;
}

.loader-flask {
    width: 80px;
    height: 100px;
    border: 4px solid var(--c-text);
    border-radius: 0 0 40px 40px;
    margin: 0 auto 1rem;
    position: relative;
    overflow: hidden;
}

.loader-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: var(--c-primary);
    animation: wave 2s infinite linear;
}

.loader-text {
    font-family: var(--font-en);
    font-weight: 700;
    color: var(--c-text-light);
    animation: blink 1.5s infinite;
}

@keyframes wave {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(2deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--c-surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: translateY(20px);
    transition: 0.3s;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--c-text-light);
}

.modal-tag {
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    background: var(--c-text-light);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--c-primary);
}

.modal-desc {
    color: var(--c-text);
    margin-bottom: 2rem;
    line-height: 1.8;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* =========================================
   Mobile Optimization (スマホ最適化・完全版)
   ========================================= */
@media (max-width: 768px) {
    /* 1. ナビゲーションの切り替え */
    .nav {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    /* 2. ヒーローセクションのレイアウト調整 */
    .hero {
        padding: 100px 0 60px; /* 余白をPC版(140px)より詰める */
        min-height: auto; /* 無理に画面いっぱいに広げない */
    }

    .hero-container {
        flex-direction: column-reverse; /* イラストを上に、文字を下に */
        text-align: center;
        gap: 2rem;
    }

    /* 3. 文字サイズの最適化 */
    .hero-title {
        font-size: 2rem; /* 少し小さくして圧迫感を減らす */
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 1rem;
        text-align: justify; /* 長文を読みやすく */
        text-align-last: center;
    }

    .section-title {
        font-size: 2rem; /* セクションタイトルも少し控えめに */
    }

    .hero-actions {
        justify-content: center;
        flex-direction: column; /* ボタンを縦並びにして押しやすく */
        gap: 1rem;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%; /* ボタンを横幅いっぱいに */
        text-align: center;
    }

    /* 4. イラストのサイズ調整 */
    .cozy-lab-art {
        width: 220px;
        height: 220px;
        margin-bottom: 1rem;
    }

    .art-flask {
        transform: scale(0.8) rotate(-10deg); /* 中身も少し小さく */
    }

    /* 5. Newsティッカーのスマホ対応 */
    .news-ticker {
        margin: -1rem auto 2rem; /* 位置調整 */
        padding: 0.8rem 1rem;
        flex-direction: column; /* NEWバッジとテキストを縦並びに */
        align-items: flex-start;
        gap: 0.5rem;
        border-radius: 16px; /* 丸みを少し減らす */
    }

    .news-ticker span {
        font-size: 0.7rem;
    }

    .news-ticker a {
        font-size: 0.9rem;
        white-space: normal; /* 折り返して全文表示させる */
        text-align: left;
    }
    
    /* 6. カードグリッドの調整 */
    .projects-grid {
        grid-template-columns: 1fr; /* 完全な1列表示に */
        gap: 1.5rem;
    }
    
    /* 7. モーダルの調整 */
    .modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
    }
}

/* =========================================
   Animation Definitions (指摘対応)
   ========================================= */
/* Fade In Up Animation */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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