/* =========================================
   1. CSS変数（カラーテーマの定義）
   ========================================= */
:root {
    --bg-color: #121212;
    --text-color: #d1d1d1;
    --accent-color: #ffffff;
    --link-color: #888888;
    --font-main: 'Noto Sans JP', sans-serif;
}

body.cyber-mode {
    --bg-color: #000000;
    --text-color: #00ff00;
    --accent-color: #00ff00;
    --link-color: #00ff00;
    --font-main: 'Courier New', Courier, monospace;
}

/* =========================================
   2. 基本設定
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    line-height: 1.8;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.5s ease, color 0.5s ease;
    position: relative;
}

/* 画面全体の走査線（ノイズ） */
.screen-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 18, 18, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.3;
}

.container {
    text-align: center;
    max-width: 600px;
    padding: 20px;
    will-change: transform, filter;
}

/* =========================================
   3. 各要素のスタイル
   ========================================= */
h1 {
    font-size: 2.5rem;
    font-weight: 500;
    letter-spacing: 0.2rem;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
    display: inline-block;
    min-height: 3.5rem;
    max-height: 6rem;
    opacity: 1;
    transition: text-shadow 0.3s ease, opacity 0.5s ease, max-height 0.5s ease, margin-bottom 0.5s ease, min-height 0.5s ease;
}

h1:hover {
    text-shadow: 0 0 10px var(--accent-color);
}

/* サイバーモード時にh1をフェードアウトして領域ごと消す */
body.cyber-mode h1 {
    opacity: 0;
    max-height: 0;
    min-height: 0;
    margin-bottom: 0;
}

.profile p {
    font-weight: 300;
    margin-bottom: 2rem;
}

.links a {
    color: var(--link-color);
    text-decoration: none;
    margin: 0 15px;
    font-size: 0.9rem;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.links a:hover {
    color: #ffffff;
    text-shadow: 0 0 10px #ffffff;
}

/* バグ修正: サイバーモード時のリンクホバー色をテーマ色に合わせる */
body.cyber-mode .links a:hover {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
}

footer {
    margin-top: 4rem;
    font-size: 0.7rem;
    color: #444;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

.fade-in {
    opacity: 0; /* delay中も非表示にする */
    animation: fadeIn 1.2s forwards;
    /* animation-delayはHTML側のstyle属性で要素ごとに指定 */
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* 右下の点 */
#status-point {
    position: fixed; bottom: 20px; right: 20px; width: 4px; height: 4px;
    background-color: #333; border-radius: 50%; opacity: 0; z-index: 10000;
    cursor: default; transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    animation: fadeInPoint 2s forwards 1s;
}

@keyframes fadeInPoint {
    to { opacity: 1; }
}

#status-point:hover {
    background-color: #ffffff;
    box-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff;
    transform: scale(1.5);
}

/* =========================================
   4. 裏モード（サイバーモード）の独自スタイル
   ========================================= */
#secret-message {
    display: none;
}

body.cyber-mode #secret-message {
    display: block;
    color: #ff00c8;
    font-weight: bold;
    animation: pulse 1s infinite;
    margin-top: -1rem;
    margin-bottom: 2rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* サイバーモード時の右下の点 */
body.cyber-mode #status-point {
    background-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    animation: pulsePoint 1.5s infinite;
}

@keyframes pulsePoint {
    0%, 100% { box-shadow: 0 0 10px var(--accent-color); transform: scale(1); }
    50% { box-shadow: 0 0 20px var(--accent-color); transform: scale(1.2); }
}

/* コンテナ全体のゆがみ */
body.cyber-mode .container {
    animation: content-distort 2.5s linear infinite;
    filter: drop-shadow(2px 0px 0px rgba(255,0,0,0.5)) drop-shadow(-2px 0px 0px rgba(0,255,255,0.5));
}

/* distortコマンドで無効化 */
body.cyber-mode .container.no-distort {
    animation: none;
    filter: none;
    transform: none;
}

@keyframes content-distort {
    0%   { transform: translate(0) skew(0deg) scale(1); filter: contrast(100%); }
    2%   { transform: translate(4px, -2px) skew(3deg) scale(1.02); filter: contrast(150%); }
    4%   { transform: translate(-3px, 3px) skew(-2deg) scale(1); filter: contrast(100%); }
    5%   { transform: translate(0) skew(0deg); }
    50%  { transform: translate(0) skew(0deg); filter: blur(0px); }
    52%  { transform: translate(-2px, 1px) skew(-1deg) scale(0.99); filter: blur(1px) contrast(120%); }
    54%  { transform: translate(2px, -1px) skew(1deg) scale(1); filter: blur(0px) contrast(100%); }
    55%  { transform: translate(0) skew(0deg); }
    100% { transform: translate(0) skew(0deg); }
}

/* =========================================
   5. ターミナル風表示（サイバーモード専用）
   ========================================= */

/* プロフィールとターミナルを同じ場所に重ねるスロット */
.profile-slot {
    position: relative;
    margin-bottom: 2rem;
    /* 両要素のうち高い方に合わせて高さが決まる */
}

.profile-slot .profile,
.profile-slot #terminal-section {
    transition: opacity 0.5s ease;
}

/* 通常時: プロフィール表示・ターミナル非表示 */
.profile-slot .profile {
    opacity: 1;
    pointer-events: auto;
}

#terminal-section {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    opacity: 0;
    visibility: hidden;   /* 完全に非表示（領域も消える） */
    pointer-events: none;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* サイバーモード時: プロフィール非表示・ターミナル表示 */
body.cyber-mode .profile-slot .profile {
    opacity: 0;
    pointer-events: none;
}

body.cyber-mode #terminal-section {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    position: relative;
    left: auto;
    transform: none;
}

#terminal-box {
    background-color: #0a0a0a;
    border: 1px solid #00ff00;
    border-radius: 6px;
    padding: 0;
    text-align: left;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.3), inset 0 0 30px rgba(0,0,0,0.5);
    overflow: hidden;
    /* 高さを固定してコマンド追加でもサイズが変わらないようにする */
    height: 200px;
    display: flex;
    flex-direction: column;
}

/* ターミナルのタイトルバー */
.terminal-header {
    background-color: #1a1a1a;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #333;
    flex-shrink: 0; /* タイトルバーは縮まない */
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.terminal-dot.red    { background-color: #ff5f57; }
.terminal-dot.yellow { background-color: #febc2e; }
.terminal-dot.green  { background-color: #28c840; }

.terminal-title {
    color: #666;
    font-size: 0.75rem;
    margin-left: 6px;
}

/* ターミナルの出力テキスト */
#terminal-output {
    padding: 12px 16px 4px;
    color: #00ff00;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* スクロールバーを非表示（Chrome / Safari / Edge） */
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE / 旧Edge */
}

#terminal-output::-webkit-scrollbar {
    display: none; /* Chrome / Safari / Edge */
}

#terminal-output .line {
    display: block;
    opacity: 0;
    animation: termFadeIn 0.1s forwards;
    white-space: pre-wrap;
    word-break: break-all;
    max-width: 100%;
}

/* promptカラー */
#terminal-output .prompt {
    color: #00ff00;
}

/* 出力行のカラー */
#terminal-output .output {
    color: #aaffaa;
    padding-left: 1em;
}

/* エラー行のカラー */
#terminal-output .error-line {
    color: #ff4444;
    padding-left: 1em;
}

@keyframes termFadeIn {
    to { opacity: 1; }
}

/* カーソル行: サイバーモード時のみ表示、インタラクティブ中は非表示 */
.terminal-cursor-line {
    padding: 0 16px 10px;
    color: #00ff00;
    display: none; /* デフォルトは非表示 */
    align-items: center;
}

body.cyber-mode .terminal-cursor-line {
    display: flex;
}

/* インタラクティブモード中はJSでhidden classを付与して隠す */
body.cyber-mode .terminal-cursor-line.hidden {
    display: none;
}

.terminal-prompt {
    color: #00ff00;
}

.terminal-blink {
    animation: blink 1s step-start infinite;
    color: #00ff00;
}

@keyframes blink {
    50% { opacity: 0; }
}