/* 
 * amekusa Portfolio Style
 * ---------------------------------------
 * 1. Global Styles (:root, resets, etc.)
 * 2. Layout Components (sticky-nav, footer)
 * 3. Home Page Styles (hero, projects, archive)
 * 4. Application Detail Page Styles
 * 5. Utility Classes
 * 6. Responsive Queries
 * ---------------------------------------
 */

:root {
    --bg-color: #fdfcf8;
    --text-color: #2d3436;
    --accent-green: #4a6741;
    --accent-blue: #0984e3;
    --card-bg: rgba(255, 255, 255, 0.8);
    --border-color: #e0e0e0;
    --font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1c1a;
        --text-color: #e0e0e0;
        --card-bg: rgba(45, 52, 54, 0.7);
        --border-color: #3d443d;
    }
}

/* モーション削減対応 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* フォーカスインジケーター */
a:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.6;
    scroll-behavior: smooth;
}

a { color: var(--accent-blue); text-decoration: none; transition: opacity 0.3s; }
a:hover { opacity: 0.7; }

.container { max-width: 900px; margin: 0 auto; padding: 2rem; position: relative; }

/* --- Language Switcher --- */
.language-link {
    position: absolute;
    top: 1rem;
    right: 2rem;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid transparent;
}
.language-link:hover { border-bottom-color: var(--accent-blue); }

footer { text-align: center; opacity: 0.6; }

/* --- Sticky Navigation --- */
.sticky-nav {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    padding: 1rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sticky-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.sticky-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.sticky-nav a:hover {
    color: var(--accent-green);
}

/* --- Index Page (Home) --- */
.home-page {
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(74, 103, 65, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(9, 132, 227, 0.05) 0px, transparent 50%);
}

#rain-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

.subtitle-note {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    color: rgba(0,0,0,0.75);
}

.project-card__image,
.current-project-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    aspect-ratio: 16 / 9;
}

.plan-project-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    aspect-ratio: 16 / 9;
    opacity: 1;
}


.home-page header {
    height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    padding: 2rem;
    backdrop-filter: blur(10px);
    text-align: center;
}

.hero-gif {
    width: 80px;
    margin-bottom: 2rem;
    mask-image: radial-gradient(circle, black 40%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: radial-gradient(circle, black 40%, rgba(0,0,0,0) 100%);
}

.home-page header h1 { font-size: 3rem; letter-spacing: 0.2em; font-weight: 300; }
.subtitle { color: var(--accent-green); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3em; margin-top: 1rem; }

.home-page section { padding: 5rem 0; border-bottom: 1px solid var(--border-color); }
.home-page h2 { font-size: 1.8rem; margin-bottom: 3rem; position: relative; display: inline-block; font-weight: 400; }
.home-page h2::after { content: ''; position: absolute; bottom: -10px; left: 0; width: 40px; height: 1px; background: var(--accent-green); }

/* --- About Section --- */
.about-content { max-width: 700px; margin: 0 auto; text-align: center; }
.about-text { 
    font-size: 0.8rem; line-height: 2; color: var(--text-color); opacity: 0.9; 
    word-break: keep-all; overflow-wrap: break-word;
}

.section-subtitle { font-size: 1rem; opacity: 0.6; font-weight: 400; margin: 3rem 0 1rem; }
.section-description { font-size: 1rem; opacity: 0.6; margin-bottom: 1rem; }

.project-grid, .current-project-grid, .plan-project-grid { 
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1.5rem; margin-bottom: 3rem; 
}
.project-card, .current-project-card, .plan-project-card { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 1.5rem; 
    backdrop-filter: blur(10px); 
    display: flex; 
    flex-direction: column; 
    font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); 
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 480px; /* 1カラムになった時に広がりすぎないよう制限 */
    justify-self: center; /* グリッド内で中央に配置 */
}
.project-card:hover, .current-project-card:hover, .plan-project-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); 
}

.archive-project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 120px)); gap: 1rem; margin-top: 2rem; }

.archive-project-card { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    padding: 0.8rem; 
    display: flex; 
    flex-direction: column; 
    font-size: 0.75rem; 
    transition: opacity 0.3s, transform 0.3s ease, box-shadow 0.3s ease; 
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); 
}
.archive-project-card:hover { 
    opacity: 1; 
    transform: translateY(-3px); 
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15); 
}
.archive-project-card h3 { font-size: 0.9rem; font-weight: 400; }
.archive-project-card img { 
    width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; 
    margin: 0.5rem 0; filter: grayscale(60%); transition: filter 0.3s; 
}
.archive-project-card:hover img { filter: grayscale(0%); }

.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; margin: 1.5rem 0; background: #000; }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* --- Mobile Video Frame --- */
.mini-video-container {
    width: 130px; /* 端末の横幅 */
    max-width: calc(100% - 40px);
    margin: 3rem auto;
    background: #1a1a1a; /* 端末のボディカラー */
    border: 12px solid #1a1a1a;
    border-top-width: 35px; /* 上部ベゼル（ノッチ用） */
    border-bottom-width: 35px; /* 下部ベゼル */
    border-radius: 45px; /* スマホらしい大きな角丸 */
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mini-video-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* ダークモードでの視認性向上 */
@media (prefers-color-scheme: dark) {
    .mini-video-container {
        border-color: #2a2a2a; /* 背景より少し明るい色に変更 */
        background: #2a2a2a;
        box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
    }
    .mini-video-container::before,
    .mini-video-container::after {
        background: #444; /* パーツの視認性も調整 */
    }
}

/* 上部のノッチ/スピーカー */
.mini-video-container::before {
    content: '';
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 45px;
    height: 5px;
    background: #333;
    border-radius: 10px;
}

/* 下部のジェスチャーバー */
.mini-video-container::after {
    content: '';
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: #333;
    border-radius: 10px;
}

.mini-video-container iframe {
    display: block;
    width: 100%;
    aspect-ratio: 9 / 16; /* 画面の比率 */
    border-radius: 6px; /* 液晶画面の少しの角丸 */
    background: #000;
    border: none;
}

/* --- Electronic Circuit Board Video Frame --- */
.Electronic-circuit-board-video-container {
    width: 360px;
    max-width: calc(100% - 40px);
    margin: 3rem auto;
    background-color: #1b4d2e; /* 基板の緑色 */
    background-image: 
        radial-gradient(circle at 12px 12px, #b5b5b5 6px, transparent 6px), /* 四隅の取付穴 */
        radial-gradient(circle at calc(100% - 12px) 12px, #b5b5b5 6px, transparent 6px),
        radial-gradient(circle at 12px calc(100% - 12px), #b5b5b5 6px, transparent 6px),
        radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), #b5b5b5 6px, transparent 6px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px), /* わずかなグリッド線 */
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 20px 20px, 20px 20px;
    border: 4px solid #143a22;
    border-radius: 8px;
    padding: 40px 15px 25px;
    position: relative;
    box-shadow: 0 10px 0 #143a22, 0 20px 30px rgba(0,0,0,0.4);
}

.Electronic-circuit-board-video-container::before {
    content: "PCB-ESP32-GAME-V1.0  ● GND  ● VCC  ● DATA";
    position: absolute;
    top: 12px;
    left: 25px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5); /* シルク印刷風の白文字 */
    letter-spacing: 1px;
}

.Electronic-circuit-board-video-container::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 8px;
    background: repeating-linear-gradient(90deg, #d4af37, #d4af37 6px, transparent 6px, transparent 12px); /* 金メッキ端子 */
}

.Electronic-circuit-board-video-container iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 4px solid #111;
    border-radius: 2px;
    background-color: #000;
    display: block;
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.photo-item { aspect-ratio: 1/1; background: #eee; border-radius: 8px; overflow: hidden; position: relative; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s ease; }
.photo-item:hover img { transform: scale(1.05); }

.profile-content { display: flex; align-items: flex-start; gap: 2rem; }
.linkedin-link { display: inline-block; background: #0077b5; color: white; padding: 0.8rem 1.5rem; border-radius: 4px; text-decoration: none; margin-top: 1rem; }

.links-list { list-style: none; }
.links-list li { margin-bottom: 1rem; padding: 1.2rem; background: var(--card-bg); border-radius: 8px; border: 1px solid var(--border-color); }

.home-page footer { padding: 5rem 0; font-size: 0.85rem; }

.footer-note { margin-top: 0.5rem; }

/* --- Application Detail Page --- */
.app-page {
    line-height: 1.8;
    background-image: radial-gradient(at 0% 0%, rgba(74, 103, 65, 0.03) 0px, transparent 50%);
}

.app-page .container { max-width: 800px; padding: 4rem 2rem; }

nav { margin-bottom: 4rem; }
nav a { color: var(--accent-green); font-size: 0.9rem; letter-spacing: 0.1em; }

.app-page header { margin-bottom: 4rem; }
.app-page header h1 { font-size: 2.5rem; font-weight: 300; margin-bottom: 1rem; }

.tag { display: inline-block; padding: 0.2rem 0.8rem; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 20px; font-size: 0.8rem; margin-right: 0.5rem; color: var(--accent-green); }

/* --- Utility Classes --- */
.u-margin-b-1 { margin-bottom: 1rem; }
.u-opacity-8 { opacity: 0.8; }
.u-text-center { text-align: center; }
.img-responsive-50 { width: 50%; height: auto; border-radius: 8px; }
.img-responsive-75 { width: 75%; height: auto; border-radius: 8px; }

@media (max-width: 600px) {
    .img-responsive-50, .img-responsive-75 { width: 100%; }
}

.hero-visual { 
    width: 100%; aspect-ratio: 16/9; background: var(--card-bg); 
    border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 3rem; 
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.hero-visual img { width: 100%; height: 100%; object-fit: cover; }

.app-page section { margin-bottom: 4rem; }
.app-page h2 { font-size: 1.5rem; margin-bottom: 1.5rem; font-weight: 400; color: var(--accent-green); border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }

.tech-stack { display: flex; flex-wrap: wrap; gap: 1rem; list-style: none; }
.tech-stack li { background: var(--card-bg); padding: 0.5rem 1rem; border-radius: 4px; border: 1px solid var(--border-color); font-size: 0.9rem; }

.code-block { background: #2d3436; color: #f8f8f2; padding: 1.5rem; border-radius: 8px; overflow-x: auto; font-family: monospace; font-size: 0.9rem; margin: 1.5rem 0; }

.link-button { 
    display: inline-block; background: var(--accent-green); color: white; 
    padding: 1rem 2rem; border-radius: 6px; text-decoration: none; 
    transition: opacity 0.3s; margin-top: 1rem;
}
.link-button:hover { opacity: 0.8; }

.app-page footer { margin-top: 8rem; font-size: 0.8rem; }

/* --- Tables & Downloads --- */
table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; background: var(--card-bg); border-radius: 8px; overflow: hidden; }
th, td { padding: 1rem; border: 1px solid var(--border-color); text-align: left; }
th { background: rgba(74, 103, 65, 0.1); color: var(--accent-green); font-size: 0.9rem; }

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--accent-green);
    color: var(--accent-green) !important;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .home-page header h1 { font-size: 2rem; }
    .app-page header h1 { font-size: 1.8rem; }
    .profile-content { flex-direction: column; }
    .project-grid, .current-project-grid, .plan-project-grid { grid-template-columns: 1fr; }
    .sticky-nav ul { flex-wrap: wrap; gap: 1rem; }
}

/* アニメーション最適化 */
.hobby-card {
    will-change: transform;
}

/* --- Project Modal Styles --- */
.project-modal-overlay {
    display: flex;
    visibility: hidden;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.6s ease, visibility 0.6s;
}
.project-modal-overlay.active {
    visibility: visible;
    opacity: 1;
}
.project-modal-card {
    background: var(--bg-color, #fff);
    padding: 2.5rem;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    position: relative;
    transform: translateY(30px) scale(0.9);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.project-modal-overlay.active .project-modal-card {
    transform: translateY(0) scale(1);
}
.modal-close-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    background: none; border: none;
    font-size: 1.5rem; cursor: pointer;
    color: var(--color-text-secondary, #666);
}
.project-modal-card h3 { margin-top: 0; color: var(--accent-green); }
.project-modal-card img { width: 100%; height: auto; border-radius: 8px; margin: 1rem 0; }
.modal-item-separator { border-top: 1px solid var(--border-color); margin: 2rem 0; }
.modal-item-wrapper:first-child .modal-item-separator { display: none; }
.image-container {
    position: relative;
    max-width: 1080px;
    margin: 2rem auto;
    padding-bottom: 2rem; /* 下側の重なり部分のための余白 */
}

.image-back {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.image-front {
    width: 40%; /* 前面画像のサイズを少し調整 */
    height: auto;
    position: absolute;
    bottom: -10px; /* 少しはみ出させて立体感を出す */
    right: -10px;
    z-index: 1;
    border: 3px solid #fff; /* 白枠で強調 */
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: zoom-in;
}

.image-front:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    z-index: 10;
}

.image-front img {
    width: 100%;
    display: block;
}

.text-content {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    position: absolute;
    bottom: 10px;
    left: 10px;
    pointer-events: none;
}