/* --- CORE SETTINGS --- */
:root {
    --bg-color: #FFFFFF;
    --text-color: #000000;
    --accent-color: #000000;
    --cursor-color: #000000;
    --font-main: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", sans-serif;
    --font-mono: "Courier New", Consolas, monospace;
    --transition-speed: 0.6s;
}

/* ターミナルモード(反転) */
body.terminal-mode {
    --bg-color: #050505;
    --text-color: #00FF41; /* ターミナルグリーン */
    --accent-color: #00FF41;
    --cursor-color: #FFFFFF; /* 白カーソル */
}

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

/* デスクトップのみカスタムカーソルを適用 */
@media (hover: hover) and (pointer: fine) {
    * {
        cursor: none;
    }
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* --- P5.JS CANVAS BACKGROUND --- */
#p5-canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#p5-canvas-container canvas {
    display: block;
}

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

/* --- CUSTOM CURSOR --- */
#cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    background-color: var(--cursor-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.2s, height 0.2s, background-color 0.2s, border-radius 0.2s;
    display: none; /* デフォルトは非表示 */
}

/* デスクトップのみカーソルを表示 */
@media (hover: hover) and (pointer: fine) {
    #cursor {
        display: block;
    }
}

/* リンクホバー時のカーソル(ターミナル風キャレット) */
body.hovering #cursor {
    width: 20px;
    height: 30px;
    border-radius: 0;
    background-color: var(--cursor-color);
    opacity: 0.8;
    animation: blink 1s infinite;
}

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

/* --- LAYOUT --- */
section {
    min-height: 100vh;
    padding: 4vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* --- HEADER / HERO --- */
.logo {
    font-size: 2rem;
    font-weight: bold;
    position: fixed;
    top: 40px;
    left: 40px;
    z-index: 100;
    letter-spacing: -0.05em;
}

.logo img {
    height: 40px;
    width: auto;
    display: block;
}

.hero-content {
    margin-top: 10vh;
}

h1 {
    font-size: clamp(3rem, 8vw, 10rem);
    line-height: 0.9;
    font-weight: 800;
    margin-bottom: 40px;
    text-transform: uppercase;
    max-width: 100%;
    word-wrap: break-word;
}

.copy-jp {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 400;
    line-height: 1.8;
    max-width: 600px;
    margin-left: 5px;
}

.tech-tags {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    margin-top: 15px;
    opacity: 0.7;
    letter-spacing: 0.1em;
    font-weight: 300;
}

/* --- GLITCH EFFECT --- */
.glitch-wrapper {
    position: relative;
    display: inline-block;
}

.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.glitch::before {
    color: #ff00c1;
    clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
    transform: translate(-2px, -2px);
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
    display: none; /* ホバーや特定のタイミングで表示させる */
}

.glitch::after {
    color: #00fff9;
    clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
    transform: translate(2px, 2px);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
    display: none;
}

/* 常に少しノイズが走る演出 */
.glitch:hover::before, .glitch:hover::after {
    display: block;
}

@keyframes glitch-anim-1 {
    0% { clip-path: inset(20% 0 80% 0); }
    20% { clip-path: inset(60% 0 10% 0); }
    40% { clip-path: inset(40% 0 50% 0); }
    60% { clip-path: inset(80% 0 5% 0); }
    80% { clip-path: inset(10% 0 60% 0); }
    100% { clip-path: inset(30% 0 30% 0); }
}
@keyframes glitch-anim-2 {
    0% { clip-path: inset(10% 0 60% 0); }
    20% { clip-path: inset(30% 0 20% 0); }
    40% { clip-path: inset(70% 0 10% 0); }
    60% { clip-path: inset(20% 0 50% 0); }
    80% { clip-path: inset(50% 0 30% 0); }
    100% { clip-path: inset(5% 0 80% 0); }
}

/* --- WORKS LINK SECTION --- */
#works {
    align-items: center;
    text-align: center;
}

.works-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.section-description {
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-family: var(--font-main);
    opacity: 0.9;
    margin-bottom: 5px;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.section-subdescription {
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    font-family: var(--font-main);
    margin-bottom: 30px;
    opacity: 0.8;
    font-weight: 300;
}

.portfolio-link {
    font-family: var(--font-mono);
    font-size: clamp(2rem, 5vw, 6rem);
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    max-width: 100%;
    word-break: break-all;
}

.portfolio-link .link-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
}

.portfolio-link:hover {
    border-bottom: 2px solid var(--accent-color);
    letter-spacing: 0.05em;
}

.portfolio-link:hover .link-icon {
    transform: translateX(10px);
}

.note {
    margin-top: 10px;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    opacity: 0.6;
    font-style: italic;
}

/* --- CONTACT SECTION --- */
#contact {
    justify-content: center;
}

.contact-wrapper {
    width: 100%;
    max-width: 600px;
}

.contact-title {
    font-size: 3rem;
    margin-bottom: 20px;
    font-family: var(--font-mono);
}

.contact-description {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    font-family: var(--font-main);
    margin-bottom: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.contact-subdescription {
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    font-family: var(--font-main);
    margin-bottom: 40px;
    opacity: 0.8;
    font-weight: 300;
}

form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

input, textarea {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--text-color);
    padding: 15px 0;
    font-size: 1.2rem;
    color: var(--text-color);
    font-family: var(--font-mono);
    outline: none;
    border-radius: 0;
    transition: border-color 0.3s;
}

input:focus, textarea:focus {
    border-bottom: 2px solid var(--accent-color);
}

button {
    margin-top: 20px;
    padding: 20px 40px;
    background: transparent;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    font-size: 1.2rem;
    font-family: var(--font-mono);
    cursor: none;
    align-self: flex-start;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

button .button-icon {
    transition: transform 0.3s;
    font-size: 1.3em;
}

button:hover {
    background: var(--text-color);
    color: var(--bg-color);
    transform: translateX(5px);
}

button:hover .button-icon {
    transform: translateX(5px);
}

/* --- MOBILE ADJUSTMENTS --- */
@media (max-width: 768px) {
    .logo {
        top: 20px;
        left: 20px;
        font-size: 1.5rem;
    }

    .logo img {
        height: 30px;
    }

    section {
        padding: 20px;
    }

    .portfolio-link {
        font-size: clamp(1.5rem, 6vw, 3rem);
        word-break: break-word;
    }

    h1 {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .contact-wrapper {
        padding: 0 10px;
    }
}
