/*
Theme Name: MIRAI SAIBOU Terminal (v2 flip overlay)
Theme URI: https://miraisaibou.com
Author: MIRAI SAIBOU Co. Ltd.
Author URI: https://miraisaibou.com
Description: Terminal-style corporate WordPress theme. v2: パタンアニメをダミーオーバーレイ方式に変更し、本体コンテンツへの transform 影響を排除。WebGL や canvas、iframe との共存が可能に。
Version: 2.1.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: Private
Text Domain: mirai-saibou
*/

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --green: #00FF55;
    --green-dim: rgba(0, 255, 85, 0.3);
    --green-faint: rgba(0, 255, 85, 0.05);
    --green-hover: rgba(0, 255, 85, 0.1);
    --black: #000000;
    --bg: rgba(0, 0, 0, 0.85);
    --font-mono: 'Courier New', Consolas, 'Lucida Console', monospace;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--black);
    color: var(--green);
    font-family: var(--font-mono);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

a {
    color: var(--green);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   BACKGROUND EFFECTS
   ============================================ */
.bg-wireframe {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 80vw;
    max-width: 600px;
    transform: translate(-50%, -50%);
    animation: spin 40s linear infinite;
    opacity: 0.07;
    z-index: -1;
    pointer-events: none;
}

@keyframes spin {
    0%   { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 255, 85, 0.04) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
}

/* ============================================
   TERMINAL WINDOW
   ============================================ */
.terminal-window {
    max-width: 960px;
    margin: 40px auto;
    padding: 36px 40px;
    border: 2px solid var(--green);
    box-shadow:
        0 0 15px var(--green-dim) inset,
        0 0 30px rgba(0, 255, 85, 0.4),
        0 0 60px rgba(0, 255, 85, 0.1);
    background-color: var(--bg);
    backdrop-filter: blur(2px);
    position: relative;
    z-index: 1;
}

/* コーナー装飾 */
.terminal-window::before,
.terminal-window::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--green);
    border-style: solid;
}

.terminal-window::before {
    top: -4px;
    left: -4px;
    border-width: 3px 0 0 3px;
}

.terminal-window::after {
    bottom: -4px;
    right: -4px;
    border-width: 0 3px 3px 0;
}

/* ============================================
   TYPOGRAPHY & GLOW
   ============================================ */
.glow {
    text-shadow: 0 0 5px var(--green), 0 0 15px var(--green);
}

.site-title {
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    margin-top: 0;
    border-bottom: 2px dashed var(--green);
    padding-bottom: 12px;
    letter-spacing: 3px;
    font-weight: bold;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-mono);
    color: var(--green);
    font-weight: bold;
    letter-spacing: 1px;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p {
    margin-bottom: 1em;
}

/* ============================================
   PROMPT LINE
   ============================================ */
.prompt {
    margin: 20px 0 6px;
    font-weight: bold;
    color: var(--green);
}

.prompt::before {
    content: "root@miraisaibou:~# ";
    opacity: 0.85;
}

.prompt-output {
    margin: 0 0 16px;
}

/* ============================================
   CURSOR BLINK
   ============================================ */
.cursor::after {
    content: "■";
    display: inline-block;
    color: var(--green);
    vertical-align: bottom;
    animation: blink 1s step-end infinite;
    text-shadow: 0 0 10px var(--green);
    margin-left: 4px;
}

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

/* ============================================
   NAVIGATION
   ============================================ */
.site-nav {
    margin: 10px 0 24px;
}

.site-nav ul,
.prompt-output ul {
    list-style: none;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px;
}

.site-nav ul li a,
.prompt-output ul li a {
    display: inline-block;
    color: var(--green);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid var(--green);
    transition: all 0.15s ease;
    font-family: var(--font-mono);
}

.site-nav ul li a:hover,
.site-nav ul li.current-menu-item a,
.prompt-output ul li a:hover,
.prompt-output ul li.current-menu-item a {
    background-color: var(--green);
    color: var(--black);
}

/* ============================================
   NEWS / POST LIST
   ============================================ */
.news-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.news-item {
    display: block;
    color: var(--green);
    text-decoration: none;
    padding: 9px 12px;
    margin-bottom: 4px;
    border: 1px dashed transparent;
    transition: all 0.2s ease;
    font-family: var(--font-mono);
}

.news-item:hover {
    border: 1px dashed var(--green);
    background-color: var(--green-hover);
    text-shadow: 0 0 8px var(--green);
}

.news-date {
    margin-right: 14px;
    opacity: 0.8;
    font-size: 0.9rem;
}

.news-tag {
    font-size: 0.75rem;
    border: 1px solid var(--green);
    padding: 1px 6px;
    margin-right: 12px;
    vertical-align: middle;
}

.news-title {
    vertical-align: middle;
}

/* ============================================
   SINGLE POST / PAGE CONTENT
   ============================================ */
.entry-header {
    margin-bottom: 24px;
    border-bottom: 1px dashed var(--green);
    padding-bottom: 12px;
}

.entry-title {
    font-size: 1.5rem;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.entry-content {
    line-height: 1.8;
}

.entry-content p { margin-bottom: 1.2em; }

.entry-content h2,
.entry-content h3 {
    margin: 1.5em 0 0.5em;
    border-left: 3px solid var(--green);
    padding-left: 12px;
}

.entry-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.entry-content a:hover {
    background-color: var(--green);
    color: var(--black);
    text-decoration: none;
}

.entry-content ul,
.entry-content ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.entry-content ul li::marker {
    content: "> ";
    color: var(--green);
}

.entry-content blockquote {
    border-left: 3px solid var(--green);
    padding: 10px 20px;
    margin: 1em 0;
    background-color: var(--green-faint);
    font-style: normal;
}

.entry-content pre,
.entry-content code {
    background-color: var(--green-faint);
    border: 1px solid var(--green-dim);
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.entry-content pre {
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 1em;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    margin-top: 30px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 4px 12px;
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--font-mono);
    transition: all 0.15s;
}

.pagination a:hover,
.pagination .current {
    background-color: var(--green);
    color: var(--black);
}

/* ============================================
   CONTACT FORM (CF7 対応)
   ============================================ */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 textarea {
    width: 100%;
    background: transparent;
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 8px 12px;
    outline: none;
    transition: box-shadow 0.2s;
    margin-bottom: 12px;
}

.wpcf7 input:focus,
.wpcf7 textarea:focus {
    box-shadow: 0 0 8px var(--green-dim);
}

.wpcf7 input[type="submit"] {
    background: transparent;
    border: 2px solid var(--green);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 8px 24px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
}

.wpcf7 input[type="submit"]:hover {
    background: var(--green);
    color: var(--black);
}

/* ============================================
   GAME EMBED
   ============================================ */
.game-embed-wrap {
    width: 100%;
    aspect-ratio: 8 / 3;
    margin-bottom: 24px;
}

.game-embed-wrap.is-mobile {
    aspect-ratio: 3 / 2;
}

.game-embed {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    display: block;
    background: #000;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.85rem;
    border-top: 1px solid var(--green);
    padding-top: 20px;
    opacity: 0.8;
}

.site-footer .encrypted-badge {
    font-size: 0.7rem;
    display: block;
    margin-top: 4px;
    letter-spacing: 2px;
}

/* ============================================
   UTILITY
   ============================================ */
.hidden { display: none; }

.section-divider {
    border: none;
    border-top: 1px dashed var(--green);
    margin: 24px 0;
    opacity: 0.5;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .terminal-window {
        margin: 16px;
        padding: 20px;
    }

    .site-title {
        font-size: 1.4rem;
        letter-spacing: 1px;
    }

    .site-nav ul,
    .prompt-output ul {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px;
    }

    .site-nav ul li,
    .prompt-output ul li {
        width: calc(50% - 4px) !important;
    }

    .site-nav ul li a,
    .prompt-output ul li a {
        display: block !important;
        width: 100%;
        box-sizing: border-box;
    }

    .news-date {
        display: block;
        margin-bottom: 2px;
    }
}

@media (max-width: 480px) {
    .terminal-window {
        margin: 8px;
        padding: 16px;
    }

    .prompt::before {
        content: "# ";
    }
}

/* ============================================
   スプラッシュオーバーレイ
   ============================================ */
#splash-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

#splash-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#splash-overlay.hidden {
    display: none;
}

#splash-logo {
    width: min(40vw, 200px);
    height: min(40vw, 200px);
    opacity: 0.5;
    animation: splash-spin 8s linear infinite;
    filter: drop-shadow(0 0 8px rgba(0,255,85,0.6));
}

@keyframes splash-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================
   ページ構築フェードイン
   ============================================ */
.terminal-window > * {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.terminal-window > *.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   隠しターミナル
   ============================================ */
#hidden-terminal {
    display: none;
    margin-top: 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--green);
    width: 100%;
}

#hidden-terminal.is-active {
    display: block;
}

#terminal-history {
    margin-bottom: 4px;
}

#terminal-history .terminal-line {
    margin: 2px 0;
    white-space: pre-wrap;
    word-break: break-all;
    opacity: 0.8;
}

#terminal-history .terminal-line.input-line::before {
    content: 'root@miraisaibou:~# ';
    opacity: 0.6;
}

#terminal-history .terminal-line.output-line {
    opacity: 0.5;
    font-size: 0.8rem;
    padding-left: 1em;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.terminal-prompt {
    opacity: 0.6;
    flex-shrink: 0;
}

#terminal-input-display {
    word-break: break-all;
}

#footer-cursor {
    margin-left: 2px;
}

/* ============================================
   ページ入場アニメーション（v2: オーバーレイ方式）
   本物のterminal-windowにはtransformをかけず、
   別のオーバーレイ要素がパタンを演じる。
   ============================================ */

/* トップページ以外では、本物はJSから表示制御される */
.terminal-window.is-pending {
    opacity: 0;
    pointer-events: none;
}

.terminal-window.is-revealed {
    opacity: 1;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}

/* ダミーオーバーレイ:本物と同じ位置・サイズに重ねてパタンを演じる */
/* 位置・サイズはJS側でインラインstyleで指定する */
.flip-overlay {
    pointer-events: none;
    z-index: 9999;
}

.flip-overlay-inner {
    /* 本物のterminal-windowと同じ見た目の枠だけ */
    border: 2px solid var(--green);
    box-shadow: 0 0 20px rgba(0, 255, 85, 0.3), inset 0 0 20px rgba(0, 255, 85, 0.05);
    background: rgba(0, 0, 0, 0.92);
    box-sizing: border-box;

    /* 初期状態: 1pxの縦線 */
    transform: perspective(4800px) rotateY(89.98deg);
    transform-origin: center center;
}

.flip-overlay-inner.is-opening {
    transform: perspective(4800px) rotateY(0deg);
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.flip-overlay.is-fading {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* 管理バー表示時の上部余白補正 */
.admin-bar .terminal-window {
    margin-top: 72px;
}

/* ============================================
   投稿記事内のcanvas表示調整
   ============================================ */
.entry-content canvas {
    display: block;
    max-width: 100%;
}
