/* ======== Liquid Glass Design & Apple-style UI (Updated) ======== */

/* ----------------------------------------------
 * 基本変数定義
 * ---------------------------------------------- */
:root {
    --primary-blue-start: #007aff;
    --primary-blue-end: #5ac8fa;
    --primary-gradient: linear-gradient(135deg, var(--primary-blue-start) 0%, var(--primary-blue-end) 100%);
    --text-gradient-up: linear-gradient(to top, #5ac8fa, #007aff);

    --text-dark: #1d1d1f;
    --text-light: #6e6e73;

    --glass-bg: rgba(242, 242, 247, 0.75);
    --glass-border-color: rgba(255, 255, 255, 0.6);
    --glass-blur: blur(20px);
    --glass-saturate: saturate(180%);

    --border-radius: 20px;
    --soft-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --soft-shadow-hover: 0 12px 40px 0 rgba(31, 38, 135, 0.15);
}

/* ----------------------------------------------
 * 基本スタイル
 * ---------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: #ffffff;
    overflow-x: hidden;
}

/* ----------------------------------------------
 * ヘッダー
 * ---------------------------------------------- */
.header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-saturate) var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
    border-bottom: 1px solid var(--glass-border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    transition: box-shadow 0.3s ease;
}
.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo-section h1, .seiun-title {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo-section .subtitle {
    font-size: 0.875rem;
    color: var(--primary-blue-start);
    font-weight: 500;
}
.seiun-title {
   font-size: 2rem;
}

/* ----------------------------------------------
 * ハンバーガーメニュー
 * ---------------------------------------------- */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
}
.hamburger span {
    width: 30px;
    height: 3px;
    background: var(--primary-blue-start);
    border-radius: 10px;
    transition: all 0.3s ease-in-out;
    position: relative;
    transform-origin: 1px;
}
.hamburger.active span:first-child { transform: rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: translateX(20px); }
.hamburger.active span:last-child { transform: rotate(-45deg); }

/* ----------------------------------------------
 * ナビゲーション
 * ---------------------------------------------- */
.nav-container {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-saturate) var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur);
    border-bottom: 1px solid var(--glass-border-color);
    position: sticky;
top: 0;
    width: 100%;
    z-index: 999;
    transition: all 0.3s ease;
}
.main-nav { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.nav-list { display: flex; list-style: none; margin: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.nav-list::-webkit-scrollbar { display: none; }
.nav-link { display: block; padding: 1rem 1.5rem; color: var(--text-dark); text-decoration: none; transition: all 0.3s ease; position: relative; white-space: nowrap; font-size: 0.9rem; font-weight: 500; }
.nav-link:hover { color: var(--primary-blue-start); background: rgba(255, 255, 255, 0.3); }
.nav-link.active { color: var(--primary-blue-start); font-weight: 600; }
.nav-link.active::after { content: ''; position: absolute; bottom: 0; left: 1.5rem; right: 1.5rem; height: 3px; background: var(--primary-gradient); border-radius: 3px; }
@media (min-width: 992px) {
    .nav-list {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: visible;
    }
}
.additional-nav { background: rgba(242, 242, 247, 0.3); padding: 0.5rem 0; }
.additional-nav-content { max-width: 1200px; margin: 0 auto; padding: 0 1rem; font-size: 0.875rem; }
.additional-nav a { color: var(--text-dark); text-decoration: none; margin-right: 1.5rem; transition: color 0.3s ease; }
.additional-nav a:hover { color: var(--primary-blue-start); }

/* ----------------------------------------------
 * モバイルナビゲーション
 * ---------------------------------------------- */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .seiun-title { display: none; }
    .nav-container { position: fixed; top: 0; right: -100%; width: 280px; height: 100vh; background: var(--glass-bg); backdrop-filter: var(--glass-saturate) var(--glass-blur); -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur); border-left: 1px solid var(--glass-border-color); transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); box-shadow: none; }
    .nav-container.active { right: 0; }
    .nav-list { flex-direction: column; padding-top: 80px; }
    .nav-link { padding: 1rem 2rem; border-bottom: 1px solid rgba(0,0,0,0.05); }
    .overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.2); z-index: 998; opacity: 0; transition: opacity 0.3s ease; }
    .overlay.active { display: block; opacity: 1; }
}

/* ----------------------------------------------
 * ヒーローセクション
 * ---------------------------------------------- */
.hero { position: relative; min-height: 400px; display: flex; align-items: center; justify-content: center; text-align: center; color: white; padding: 2rem; }
.hero-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(rgba(0, 80, 150, 0.6), rgba(0, 122, 255, 0.5)), url('img/building.jpg') center/cover no-repeat; z-index: -1; }
.hero-content { max-width: 800px; margin: 0 auto; }
.hero h2 { font-size: 2.5rem; margin-bottom: 1rem; animation: fadeInUp 0.8s ease; }
.hero p { font-size: 1.125rem; opacity: 0.95; animation: fadeInUp 0.8s ease 0.2s both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ----------------------------------------------
 * メインコンテンツ & カードスタイル
 * ---------------------------------------------- */
.main-content { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 768px) { .main-content { grid-template-columns: 280px 1fr; } }
.content-section, .sidebar, .facility-card, .contact-card { background: var(--glass-bg); backdrop-filter: var(--glass-saturate) var(--glass-blur); -webkit-backdrop-filter: var(--glass-saturate) var(--glass-blur); border-radius: var(--border-radius); border: 1px solid var(--glass-border-color); box-shadow: var(--soft-shadow); padding: 2rem; transition: all 0.4s ease; }
.content-section:hover, .sidebar:hover, .facility-card:hover { box-shadow: var(--soft-shadow-hover); transform: translateY(-5px); }

/* ----------------------------------------------
 * サイドバー
 * ---------------------------------------------- */
.sidebar { padding: 1.5rem; height: fit-content; }
.sidebar h3 { color: var(--primary-blue-start); font-size: 1.125rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(0,0,0,0.1); }
.sidebar-links { list-style: none; margin-bottom: 2rem; }
.sidebar-links li { margin-bottom: 0.5rem; }
.sidebar-links a { display: block; padding: 0.75rem; color: var(--text-dark); text-decoration: none; border-radius: 10px; transition: all 0.3s ease; }
.sidebar-links a:hover { background: rgba(0, 122, 255, 0.1); color: var(--primary-blue-start); transform: translateX(4px); }
.cta-button { display: block; background: var(--primary-gradient); color: white; text-align: center; padding: 1rem; border-radius: 15px; text-decoration: none; font-weight: 600; transition: all 0.3s ease; margin-bottom: 2rem; border: none; box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3); }
.cta-button:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 25px rgba(0, 122, 255, 0.4); }
.contact-card { background: rgba(0, 122, 255, 0.05); padding: 1.5rem; font-size: 0.875rem; line-height: 1.8; }

/* ----------------------------------------------
 * コンテンツセクション
 * ---------------------------------------------- */
.content-section { margin-bottom: 2rem; animation: fadeIn 0.6s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--text-gradient-up);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid;
    border-image: var(--primary-gradient) 1;
    display: inline-block;
}
.content-text { color: var(--text-dark); margin-bottom: 1.5rem; line-height: 1.8; }
.content-with-image { display: grid; grid-template-columns: 1fr; gap: 2rem; align-items: start; }
@media (min-width: 768px) { .content-with-image { grid-template-columns: 1fr 300px; } .content-with-image.reverse { grid-template-columns: 300px 1fr; } .content-with-image.reverse .image-container { order: -1; } }
.image-container { position: relative; border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--soft-shadow); }
.image-container img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder-image { background: rgba(230,230,230,0.5); border: 1px dashed rgba(0,0,0,0.2); padding: 40px; text-align: center; color: var(--text-light); min-height: 200px; display: flex; align-items: center; justify-content: center; font-size: 14px; border-radius: var(--border-radius); }
.facilities-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.facility-card h4 { color: var(--primary-blue-start); margin-bottom: 0.5rem; }
.facility-card ul { padding-left: 20px; margin-top: 1rem; }

/* 説明リスト */
.definition-list {
    margin-top: 1rem;
}
.definition-list-item {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.5em;
}
.definition-list-item dt {
    flex-shrink: 0;
    font-weight: bold;
    white-space: nowrap;
}
.definition-list-item dd {
    margin-left: 0.5em;
}

/* ----------------------------------------------
 * タイムライン (沿革)
 * ---------------------------------------------- */
.timeline { 
    position: relative; 
    padding-left: 2rem;
    border-left: 2px solid;
    border-image: var(--primary-gradient) 1;
    margin-top: 2rem;
}
.timeline-item { position: relative; margin-bottom: 2rem; padding-left: 1.5rem; }
.timeline-item:last-of-type { margin-bottom: 0; }
.timeline-item::before { 
    content: ''; 
    position: absolute; 
    left: calc(-2rem - 11px);
    top: 4px;
    width: 14px; 
    height: 14px; 
    background: var(--primary-gradient); 
    border-radius: 50%; 
    border: 4px solid white; 
    z-index: 1;
}
.timeline-date { color: var(--primary-blue-start); font-weight: 600; margin-bottom: 0.5rem; }

/* ----------------------------------------------
 * フッター
 * ---------------------------------------------- */
.footer { background: var(--text-dark); color: #d1d1d6; padding: 3rem 1rem 1rem; margin-top: 4rem; border-top-left-radius: 30px; border-top-right-radius: 30px; }
.footer-content { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.footer-section h3 {
    margin-bottom: 1rem;
    font-weight: 600;
    background: var(--text-gradient-up);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
.footer-section a { color: #8e8e93; text-decoration: none; display: block; margin-bottom: 0.5rem; transition: color 0.3s ease; }
.footer-section a:hover { color: var(--primary-blue-end); }
.footer-bottom { text-align: center; padding-top: 2rem; border-top: 1px solid #3a3a3c; color: #8e8e93; font-size: 0.875rem; }

/* ----------------------------------------------
 * その他コンポーネント
 * ---------------------------------------------- */
.image-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin: 2rem 0; }
.gallery-item { border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--soft-shadow); transition: all 0.3s ease; position: relative; }
.gallery-item:hover { transform: scale(1.05) translateY(-5px); box-shadow: var(--soft-shadow-hover); }
.gallery-item img { width: 100%; height: 200px; object-fit: cover; display: block; }
.gallery-caption { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); color: white; padding: 0.75rem; font-size: 0.875rem; text-align: center; }

.founder-section { display: flex; align-items: start; gap: 2rem; flex-wrap: wrap; }
.founder-image { width: 150px; height: 200px; border-radius: var(--border-radius); overflow: hidden; box-shadow: var(--soft-shadow); }
.founder-image img { width: 100%; height: 100%; object-fit: cover; }
.founder-content { flex: 1; min-width: 300px; }

/* ----------------------------------------------
 * モバイル & アクセシビリティ
 * ---------------------------------------------- */
@media (max-width: 767px) { .hero { margin-top: 0; } .hero h2 { font-size: 1.75rem; } .content-section { padding: 1.5rem; } .sidebar { order: 2; } .main-content { margin-top: 1rem; } .founder-section { flex-direction: column; align-items: center; } .founder-image { margin-bottom: 1rem; } }
:focus { outline: 2px solid var(--primary-blue-start); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }


let current = 0;
let next = 1;
const bgEls = [
    document.querySelector('.hero-bg-1'),
    document.querySelector('.hero-bg-2')
];

// 初期設定
bgEls[0].style.backgroundImage = `linear-gradient(rgba(0,80,150,0.4),rgba(0,122,255,0.3)), url('${images[0]}')`;
bgEls[0].classList.add('show');

function fadeToNextImage() {
    // 切り替え先画像セット
    bgEls[next].style.backgroundImage = `linear-gradient(rgba(0,80,150,0.4),rgba(0,122,255,0.3)), url('${images[(current+1)%images.length]}')`;
    bgEls[next].classList.add('show');
    // 下の画像をフェードアウト
    bgEls[current].classList.remove('show');
    // current/nextを入れ替え
    let old = current;
    current = next;
    next = old;
}

setInterval(() => {
    fadeToNextImage();
}, 4000);