/* ==========================================================================
   Retro 80s GUI Portfolio - Core Design System & Styles
   ========================================================================== */

/* 1. 変数の定義 */
:root {
    --bg-canvas: #F5F5F0;        /* 温かみのある紙の白 */
    --bg-window: #EAEAE0;        /* システムのベージュグレー */
    --color-text: #1C1A17;       /* 濃いチャコールインク */
    --color-muted: #7A7870;      /* 補助的テキスト */
    --color-accent: #2E8B57;     /* クラシックターミナルグリーン */
    --color-accent-hover: #226b43;
    --border-width: 2px;
    
    /* タイポグラフィ */
    --font-display: 'Satoshi', sans-serif;
    --font-body: 'Satoshi', sans-serif;
    --font-mono: 'JetBrains Mono', 'Share Tech Mono', 'Courier New', monospace;
}

/* ダークモード用のテーマ（レトロ反転カラー） */
body.dark-mode {
    --bg-canvas: #1C1A17;        /* デスクトップ背景はチャコールインク */
    --bg-window: #2D2A26;        /* ウィンドウ背景は暗いベージュグレー */
    --color-text: #F5F5F0;       /* テキストは温かみのある紙の白 */
    --color-muted: #9A9890;      /* 補助的テキスト */
    --color-accent: #4ADE80;     /* ターミナルグリーン（明るめ） */
    --color-accent-hover: #3cae68;
}

/* 2. 基本リセットと画面構造 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-canvas);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    overflow: hidden; /* デスクトップ環境を再現するためスクロール禁止（モバイルで解除） */
    height: 100vh;
    width: 100vw;
}

/* モノスペース補助クラス */
.system-mono {
    font-family: var(--font-mono);
}

/* 3. CRTスクリーンシミュレーション */
.crt-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.08) 50%),
                radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.15) 100%);
    background-size: 100% 4px, 100% 100%;
    z-index: 9999;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* 走査線のオン/オフ切り替えクラス */
.no-scanlines {
    background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.08) 100%) !important;
}

/* CRTモニターベゼル（額縁）効果（画面四隅をわずかに丸める） */
.crt-bezel::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
    z-index: 10000;
    pointer-events: none;
}

/* 4. OS コンテナ & 上部メニューバー */
.os-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.menu-bar {
    height: 32px;
    background-color: var(--bg-window);
    border-bottom: var(--border-width) solid var(--color-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    user-select: none;
    z-index: 999;
}

.menu-left, .menu-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-brand {
    font-weight: bold;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 6px;
}

.menu-nav {
    display: flex;
    gap: 16px;
}

.menu-item {
    position: relative;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 14px;
}

.menu-trigger {
    padding: 2px 8px;
    display: block;
}

.menu-trigger:hover, .menu-item.active .menu-trigger {
    background-color: var(--color-text);
    color: var(--bg-canvas);
}

/* ドロップダウンメニュー */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-window);
    border: var(--border-width) solid var(--color-text);
    box-shadow: 3px 3px 0px 0px var(--color-text);
    min-width: 160px;
    z-index: 1000;
}

.menu-item.active .dropdown {
    display: block;
}

.dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
}

.dropdown button:hover {
    background-color: var(--color-text);
    color: var(--bg-canvas);
}

/* 5. デスクトップ & アイコン */
.desktop {
    flex-grow: 1;
    position: relative;
    padding: 20px;
    background-image: 
        radial-gradient(var(--color-muted) 1px, transparent 1px),
        radial-gradient(var(--color-muted) 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    opacity: 0.85;
}

.desktop-icons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    z-index: 1;
}

.shortcut-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    user-select: none;
    background: none;
    border: none;
    outline: none;
}

.icon-visual {
    font-size: 32px;
    margin-bottom: 4px;
    transition: transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-label {
    font-family: var(--font-mono);
    font-size: 12px;
    background-color: var(--bg-canvas);
    border: 1px solid transparent;
    padding: 1px 4px;
    word-break: break-all;
    color: var(--color-text);
}

.shortcut-icon:hover .icon-visual, .shortcut-icon:focus .icon-visual {
    filter: invert(100%);
}

.shortcut-icon:focus .icon-label, .shortcut-icon:hover .icon-label {
    background-color: var(--color-text);
    color: var(--bg-canvas);
    border-color: var(--color-text);
    outline: none;
}

/* 6. GUI ウィンドウ */
.window {
    position: absolute;
    background-color: var(--bg-window);
    border: var(--border-width) solid var(--color-text);
    box-shadow: 6px 6px 0px 0px var(--color-text);
    display: flex;
    flex-direction: column;
    min-height: 150px;
    max-height: 80vh;
    transition: box-shadow 0.1s ease, transform 0.1s ease;
    overflow: hidden;
}

/* アクティブウィンドウの強調 */
.active-window {
    box-shadow: 8px 8px 0px 0px var(--color-text);
    z-index: 100 !important;
}

/* ウィンドウ最大化状態 */
.window-maximized {
    box-shadow: none !important;
    transform: none !important;
}

/* ウィンドウヘッダー */
.window-header {
    height: 30px;
    background-color: var(--bg-window);
    border-bottom: var(--border-width) solid var(--color-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    cursor: move;
    user-select: none;
    position: relative;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--color-text) 2px,
        var(--color-text) 3px
    );
    background-size: 100% 6px;
}

/* ウィンドウタイトル */
.window-title {
    font-weight: bold;
    font-size: 13px;
    padding: 2px 12px;
    background-color: var(--bg-window);
    border: var(--border-width) solid var(--color-text);
    z-index: 2;
}

/* ウィンドウ閉じるボタン */
.window-control-close {
    width: 14px;
    height: 14px;
    border: var(--border-width) solid var(--color-text);
    background-color: var(--bg-canvas);
    cursor: pointer;
    z-index: 2;
    position: relative;
}

/* クリック判定領域（ヒットエリア）を周囲に拡張 */
.window-control-close::after, .window-control-zoom::after {
    content: "";
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    cursor: pointer;
}

.window-control-close:hover {
    background-color: var(--color-text);
}

.window-control-zoom {
    width: 14px;
    height: 14px;
    border: var(--border-width) solid var(--color-text);
    background-color: var(--bg-canvas);
    cursor: pointer;
    z-index: 2;
    position: relative;
}

.window-control-zoom::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid var(--color-text);
}

.window-control-zoom:hover {
    background-color: var(--color-text);
}

.window-control-zoom:hover::before {
    border-color: var(--bg-canvas);
}

/* ウィンドウボディ */
.window-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

/* ウィンドウステータスバー */
.window-status {
    height: 24px;
    border-top: var(--border-width) solid var(--color-text);
    background-color: var(--bg-window);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-size: 11px;
    color: var(--color-muted);
    user-select: none;
    position: relative;
}

/* 右下リサイズハンドル */
.window-resize-handle {
    width: 14px;
    height: 14px;
    position: absolute;
    bottom: 0;
    right: 0;
    cursor: se-resize;
    background-image: linear-gradient(135deg, 
        transparent 30%, 
        var(--color-text) 30%, var(--color-text) 40%, 
        transparent 40%, transparent 60%, 
        var(--color-text) 60%, var(--color-text) 70%, 
        transparent 70%
    );
    background-size: 6px 6px;
    opacity: 0.6;
}

.window-resize-handle:hover {
    opacity: 1.0;
}

/* 7. コンポーネント & セクションのスタイリング */

/* レトロボタン */
.retro-btn {
    display: inline-block;
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    background-color: var(--bg-canvas);
    border: var(--border-width) solid var(--color-text);
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 3px 3px 0px 0px var(--color-text);
    outline: none;
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.retro-btn:hover {
    background-color: var(--color-text);
    color: var(--bg-canvas);
}

.retro-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0px 0px var(--color-text);
}

.primary-btn {
    background-color: var(--color-accent);
    color: var(--bg-canvas);
}
.primary-btn:hover {
    background-color: var(--color-accent-hover);
    color: var(--bg-canvas);
}

/* 見出しとテキスト */
.display-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    border-bottom: var(--border-width) solid var(--color-text);
    padding-bottom: 6px;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.accent-text {
    color: var(--color-accent);
}

.body-text {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    margin-bottom: 16px;
    max-width: 65ch;
}

.badge {
    display: inline-block;
    font-size: 11px;
    color: var(--color-accent);
    margin-bottom: 8px;
    font-weight: bold;
}

/* --- HERO SECTION --- */
.hero-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-cta-wrapper {
    margin-top: 10px;
    display: flex;
    gap: 12px;
}

/* --- PROFILE SECTION (ABOUT) --- */
.profile-layout {
    display: flex;
    gap: 20px;
}

.profile-avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.avatar-svg {
    border: var(--border-width) solid var(--color-text);
    box-shadow: 3px 3px 0px 0px var(--color-text);
    image-rendering: pixelated;
}

.user-tag {
    font-size: 11px;
    font-weight: bold;
}

.profile-details {
    flex-grow: 1;
}

.status-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 12px;
}

.status-table td {
    padding: 4px 0;
}

.status-table td:first-child {
    font-weight: bold;
    width: 90px;
    color: var(--color-muted);
}

.profile-bio {
    font-size: 13px;
}

/* --- PROJECTS SECTION --- */
.projects-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.project-card {
    background-color: var(--bg-canvas);
    border: var(--border-width) solid var(--color-text);
    box-shadow: 3px 3px 0px 0px var(--color-text);
    padding: 14px;
    transition: transform 0.1s ease;
}

.project-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px 0px var(--color-text);
}

.project-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-muted);
    margin-bottom: 6px;
}

.project-title {
    font-size: 16px;
    margin-bottom: 8px;
}

.project-desc {
    font-size: 13px;
    margin-bottom: 12px;
}

.project-link {
    font-size: 12px;
    font-weight: bold;
    color: var(--color-accent);
    text-decoration: none;
}

.project-link:hover {
    text-decoration: underline;
}

/* --- TERMINAL (CONTACT) --- */
.terminal-body {
    background-color: #1C1A17;
    color: var(--color-accent);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 320px;
}

.terminal-body .body-text, .terminal-body .section-title {
    color: var(--color-accent);
}

.terminal-output {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 10px;
}

.terminal-line {
    margin-bottom: 4px;
    word-break: break-all;
}

.text-muted {
    color: var(--color-muted);
}

.terminal-prompt {
    color: var(--color-accent);
    font-weight: bold;
}

.terminal-input-area {
    display: flex;
    align-items: center;
    border-top: 1px dashed var(--color-accent);
    padding-top: 8px;
}

.terminal-input {
    flex-grow: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-accent);
    font-family: var(--font-mono);
    font-size: 12px;
    margin-left: 8px;
}

/* 8. モバイル端末向けのレスポンシブ設計 (境界値 768px) */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    .os-container {
        height: auto;
    }

    .desktop {
        padding: 10px;
        height: auto;
        min-height: calc(100vh - 32px);
    }

    .desktop-icons {
        position: relative;
        top: 0;
        right: 0;
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        margin-bottom: 20px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .shortcut-icon {
        width: 70px;
    }

    .window {
        position: relative !important;
        width: 100% !important;
        top: 0 !important;
        left: 0 !important;
        margin-bottom: 24px !important;
        height: auto !important;
        max-height: none !important;
        box-shadow: 4px 4px 0px 0px var(--color-text) !important;
    }

    .window-header {
        cursor: default;
    }

    .window-body {
        padding: 15px;
    }

    .profile-layout {
        flex-direction: column;
        align-items: center;
    }

    .display-title {
        font-size: 26px;
    }
    
    .blog-layout {
        flex-direction: column;
        height: auto;
    }
    .blog-sidebar {
        width: 100%;
        height: 120px;
        border-right: none;
        border-bottom: var(--border-width) solid var(--color-text);
    }
    .blog-content-pane {
        height: 250px;
    }
}

/* --- BLOG SECTION (2-PANE) --- */
.blog-body {
    padding: 0 !important;
    height: 380px;
}

.blog-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

.blog-sidebar {
    width: 200px;
    min-width: 200px;      /* flexコンテナ内で縮まないよう固定 */
    flex-shrink: 0;        /* flex-shrink デフォルトの1を無効化 */
    border-right: var(--border-width) solid var(--color-text);
    background-color: var(--bg-window);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    user-select: none;
}

.blog-item {
    padding: 10px;
    border-bottom: 1px solid var(--color-text);
    cursor: pointer;
    font-size: 11px;
    line-height: 1.3;
}

.blog-item-title {
    font-weight: bold;
    margin-bottom: 4px;
    word-break: break-word;
}

.blog-item-date {
    color: var(--color-muted);
}

.blog-item:hover, .blog-item.active-post {
    background-color: var(--color-text);
    color: var(--bg-canvas);
}
.blog-item:hover .blog-item-date, .blog-item.active-post .blog-item-date {
    color: var(--bg-window);
}

.blog-content-pane {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-canvas);
}

.blog-content-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    border-bottom: var(--border-width) solid var(--color-text);
    padding-bottom: 8px;
}

.blog-content-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-muted);
    margin-bottom: 15px;
}

.blog-content-body {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.6;
}

.blog-content-body h1, .blog-content-body h2 {
    font-size: 14px;
    margin: 18px 0 8px 0;
    border-bottom: 1px dashed var(--color-text);
    padding-bottom: 4px;
}

.blog-content-body p {
    margin-bottom: 12px;
}

.blog-content-body ul {
    margin-left: 20px;
    margin-bottom: 12px;
}
