/* ==========================================
   site.css — 全ページ共通スタイル
   リセット・変数・ナビ基本・セクション・フッター・
   カードグリッドMQ・ユーティリティ・View Transitions
   各ページの style.css より先に読み込むこと
   実装方針: /architecture.md
   ========================================== */

/* ==========================================
   リセット & 基本設定
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3e5e9b;
    --secondary-color: #ff20ca;
    --dark-bg: #0a0a0a;
    --darker-bg: #161616;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-gradient: linear-gradient(135deg, #3e5e9b 0%, #ff20ca 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    scrollbar-color: rgba(128, 90, 213, 0.5) rgba(255, 255, 255, 0.04);
    scrollbar-gutter: stable;
}

/* モバイルはthin、デスクトップはauto（デフォルト幅） */
@media (width <= 767px) {
    html { scrollbar-width: thin; }
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    word-break: auto-phrase;
    overflow-wrap: break-word;
}

/* タイポグラフィ最適化 */
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

/* アクセシビリティ：キーボードフォーカスインジケーター */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* ==========================================
   アニメーション背景（Canvas）
   ========================================== */
#background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: var(--darker-bg);
}

/* ==========================================
   ナビゲーション（ベース）
   各ページの独自ナビスタイルで上書き可能
   ========================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(10, 10, 10, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);

    &.scrolled {
        background: rgba(10, 10, 10, 0.7);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    }
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Orbitron', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-decoration: none;
    transition: opacity 0.3s ease;

    &:hover { opacity: 0.8; }
    &::after { display: none !important; }
}

.logo-main {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-text {
    color: var(--text-primary);
}

.logo-subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #808080;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    list-style: none;

    & a, & .nav-dropdown-toggle {
        color: var(--text-primary);
        text-decoration: none;
        font-weight: 500;
        transition: color 0.3s ease;
        position: relative;

        &::after {
            content: '';
            position: absolute;
            bottom: -5px;
            left: 0;
            width: 0;
            height: 2px;
            background: var(--accent-gradient);
            transition: width 0.3s ease;
        }
        &:hover {
            color: var(--secondary-color);
            &::after { width: 100%; }
        }
        &.active {
            color: var(--secondary-color);
            &::after { width: 100%; }
        }
    }
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;

    & span {
        width: 25px;
        height: 3px;
        background: var(--text-primary);
        transition: all 0.3s ease;
        border-radius: 3px;
    }
}

/* ==========================================
   セクション共通
   ========================================== */
section {
    padding: 5rem 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    padding-bottom: 1.5rem;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.6);
    --line-width: 0px;

    & .title-jp {
        display: block;
        font-family: 'Noto Sans JP', sans-serif;
        font-size: clamp(1.6rem, 4vw, 2.5rem);
        font-weight: 700;
        color: #ffffff;
        margin-top: 0.5rem;
        letter-spacing: 0.05em;
    }

    &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 200px; /* 非対応ブラウザ: 常時表示。対応ブラウザ: @keyframes underlineGrow で上書き */
        height: 4px;
        background: var(--accent-gradient);
        border-radius: 2px;
    }
}

/* カードタイトル共通サイズ（MQ上書き禁止、clamp()のみで完結） */
.division-title,
.strength-title,
.philosophy-card-title,
.policy-title {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

/* ==========================================
   フッター
   ========================================== */
.footer {
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 4rem 2rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-company-name {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.1em;
}

.footer-brand-en {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.05em;
}

.footer-tagline {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0.8;
}

.footer-heading {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;

    & li {
        font-size: 0.85rem;
        color: rgba(255, 255, 255, 0.5);
    }

    & a {
        color: rgba(255, 255, 255, 0.5);
        text-decoration: none;
        transition: color 0.3s ease;

        &:hover { color: var(--secondary-color); }
    }
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.5rem;
    text-align: center;
}

.footer-ai-note {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}
.copyright {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ==========================================
   Scroll to Top ボタン
   ========================================== */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--primary-color) 40%, transparent);
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.3s, border-color 0.3s;
    transition-behavior: allow-discrete;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;

    &.visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    &:hover {
        background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 60%, transparent), color-mix(in srgb, var(--secondary-color) 40%, transparent));
        border-color: color-mix(in srgb, var(--secondary-color) 60%, transparent);
        transform: translateY(-3px);
    }
}

/* @starting-style: 初期遷移の明示（86.6%対応） */
@starting-style {
    .scroll-top-btn.visible {
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
    }
}

/* ==========================================
   Reveal アニメーション（Scroll-driven Animations）
   CSS animation-timeline: view() でスクロール連動表示
   非対応ブラウザ（Firefox）ではアニメなし＝即表示
   translate プロパティ使用（hover の transform と衝突回避）
   ========================================== */
@keyframes revealY {
    from { opacity: 0; translate: 0 var(--reveal-y, 200px); }
    to   { opacity: 1; translate: 0 0; }
}
@keyframes revealX {
    from { opacity: 0; translate: var(--reveal-x, -50px) 0; }
    to   { opacity: 1; translate: 0 0; }
}

@supports (animation-timeline: view()) {
    /* 縦方向 reveal（カード・タイトル・パネル・フッター） */
    .section-title,
    .division-card,
    .strength-card,
    .tool-card,
    .tech-card,
    .example-card,
    .contact-item,
    .philosophy-card,
    .glossary-card,
    .faq-item,
    .info-panel,
    .policy-panel,
    .policy-content p,
    .footer {
        animation-name: revealY;
        animation-timing-function: linear;
        animation-fill-mode: both;
        animation-duration: 0.5s;
        animation-timeline: view();
        animation-range: entry 0% entry 60%;
    }

    /* 横方向 reveal（flow-step） */
    .flow-step {
        animation-name: revealX;
        animation-timing-function: linear;
        animation-fill-mode: both;
        animation-duration: 0.5s;
        animation-timeline: view();
        animation-range: entry 0% entry 60%;
    }

    /* 要素別 --reveal-y 調整 */
    .section-title { --reveal-y: 150px; }
    .policy-panel  { --reveal-y: 250px; }
    .policy-content p { --reveal-y: 120px; }
    .footer        { --reveal-y: 120px; }

    /* section-title 下線もスクロール連動で伸ばす */
    .section-title::after {
        animation-name: underlineGrow;
        animation-timing-function: linear;
        animation-fill-mode: both;
        animation-duration: 0.5s;
        animation-timeline: view();
        animation-range: entry 10% entry 60%;
    }
}

@keyframes underlineGrow {
    from { width: 0; }
    to   { width: 200px; }
}

/* ==========================================
   ndocs ボタン（対角角丸）
   ========================================== */
.ndocs-lead {
    font-size: clamp(1.2rem, 2.8vw, 1.7rem);
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.5rem;
}
.ndocs-sub {
    font-size: 1.05rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0;
}
.ndocs-btn {
    margin-top: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 2.5rem;
    color: #ffffff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(139, 92, 246, 0.3));
    border: 2px solid rgba(99, 102, 241, 0.6);
    border-radius: 20px 4px 20px 4px;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;

    &:hover {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(139, 92, 246, 0.5));
        border-color: #818cf8;
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4),
                    0 0 40px rgba(139, 92, 246, 0.2);
        transform: translateY(-2px);
    }
}

/* ==========================================
   Highlight-text 文字送りアニメーション（GSAP排除・CSS版）
   JS が各文字に --char-i を設定、.active 付与で再生
   ========================================== */
.highlight-text {
    & .char {
        opacity: 0;
        display: inline-block;
    }

    &.active {
        animation: highlight-pulse 0.3s ease 0.2s;

        & .char {
            animation: char-fade-in 0.05s ease forwards;
            animation-delay: calc(var(--char-i, 0) * 0.03s);
        }
    }
}
@keyframes char-fade-in {
    to { opacity: 1; }
}
@keyframes highlight-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ==========================================
   アニメーション（共通）
   ========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* fade-in-up: ヒーロー要素は最初から表示（VTフェードと競合するため廃止）
   トップページのローディング画面後のアニメーションは loading screen JS 側で管理 */
.fade-in-up {
    opacity: 1;
    animation: none;
}

/* ==========================================
   View Transitions（ページ遷移）
   @view-transition + ルート遷移アニメーション
   view-transition-name の付与は nav.css / 各 style.css で行う
   ========================================== */
@view-transition {
    navigation: auto;
}

/* ページ全体の遷移: 旧ページは即消し、新ページだけフェードイン */
/* ダーク背景で黒フェードが目立たないようにする */
::view-transition-old(root) {
    animation: none;
}
::view-transition-new(root) {
    animation: vt-fade-in 0.2s ease-out;
}
@keyframes vt-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ==========================================
   レスポンシブ: セクション・フッター
   ========================================== */
@media (width <= 767px) {
    section { padding: 3rem 1rem; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
    .section-title {
        font-size: clamp(1.1rem, 3.5vw, 1.6rem);
        margin-bottom: 2rem;
        padding-bottom: 1rem;

        & .title-jp { font-size: clamp(1.3rem, 5.5vw, 2rem); }
    }
}

@media (width <= 480px) {
    .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* ==========================================
   Strength カード — 全ページ共通ベース
   各カードに --card-color を設定するだけで
   ボーダー・背景ティント・アイコン・バッジが連動
   ========================================== */
.strength-section {
    background: transparent;
    padding: 5rem 2rem;
    position: relative;
}

.strength-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
    max-width: 1400px;
    margin-inline: auto;
}

.strength-card {
    --card-color: var(--primary-color);
    background: linear-gradient(135deg, color-mix(in srgb, var(--card-color) 8%, transparent) 0%, rgba(10, 15, 30, 0.85) 60%);
    border: 2px solid color-mix(in srgb, var(--card-color) 20%, transparent);
    border-radius: 20px;
    padding: 2.5rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6),
                0 8px 16px rgba(0, 0, 0, 0.4);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));

    &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.02);
        z-index: -1;
        border-radius: 20px;
    }

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, color-mix(in srgb, var(--card-color) 15%, transparent) 0%, color-mix(in srgb, var(--card-color) 5%, transparent) 100%);
        opacity: 0;
        transition: opacity 0.4s ease;
        z-index: -1;
        border-radius: 20px;
    }

    &:hover {
        border-color: color-mix(in srgb, var(--card-color) 40%, transparent);
        box-shadow: 0 20px 60px color-mix(in srgb, var(--card-color) 10%, transparent);
        transform: scale(1.02);

        &::before {
            opacity: 1;
        }
    }

    & > * {
        position: relative;
        z-index: 1;
    }
}

.strength-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.strength-icon {
    width: 70px;
    height: 70px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--card-color), color-mix(in srgb, var(--card-color) 70%, white));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 10px 30px color-mix(in srgb, var(--card-color) 50%, transparent);
}

.strength-badge {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: color-mix(in srgb, var(--card-color) 20%, transparent);
    border: 1px solid var(--card-color);
    color: color-mix(in srgb, var(--card-color) 70%, white);
}

.strength-content {
    display: flex;
    flex-direction: column;
}

.strength-title {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
    margin-bottom: 0.3rem;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
}

.strength-name-en {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.3;
}

.strength-description {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.8;
    margin-top: 1rem;
}

/* ==========================================
   レスポンシブ: カードグリッド共通
   strength ベースは上記で定義済み。ここでは列数を調整。

   1列→2列の切り替え基準:
     説明文付きカード（strength/tool/tech）= 600px+
     コンパクトカード（将来用）           = 480px+
   ========================================== */

/* === 600px以上: 全カード2列（説明文が折り返されすぎない幅） === */
@media (width >= 600px) {
    .strength-grid,
    .tools-grid,
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === 960px以上: strength/tools 3列 === */
@media (width >= 960px) {
    .strength-grid,
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === 1100px以上: tech 4列 === */
@media (width >= 1100px) {
    .tech-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================
   アクセシビリティ: モーション軽減
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    /* Scroll-driven reveal アニメーション無効化 */
    .section-title, .division-card, .strength-card, .tool-card,
    .tech-card, .example-card, .contact-item, .philosophy-card,
    .glossary-card, .faq-item, .info-panel, .policy-panel,
    .policy-content p, .footer, .flow-step,
    .section-title::after {
        animation: none;
    }

    /* 文字送り・パルスアニメーション無効化 */
    .highlight-text .char { opacity: 1; }
    .highlight-text.active .char,
    .highlight-text.active { animation: none; }

    /* View Transitions 無効化 */
    ::view-transition-new(root) { animation: none; }

    /* fade-in-up 無効化 */
    .fade-in-up { animation: none; }
}
