/*
Theme Name: Portfolio Theme
Theme URI: http://example.com/
Author: Your Name
Author URI: http://example.com/
Description: ポートフォリオサイト用のカスタムテーマ
Version: 6.0 Final
License: GPL v2 or later
Text Domain: portfolio-theme
*/

/* CSS Variables for dynamic sizing */
:root {
    --item-width: 320px;
    --item-height: 450px;
    --image-height: 350px;
    --item-gap: 60px;
}

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

body {
    font-family: 'Arial', sans-serif;
    background: #0a0a0a;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    cursor: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* 全体的なリンクのスタイル */
a {
    color: #667eea;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* 投稿内容内のリンク */
.modal-body a,
.page-content a,
.content-scroll-area a {
    color: #667eea;
    text-decoration: underline;
}

.modal-body a:hover,
.page-content a:hover,
.content-scroll-area a:hover {
    color: #8b9cff;
    text-decoration: none;
}

/* 背景グラデーション - 新規抜き出し */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, rgba(26,26,46,0.8) 0%, rgba(10,10,10,0.9) 100%);
    z-index: 0;
    pointer-events: none;
}

/* 背景タイルパターン - 背景の上、コンテンツの下 */
.background-tiles-wrapper {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.background-tiles {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 300%;
    height: 300%;
	opacity: 0.10;
    background-size: 300px 300px;
    background-repeat: repeat;
    will-change: transform;
    pointer-events: none;
}

/* Main Container */
.main-container {
    position: relative;
    width: 100%;
    height: 100vh;
    z-index: 10;
}

/* Corner UI Elements - 完全階層分離 */
.corner-ui {
    position: fixed;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* 上部 - 最上位層 */
.top-left {
    top: 40px;
    left: 40px;
    z-index: 9000;
}

.top-right {
    top: 40px;
    right: 40px;
    text-align: right;
    z-index: 9000;
}

/* 下部 - 最下位層（四隅テキスト） */
.bottom-left {
    bottom: 40px;
    left: 40px;
    z-index: 50;
}

.bottom-right {
    bottom: 40px;
    right: 40px;
    text-align: right;
    z-index: 50;
}

.brand-name {
    font-size: 24px;
    font-weight: 300;
    margin-bottom: 20px;
    opacity: 0.9;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.brand-name:hover {
    opacity: 1;
}

.tag-filter {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    position: relative;
}

.tag-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s ease;
    padding: 6px 12px;
    border-radius: 15px;
    position: relative;
    z-index: 9001;
}

.tag-btn.active,
.tag-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

.menu-item {
    display: block;
    color: #fff;
    text-decoration: none;
    margin-bottom: 8px;
    opacity: 0.7;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    z-index: 9000;
}

.menu-item:hover {
    opacity: 1;
    transform: translateX(-5px);
}

.menu-item.active {
    opacity: 1;
}

.menu-item.active::after {
    content: '';
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 1px;
    background: #fff;
}

/* Bottom UI - 四隅テキスト */
.current-info {
    opacity: 0.5;
}

.current-category {
    font-size: 10px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.current-title {
    font-size: 12px;
    font-weight: 300;
}

.year {
    font-size: 48px;
    font-weight: 100;
    opacity: 0.3;
    line-height: 1;
    margin-bottom: 10px;
}

.counter {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    opacity: 0.6;
}

/* Section Base Styles - 背景タイルより上 */
.section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.section.active {
    opacity: 1;
    pointer-events: auto;
}

/* Works Section */
.portfolio-container {
    position: relative;
    width: 100%;
    height: 600px;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    cursor: grab;
    z-index: 5000;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

.portfolio-container.dragging {
    cursor: grabbing;
}

.portfolio-wrapper {
    display: flex;
    align-items: center;
    gap: var(--item-gap);
    position: absolute;
    left: 0;
    transform: translateX(0);
    will-change: transform;
}

.portfolio-item {
    flex-shrink: 0;
    width: var(--item-width);
    height: var(--item-height);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 1;
    z-index: 6000;
    will-change: transform, opacity;
}

.portfolio-item.visible {
    opacity: 1;
}

/* 中央から離れるほど縮小 */
.portfolio-item.distance-0 {
    opacity: 1;
    transform: scale(1.2);
    z-index: 7000;
    cursor: pointer;
}

.portfolio-item.distance-1 {
    opacity: 1;
    transform: scale(1);
    z-index: 6500;
    cursor: pointer;
}

.portfolio-item.distance-2 {
    opacity: 1;
    transform: scale(1);
    z-index: 6400;
    cursor: pointer;
}

.portfolio-item.distance-3 {
    opacity: 1;
    transform: scale(1);
    z-index: 6300;
    cursor: pointer;
}

.portfolio-item.distance-4 {
    opacity: 1;
    transform: scale(1);
    z-index: 6200;
    cursor: pointer;
}

.portfolio-image {
    width: 100%;
    height: var(--image-height);
    position: relative;
    overflow: visible;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* 透過画像対応 - 背景なし */
}

/* ホバー時は.portfolio-image全体を拡大 */
.portfolio-item.distance-0:hover .portfolio-image {
    transform: scale(1.05);
}

.portfolio-info {
    padding: 20px 0;
    text-align: center;
    z-index: 4000;
    position: relative;
}

.portfolio-category {
    font-size: 12px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.portfolio-title {
    font-size: 18px;
    font-weight: 300;
    opacity: 0.9;
}

/* About Section - 背景タイルより上 */
.about-section, .contact-section {
    padding-top: 120px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* スクロール有効化 */
    touch-action: auto;
    overflow: hidden;
    z-index: 200;
}

.about-content, .contact-content {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    padding: 0 20px;
    z-index: 300;
    position: relative;
}

.about-content h2, .contact-content h2 {
    font-size: 36px;
    font-weight: 300;
    margin-bottom: 30px;
    opacity: 0.9;
    text-align: center;
    flex-shrink: 0;
    z-index: 400;
    position: relative;
}

/* スクロール可能なコンテンツエリア */
.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 70vh;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch;
    /* スクロール有効化 */
    touch-action: pan-y;
    z-index: 400;
    position: relative;
}

/* カスタムスクロールバー */
.content-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.content-scroll-area::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}

.content-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.content-scroll-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.about-content p, .contact-content p {
    font-size: 18px;
    line-height: 1.8;
    opacity: 0.8;
    margin-bottom: 20px;
}

/* About/Contact画像 - 背景タイルより確実に上に配置 */
.about-content img, .contact-content img,
.content-scroll-area img, .page-content img {
    opacity: 1 !important;
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    border-radius: 8px;
    z-index: 500 !important;
    position: relative !important;
}

.contact-email {
    font-size: 24px;
    color: #667eea;
    text-decoration: none;
    transition: opacity 0.3s ease;
    display: inline-block;
    margin-top: 10px;
}

.contact-email:hover {
    opacity: 0.8;
}

/* Navigation Buttons */
.nav-button {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 8000;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.works-section.active ~ .nav-button,
.nav-button.works-visible {
    opacity: 0.7;
    pointer-events: auto;
}

.nav-button:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-50%) scale(1.1);
}

.nav-left {
    left: 40px;
}

.nav-right {
    right: 40px;
}

/* Scroll Bar - タイトルの下、四隅の上の隙間に正確配置 */
.scroll-bar-container {
    position: fixed;
    bottom: 90px; /* 四隅テキスト（40px）+ 余裕（50px）で90px */
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 8500; /* 高いz-indexでタッチ可能に */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* タッチ確実化 */
    touch-action: manipulation;
}

/* works-visibleクラスが付いたら表示 */
.scroll-bar-container.works-visible {
    display: flex !important;
    opacity: 0.8 !important;
    pointer-events: auto !important;
}

/* About/Contactセクションでは強制的に非表示 */
.about-section.active ~ .scroll-bar-container,
.contact-section.active ~ .scroll-bar-container {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.scroll-bar-track {
    position: relative;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.05) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0.05) 100%);
    border-radius: 3px;
    overflow: visible;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    /* タッチ領域拡大 */
    padding: 10px 0;
    margin: -10px 0;
}

.scroll-bar-progress {
    position: absolute;
    top: 10px;
    left: 0;
    height: 6px;
    background: linear-gradient(90deg,
        rgba(102, 126, 234, 0.3) 0%,
        rgba(102, 126, 234, 0.5) 100%);
    border-radius: 3px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.scroll-bar-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px; /* タッチ領域拡大 */
    height: 30px; /* タッチ領域拡大 */
    background: radial-gradient(circle at center,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.5) 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(102, 126, 234, 0.2);
    /* タッチ確実化 */
    touch-action: manipulation;
    z-index: 8501;
}

.scroll-bar-handle:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: radial-gradient(circle at center,
        rgba(255, 255, 255, 1) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0.6) 100%);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(102, 126, 234, 0.4);
}

.scroll-bar-handle.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
    background: radial-gradient(circle at center,
        rgba(255, 255, 255, 1) 0%,
        rgba(102, 126, 234, 0.8) 50%,
        rgba(102, 126, 234, 0.6) 100%);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(102, 126, 234, 0.6);
}

/* ツールチップ */
.scroll-bar-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 1px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.scroll-bar-handle:hover .scroll-bar-tooltip,
.scroll-bar-handle.dragging .scroll-bar-tooltip {
    opacity: 1;
}

/* スクロールバー全体のホバー効果 */
.scroll-bar-container:hover .scroll-bar-track {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.08) 0%, 
        rgba(255, 255, 255, 0.15) 50%, 
        rgba(255, 255, 255, 0.08) 100%);
}

.scroll-bar-container:hover .scroll-bar-progress {
    background: linear-gradient(90deg,
        rgba(102, 126, 234, 0.4) 0%,
        rgba(102, 126, 234, 0.6) 100%);
}

/* Modal - 最上位レイヤー */
.modal {
    display: none;
    position: fixed;
    z-index: 50000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.95);
    pointer-events: auto; /* モーダル自体はクリック可能 */
}

/* モーダル表示中は背景要素のポインターイベントを無効化 */
body:has(.modal.show) .portfolio-container,
body:has(.modal.show) .nav-button,
body:has(.modal.show) .scroll-bar-container {
    pointer-events: none;
}

.modal-content {
    background: rgba(20,20,20,0.98);
    border-radius: 16px;
    padding: 60px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.modal.show .modal-content {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* カスタムスクロールバー */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* 閉じるボタンを画面に完全固定 */
.modal-close {
    position: fixed !important;
    top: 30px !important;
    right: 40px !important;
    font-size: 30px;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    transform: rotate(0deg);
    z-index: 50001 !important;
    background: rgba(0, 0, 0, 0.7);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-close:hover {
    opacity: 1;
    transform: rotate(90deg);
    background: rgba(0, 0, 0, 0.9);
}

.modal-header {
    margin-bottom: 40px;
}

.modal-title {
    font-size: 36px;
    font-weight: 300;
    margin-bottom: 10px;
    color: #fff;
}

.modal-meta {
    font-size: 14px;
    opacity: 0.6;
}

.modal-category {
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-right: 20px;
}

#modalMedia {
    margin-bottom: 0;
}

#modalMedia img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    opacity: 1 !important;
}

.modal-body {
    font-size: 16px;
    line-height: 1.8;
    color: #ccc;
}

.modal-body h1, .modal-body h2, .modal-body h3,
.modal-body h4, .modal-body h5, .modal-body h6 {
    color: #fff;
    margin: 30px 0 15px;
}

.modal-body p {
    margin-bottom: 20px;
}

.modal-body img {
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    border-radius: 8px;
    opacity: 1 !important;
}

.loading {
    text-align: center;
    opacity: 0.7;
    font-size: 18px;
}

/* Page Template */
.page-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.page-content h1, .page-content h2, .page-content h3,
.page-content h4, .page-content h5, .page-content h6 {
    color: #fff;
    margin: 30px 0 15px;
}

.page-content h1:first-child,
.page-content h2:first-child {
    margin-top: 0;
}

.page-content p {
    margin-bottom: 20px;
    line-height: 1.8;
}

/* スクロールエリア内のコンテンツ */
.content-scroll-area .page-content {
    padding-top: 0;
}

.content-scroll-area p:last-child {
    margin-bottom: 40px;
}

/* Responsive - タブレット */
@media (max-width: 1024px) {
    .portfolio-container {
        height: 500px;
        max-height: 80vh;
    }
    
    .about-section, .contact-section {
        padding-top: 100px;
        align-items: center;
    }
    
    .about-content, .contact-content {
        height: calc(100vh - 100px);
    }
    
    .content-scroll-area {
        max-height: 68vh;
    }
    
    .scroll-bar-container {
        width: 250px;
        bottom: 80px;
    }
}

/* Responsive - スマートフォン（完全干渉回避） */
@media (max-width: 768px) {
    .corner-ui {
        font-size: 12px;
    }

    .top-left {
        top: 20px;
        left: 20px;
        right: auto;
        z-index: 9000;
    }
    
    .top-right {
        top: 20px;
        right: 20px;
        left: auto;
        z-index: 9000;
    }

    /* 下部コーナーの完全分離 */
    .bottom-left {
        bottom: 20px;
        left: 20px;
        max-width: calc(40vw - 20px);
        z-index: 50;
    }
    
    .bottom-right {
        bottom: 20px;
        right: 20px;
        max-width: calc(40vw - 20px);
        z-index: 50;
    }

    /* テキスト改行強化 */
    .current-category,
    .current-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        line-height: 1.3;
        font-size: 9px;
    }

    .brand-name {
        font-size: 18px;
        margin-bottom: 12px;
    }

    /* タグフィルター改行対応 */
    .tag-filter {
        gap: 6px;
        max-width: calc(100vw - 80px);
    }

    .tag-btn {
        padding: 5px 8px;
        font-size: 8px;
        white-space: nowrap;
        -webkit-tap-highlight-color: rgba(255,255,255,0.2);
    }

    .menu-item {
        font-size: 10px;
        margin-bottom: 5px;
    }

    .year {
        font-size: 32px;
    }

    .counter {
        font-size: 10px;
    }

    /* ポートフォリオ表示調整 */
    .portfolio-container {
        height: 450px;
        max-height: 65vh;
        cursor: default;
        margin-top: -30px;
    }

    .portfolio-info {
        padding: 12px 0;
    }

    .portfolio-category {
        font-size: 9px;
    }

    .portfolio-title {
        font-size: 12px;
    }

    /* スマホ用の縮小効果調整 */
    .portfolio-item.distance-0 {
        transform: scale(1.1);
        cursor: pointer;
    }

    /* ナビゲーションボタン */
    .nav-button {
        width: 35px;
        height: 35px;
        font-size: 14px;
        top: 42%;
    }

    .nav-left {
        left: 8px;
    }

    .nav-right {
        right: 8px;
    }
    
    /* About/Contactセクション */
    .about-section, .contact-section {
        padding-top: 70px;
        padding-left: 15px;
        padding-right: 15px;
        align-items: center;
    }
    
    .about-content,
    .contact-content {
        height: calc(100vh - 70px);
        padding: 0;
    }
    
    .about-content h2,
    .contact-content h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .content-scroll-area {
        max-height: 60vh;
        padding: 10px 0;
    }
    
    .about-content p,
    .contact-content p {
        font-size: 14px;
    }
    
    .contact-email {
        font-size: 18px;
    }

    /* モーダル */
    .modal-content {
        padding: 30px 15px;
        max-height: 88vh;
        border-radius: 10px;
    }

    .modal-close {
        top: 15px !important;
        right: 15px !important;
        font-size: 24px;
        width: 40px;
        height: 40px;
    }

    .modal-title {
        font-size: 24px;
    }
    
    /* スクロールバー位置調整 - タイトルと四隅の隙間 */
    .scroll-bar-container {
        width: 200px;
        bottom: 70px; /* スマホ用調整 */
    }
    
    /* スクロールバーのタッチ領域拡大（スマホ用） */
    .scroll-bar-handle {
        width: 40px;
        height: 40px;
    }
}

/* 縦画面時の追加調整 */
@media (orientation: portrait) and (max-width: 768px) {
    .portfolio-container {
        margin-top: -50px;
    }
    
    .scroll-bar-container {
        bottom: 75px;
    }
    
    .nav-button {
        top: 40%;
    }
}