/**
 * トップページセクション - メインCSS
 * 
 * @package FCプランニングオフィス
 * @author 株式会社Hackusha - 大硲 神
 * @version 1.0.2
 * 
 * 含まれる内容：
 * - サービスセクション
 * - プロジェクトセクション
 */

/* ==========================================================================
   Service Section - メインスタイル
   ========================================================================== */

/* サービスセクション全体 */
.service-section {
    position: relative;
    background: var(--color-bg-base);
    overflow: hidden;
    z-index: 10; /* heroセクションの要素より上に表示 */
}

/* サービスセクションにグラデーション適用 */
.service-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-overlay);
    pointer-events: none;
    z-index: 1;
}

/* 動画背景付きメインタイトルエリア */
.service-hero {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
    z-index: 2; /* グラデーションの上に表示 */
}

/* 4つの動画グリッド背景 */
.video-grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* デスクトップ: 4列 */
    grid-template-rows: repeat(2, 1fr); /* デスクトップ: 2行 */
    gap: 0;
    background: #000;
    overflow: hidden; /* 枠からはみ出る部分を非表示 */
}

.grid-video {
    width: 100%;
    height: 100%;
    max-width: 100%; /* 最大幅を制限 */
    max-height: 100%; /* 最大高さを制限 */
    object-fit: cover; /* アスペクト比を維持して枠を埋める */
    object-position: center; /* 中央に配置 */
    display: block;
    overflow: hidden; /* 動画自体からのはみ出しも防止 */
}

/* デスクトップ版動画配置 */
.video-1 {
    grid-column: 1 / span 2; /* 1列目から2列分 */
    grid-row: 1 / span 2; /* 1行目から2行分 */
}

.video-2 {
    grid-column: 3 / span 1; /* 3列目に1列分 */
    grid-row: 1 / span 1; /* 1行目に1行分 */
}

.video-3 {
    grid-column: 4 / span 1; /* 4列目に1列分 */
    grid-row: 1 / span 1; /* 1行目に1行分 */
}

.video-4 {
    grid-column: 3 / span 2; /* 3列目から2列分 */
    grid-row: 2 / span 1; /* 2行目に1行分 */
}

/* メインタイトル */
.service-main-title {
    position: relative;
    z-index: 10;
    font-size: clamp(20px, 1rem + 3.5vw, 150px); /* モバイル30px〜デスクトップ70px */
    font-weight: 700;
    color: var(--color-white);
    text-align: center;
    text-transform: none;
    letter-spacing: 0.02em;
    margin: 0;
    padding: 0 20px;
    text-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
}

/* Nature Geekセクション */
.nature-geek-section {
    padding: var(--spacing-2xl) 0 20vh;
    position: relative;
}

.nature-geek-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--padding-container);
    text-align: center;
}

/* Nature Geekタイトル */
.nature-geek-title {
    font-size: var(--font-size-4xl);
    /* font-size: clamp(50px, calc(50px + (70 - 50) * (100vw - 375px) / (1440 - 375)), 70px); */
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    margin: 0 0 30px;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    flex-direction: row;
}

/* Nature Geekリンク */
.nature-geek-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nature-geek-link:hover {
    transform: translateX(5px);
}

/* 説明文 */
.nature-geek-description {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.8;
    color: var(--color-white);
    margin: 0 0 50px;
}

/* ポップアップトリガーボタンは共通スタイルを使用 */

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .service-hero {
        height: 70vh;
        min-height: 600px; /* 回転したタイトルが収まるように高さを増加 */
    }
    
    /* モバイル版動画グリッド */
    .video-grid-background {
        grid-template-columns: repeat(2, 1fr); /* モバイル: 2列 */
        grid-template-rows: repeat(3, 1fr); /* モバイル: 3行 */
    }
    
    /* モバイル版動画配置 */
    .video-1 {
        grid-column: 1 / span 2; /* 1列目から2列分 */
        grid-row: 1 / span 1; /* 1行目に1行分 */
    }
    
    .video-2 {
        grid-column: 1 / span 1; /* 1列目に1列分 */
        grid-row: 2 / span 1; /* 2行目に1行分 */
    }
    
    .video-3 {
        grid-column: 2 / span 1; /* 2列目に1列分 */
        grid-row: 2 / span 1; /* 2行目に1行分 */
    }
    
    .video-4 {
        grid-column: 1 / span 2; /* 1列目から2列分 */
        grid-row: 3 / span 1; /* 3行目に1行分 */
    }
    
    .service-main-title {
        position: absolute;
        left: 50px; /* 画面左端から適切な距離に配置 */
        top: 50%; /* 上下中央配置 */
        transform: translate(-50%, -50%) rotate(-90deg); /* 中央配置 + 反時計回りに90度回転 */
        transform-origin: center center; /* 回転の中心点を中央に戻す */
        white-space: nowrap; /* テキストの改行を防ぐ */
        z-index: 15; /* 動画の上に表示 */
    }
    
    .nature-geek-description {
        font-size: 1rem;
        margin-bottom: 40px;
    }
    
    .popup-content {
        padding: 40px 20px;
    }
    
    .popup-title {
        font-size: 1.5rem;
        margin-bottom: 30px;
    }
    
    .service-buttons {
        flex-direction: column;
        gap: 20px;
    }
    
    .service-button {
        min-width: 100%;
    }
}

/* テンポラリー：動画が無い場合の代替背景（デスクトップのみ） */
@media (min-width: 769px) {
    .video-grid-background:not(:has(video[src])) {
        background: linear-gradient(45deg, #333 25%, #444 25%, #444 50%, #333 50%, #333 75%, #444 75%, #444);
        background-size: 40px 40px;
        animation: backgroundMove 2s linear infinite;
    }

    @keyframes backgroundMove {
        0% {
            background-position: 0 0;
        }
        100% {
            background-position: 40px 40px;
        }
    }
}

/* ==========================================================================
   レスポンシブ対応
   ========================================================================== */

@media (max-width: 768px) {
    /* モバイル用静止画フォールバック */
    .video-grid-background {
        /* 動画グリッドを無効化 */
        display: block;
        grid-template-columns: none;
        grid-template-rows: none;
        
        /* 軽量静止画背景を設定 */
        background: 
            url('../images/video-bg.webp');
        background-size: cover !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        background-blend-mode: multiply, normal, normal !important;
    }
    
    /* モバイル: 全ての動画を非表示 */
    .grid-video {
        display: none !important;
    }
    
    /* サービスタイトルのモバイル調整 */
    .service-main-title {
        font-size: clamp(24px, 1rem + 4vw, 45px);
        padding: 0 20px;
        text-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
        line-height: 1.2;
    }
    
    /* Nature Geekセクション - モバイル調整 */
    .nature-geek-section {
        padding: 60px 0;
    }
    
    .nature-geek-title a {
        margin-bottom: 25px;
        flex-direction: column;  /* 上下配置 */
        gap: 0;                  /* 余白なし */
    }
    
    
    .nature-geek-description {
        font-size: 1rem;
        line-height: 1.7;
        margin-bottom: 40px;
        text-align: justify;
    }
    
    .trigger-knob {
        width: 70px;
        height: 70px;
    }
    
    .trigger-text {
        font-size: 1.1rem;
    }
}

/* ポップアップオーバーレイ */
.service-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.service-popup-overlay[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

/* ポップアップコンテンツ */
.popup-content {
    position: relative;
    background: var(--color-bg-base);
    border-radius: 0;
    padding: 10rem 2rem;
    min-width: 50vw;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    /* グラデーションオーバーレイを追加 */
    background-image: var(--gradient-overlay);
}

.service-popup-overlay[aria-hidden="false"] .popup-content {
    transform: scale(1);
}

/* 閉じるボタン */
.popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    outline: none;
    padding: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 1;
}

.popup-close:hover {
    transform: scale(1.1);
}

.popup-close svg {
    width: 24px;
    height: 24px;
}

/* ポップアップ内部 */
.popup-inner {
    text-align: center;
    position: relative;
    z-index: 1;
}

.popup-title {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-white);
    margin: 0 0 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* サービスボタンコンテナ */
.service-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

/* サービスボタン */
.service-button {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    padding: 1rem 3rem;
    background: transparent;
    color: var(--color-white);
    text-decoration: none;
    font-size: var(--font-size-3xl);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid #D9D9D9;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

/* ボタンテキスト */
.service-button-text {
    flex: 1;
    text-align: center;
}

/* リンクアイコン */
.service-button svg {
    width: 1rem;
    height: 1rem;
    margin-left: auto;
}

/* ORGANICボタン */
.organic-button {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.organic-button:hover {
    background: var(--color-accent);
    color: var(--color-white);
}

.organic-button svg {
    color: var(--color-accent);
}

.organic-button:hover svg {
    color: var(--color-white);
}

/* RECYCLEボタン */
.recycle-button {
    border-color: var(--color-main);
    color: var(--color-main);
}

.recycle-button:hover {
    background: var(--color-main);
    color: var(--color-white);
}

.recycle-button svg {
    color: var(--color-main);
}

.recycle-button:hover svg {
    color: var(--color-white);
}

/* モバイル対応 */
@media (max-width: 768px) {
    .popup-content {
        width: 95%;
        padding: 10rem 1rem;
    }
    
    .service-button {
        padding: 0.75rem 2rem;
        font-size: var(--font-size-xl);
    }
}

/* ==========================================================================
   PROJECTSセクション
   ========================================================================== */

.projects-section {
    padding: var(--spacing-2xl) 0;
    background: var(--color-white);
    background-image: var(--gradient-overlay);
    position: relative;
    overflow: visible; /* レコード盤が飛び出せるように */
    transition: background-color 0.4s ease; /* ホバー時の色変化アニメーション */
}

.projects-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--padding-container);
    overflow: visible; /* レコード盤が飛び出せるように */
}

/* セクションタイトル */
.projects-title {
    font-family: var(--font-heading);
    font-size: var(--font-size-4xl);
    font-weight: 700;
    color: #fff;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 3rem;
    mix-blend-mode: difference;
}

/* 記事一覧グリッド */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem 5%; /* 横の余白を広げてレコード盤が飛び出せるスペースを確保 */
    margin-bottom: 3rem;
    overflow: visible;
}

/* 記事アイテム */
.project-item {
    position: relative;
    background: transparent;
    border: none;
    display: block;
    text-decoration: none;
    width: 90%;
}

/* プロジェクトサムネイル */
.project-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-bottom: 1rem;
    background-color: #FFF9E6;
    overflow: hidden; /* ジャケット画像のみをクリップ */
    z-index: 2; /* レコード盤より前面に */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* レコード盤（背景） */
.project-record {
    position: absolute;
    top: 5%;
    left: 10%;
    width: 90%;
    aspect-ratio: 1 / 1; /* 正方形を維持 */
    object-fit: cover;
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1; /* ジャケットの後ろに配置 */
    transform: translateX(15%); /* 初期状態：15%だけ見える */
}

/* プロジェクト画像（前面） */
.project-image {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    mix-blend-mode: multiply;
    z-index: 3; /* 最前面 */
    filter: saturate(0.3);
    
    /* フォールバック：古いブラウザやカスタムサイズが生成されていない場合の対応 */
    min-height: 200px;
    background-color: #f5f5f5;
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                      linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                      linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* ホバー時の動作 */
.project-item:hover .project-record {
    transform: translateX(50%); /* 50%まで飛び出す */
}

/* タッチデバイス対応 */
@media (hover: none) {
    .project-item:active .project-record {
        transform: translateX(50%);
    }
}

/* プロジェクト情報 */
.project-info {
    width: 100%;
    color: #fff;
    font-size: 1rem;
    position: relative;
    z-index: 2; /* レコード盤より前面に */
    mix-blend-mode: difference;
}

/* 日付 */
.project-date {
    font-family: var(--font-navigation);
    font-weight: 600;
    border-bottom: 1px solid #fff;
    padding-bottom: 0.25rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* プロジェクト名 */
.project-name {
    font-family: var(--font-japanese);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    color: #fff;
    
    /* 2行まで表示、以降は... */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* アーカイブ誘導ボタン */
.projects-cta {
    text-align: center;
}

/* アーカイブ誘導ボタンは共通スタイルを使用 */

/* モバイル対応 */
@media (max-width: 768px) {
    .projects-section {
        width: 100vw;
        overflow-x: hidden;
    }
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem 5%; /* 横の余白を確保 */
    }
    
    .projects-title {
        margin-bottom: 2rem;
    }
    
    .project-info {
        font-size: 0.9rem;
    }
    
    .project-name {
        font-size: 0.9rem;
    }
    
    /* モバイルではレコード盤の飛び出しを調整 */
    .project-record {
        transform: translateX(15%); /* 初期状態：10%だけ見える */
    }
    
    .project-item:hover .project-record,
    .project-item:active .project-record {
        transform: translateX(40%); /* 40%まで飛び出す */
    }
}

/* ==========================================================================
   プロジェクトカラーホバー効果
   ========================================================================== */

/* タッチデバイスでのアクティブ状態 */
.project-item.touch-active .project-record {
    transform: translateX(50%);
}

/* ホバー時のプロジェクトアイテムの強調 */
.project-item {
    transition: transform 0.3s ease;
}

/* タイトルとプロジェクト情報のトランジション */
.projects-title,
.project-info {
    transition: all 0.4s ease;
}

/* ==========================================================================
   COMPANY PROFILEセクション
   ========================================================================== */

.company-profile-section {
    position: relative;
    background: var(--color-bg-base);
    background-image: var(--gradient-overlay);
    padding: var(--spacing-2xl) 0 15vh;
    border-left: 50px solid var(--color-main);
    z-index: 5; /* パララックス画像より下に配置 */
}

.company-profile-container {
    width: clamp(375px, 50vw, 1600px);
    margin: 0 auto;
    padding: 0 2rem;
}

/* セクションタイトル */
.company-profile-title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 0 30px;
    text-align: center;
    color: var(--color-white);
}

/* 会社情報テーブル */
.company-profile-content {
    width: 100%;
}

.company-profile-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--color-white);
    font-weight: 700;
}

.company-profile-row {
    border-bottom: 1px solid var(--color-accent);
}

.company-profile-row:last-child {
    border-bottom: none;
}

.company-profile-label {
    padding: 1.5rem 2rem 1.5rem 0;
    text-align: left;
    vertical-align: top;
    font-weight: 700;
    color: var(--color-white);
    border: none;
    width: 30%;
}

.company-profile-value {
    padding: 1.5rem 0 1.5rem 2rem;
    text-align: left;
    vertical-align: top;
    font-weight: 700;
    color: var(--color-white);
    border: none;
    width: 70%;
    line-height: 1.6;
    word-break: keep-all;
    overflow-wrap: anywhere;
    line-break: strict;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .company-profile-section {
        border-left: 5px solid var(--color-main);
    }
    
    .company-profile-title {
        font-size: var(--font-size-2xl);
        margin-bottom: 2rem;
    }
    
    .company-profile-label {
        padding: 1rem 1rem 1rem 0;
        width: 35%;
        font-size: 0.9rem;
    }
    
    .company-profile-value {
        padding: 1rem 0 1rem 1rem;
        width: 65%;
        font-size: 0.9rem;
    }
}

/* ==========================================================================
   事務所写真セクション
   ========================================================================== */

.office-section {
    position: relative;
    width: 100vw;
    min-height: 50vh;
    /* 背景画像: fv-bg.webpを解像度別に設定 */
    background-color: var(--color-white);
    background-image: url('../images/fv-bg@05x.webp'); /* デフォルト: モバイル用軽量版 */
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-blend-mode: multiply;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl) 0;
    z-index: 15;
}

/* タブレット・デスクトップ: 標準版 */
@media (min-width: 769px) {
    .office-section {
        background-image: url('../images/fv-bg.webp');
    }
}

/* 高解像度ディスプレイ: 2倍解像度版 */
@media (min-width: 769px) and (-webkit-min-device-pixel-ratio: 2),
       (min-width: 769px) and (min-resolution: 192dpi),
       (min-width: 769px) and (min-resolution: 2dppx) {
    .office-section {
        background-image: url('../images/fv-bg@2x.webp');
    }
}

/* モバイル高解像度ディスプレイ用（必要に応じて） */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2),
       (max-width: 768px) and (min-resolution: 192dpi),
       (max-width: 768px) and (min-resolution: 2dppx) {
    .office-section {
        background-image: url('../images/fv-bg.webp');
    }
}

.office-container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--padding-container);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* デスクトップ: 左右配置 */
@media (min-width: 769px) {
    .office-container {
        width: 90%;
        flex-direction: row;
        gap: var(--spacing-lg);
        align-items: stretch;
    }
}

/* ==========================================================================
   事務所アイテム
   ========================================================================== */

.office-item {
    position: relative;
    width: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* デスクトップ: 左右均等配置 */
@media (min-width: 769px) {
    .office-item {
        flex: 1;
    }
}

/* パララックス効果 */
.office-image {
    width: 100%;
    height: 100%;
    background-color: #FFF9E6;
    aspect-ratio: 4/3;
 }

.office-picture { 
    width: 100%;
    height: 100%;
    position: relative;
    display: block;
    will-change: transform;
    z-index: 9;
}
 .office-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.7);
    mix-blend-mode: multiply;
}

/* テキスト */
.office-image {
    h3 {
        position: absolute;
        z-index: 17;
        bottom: -30px;
        margin-bottom: 0;
        color: var(--color-white);
        right: 5px;
    }
 }
 @media (max-width: 768px) {
    .office-image {
        h3 {
            bottom: 0;
        }
    }
 }

/* ==========================================================================
   レスポンシブ調整
   ========================================================================== */

@media (max-width: 768px) {
    .office-section {
        min-height: auto;
        padding: var(--spacing-lg) 0;
    }
    
    .office-container {
        gap: var(--spacing-lg);
    }        
}

@media (max-width: 480px) {
    .office-section {
        padding: var(--spacing-md) 0;
    }
    
    .office-container {
        padding: 0 var(--spacing-md);
        gap: var(--spacing-lg);
    }
}

/* ==========================================================================
   アニメーション
   ========================================================================== */

/* 初期表示用アニメーション（GSAPパララックス開始前に実行） */
.office-item {
    opacity: 0;
    transform: translateY(30px);
    animation: officeFadeIn 0.8s ease forwards;
}

.office-wakayama {
    animation-delay: 0.2s;
}

.office-tokyo {
    animation-delay: 0.4s;
}

@keyframes officeFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* GSAPパララックス開始後はアニメーションを無効化 */
.office-item.parallax-active {
    animation: none;
    opacity: 1;
    transform: none;
}

/* ==========================================================================
   アクセシビリティ
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .office-item {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .office-item:hover {
        transform: none;
    }
    
    .office-image {
        transition: none;
    }
    
    .office-item:hover .office-image {
        transform: none;
    }
}

/* ==========================================
   プロジェクトカラーホバー機能対応CSS
   ========================================== */

/* アーカイブボタンのテキスト（mix-blend-mode対応） */
.knob-trigger--black .trigger-text {
    color: #fff; /* ★白色ベース */
    mix-blend-mode: difference; /* ★背景色に応じて自動で色変化 */
}

/* タッチデバイス対応 */
.project-item.touch-active {
    transform: scale(0.98);
    transition: transform 0.2s ease;
}

/* mix-blend-modeの動作説明:
   - 白色テキスト（#fff）にmix-blend-mode: differenceを適用
   - 背景が白の場合：白 - 白 = 黒（テキストが黒く表示）
   - 背景が色付きの場合：白 - 背景色 = 反転色（コントラストが効く色で表示）
   - JavaScriptでの色制御が不要になり、自動的に最適な色で表示される */