/* =========================================
   基本設定 & フォント
   ========================================= */
/* 音楽記号用Webフォント（Bravura）
   ちらつき防止のため font-display: block に変更
   Canvas描画時にフォントが未ロードで代替フォントが一瞬出るのを防ぐ */
@font-face {
    font-family: 'Bravura';
    src: url('https://cdn.jsdelivr.net/npm/@smufl/bravura@1.392.0/redist/bravura.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/npm/@smufl/bravura@1.392.0/redist/bravura.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

/* CSS変数は style.css で定義済み */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem 1rem;
    position: relative;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body::-webkit-scrollbar { display: none; }

/* =========================================
   背景・トランジションアニメーション
   ========================================= */
#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    /* will-changeはメモリ消費と再描画の兼ね合いでちらつきの原因になることがあるため、
       必要な場合のみ適用するようにスクリプト側で制御するか、ここでは外しておく */
    /* will-change: contents; */
}

.transition-overlay {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: #4fc3f7;
    z-index: 10002;
    pointer-events: none;
    will-change: transform;
}

.transition-text-wrapper {
    position: fixed;
    top: 49.5%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10003;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.transition-text-wrapper.show { opacity: 1; }

.transition-text {
    color: white;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 600;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.transition-overlay.slide-in { animation: slideIn 0.8s cubic-bezier(0.42, 0, 0.58, 1) forwards; }
.transition-overlay.slide-out { animation: slideOut 0.8s cubic-bezier(0.42, 0, 0.58, 1) forwards; }

@keyframes slideIn { from { left: -100%; } to { left: 0; } }
@keyframes slideOut { from { left: 0; } to { left: 100%; } }

.transition-overlay:not(.slide-in):not(.slide-out) { will-change: auto; }
.transition-text-wrapper:not(.show) { will-change: auto; }

/* =========================================
   レイアウト構造
   ========================================= */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.home-header {
    text-align: center;
    padding: 3rem 1rem;
    margin-bottom: 3rem;
    background: transparent;
    animation: fadeInUp 0.6s ease;
    position: relative;
    overflow: visible;
}

.home-header.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.home-header.fullscreen .site-catchcopy { display: none; }
.home-header.normal { position: relative; }

.home-container.hidden .main-navigation,
.home-container.hidden .enter-room-section {
    opacity: 0;
    pointer-events: none;
}

.home-container.show .main-navigation,
.home-container.show .enter-room-section {
    opacity: 1;
    animation: fadeIn 1s ease forwards;
    will-change: opacity;
}

.header-content {
    position: relative;
    z-index: 1;
}

.site-catchcopy {
    font-size: 0.9rem;
    color: var(--color-creation);
    margin-bottom: 0.5rem;
    font-weight: 400;
    opacity: 0.8;
}

.site-title {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 600;
    color: var(--color-primary-dark);
    margin: 0 0 0.5rem 0;
    letter-spacing: 0.5px;
    position: relative;
    display: inline-block;
    min-height: 2.5rem;
}

.title-animation,
.title-main {
    position: relative;
    display: inline-block;
    white-space: nowrap;
}

/* SEO対策: display: none を廃止し、positionとopacityで制御 */
.title-main {
    opacity: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    width: 100%;
}

.title-main.show {
    position: relative;
    left: auto;
    transform: none;
    pointer-events: auto;
    width: auto;
    animation: fadeInMain 1s ease forwards;
    will-change: opacity;
}

@keyframes fadeInMain { from { opacity: 0; } to { opacity: 1; } }

/* =========================================
   ナビゲーション
   ========================================= */
.main-navigation {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.navigation-hint {
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-primary-dark);
    margin-bottom: 0.2rem;
    text-shadow:
        -1px 0 0 rgba(255, 255, 255, 1),
        1px 0 0 rgba(255, 255, 255, 1),
        0 -1px 0 rgba(255, 255, 255, 1),
        0 1px 0 rgba(255, 255, 255, 1);
}

.nav-section[data-section="creation"] { --theme-color: var(--color-creation); }
.nav-section[data-section="review"]   { --theme-color: var(--color-review); }
.nav-section[data-section="works"]    { --theme-color: var(--color-works); }
.nav-section[data-section="about"]    { --theme-color: var(--color-about); }
.nav-section[data-section="other"]    { --theme-color: var(--color-other); }

.nav-section {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease;
}

.nav-section:first-of-type { margin-top: -0.7rem; }

.nav-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    transition: background 0.3s ease;
    background: var(--theme-color);
}

.nav-section:nth-child(n+2) {
    animation-delay: calc((var(--nth) - 1) * 0.1s);
}

.nav-section-header {
    padding: 1.5rem 2rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: background-color 0.3s ease;
    flex-wrap: nowrap;
}

.nav-section-header:focus {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

.nav-section-title {
    font-size: 1.3rem;
    color: var(--color-primary-dark);
    margin: 0;
    font-weight: 600;
    flex-shrink: 0;
    display: inline-block;
    background: rgba(255, 255, 255, 1);
    padding: 2px;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.nav-section-description {
    font-size: 0.85rem;
    color: var(--color-text-hint);
    opacity: 0.9;
    flex-grow: 0;
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(255, 255, 255, 1);
    padding: 2px;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.nav-section-header:hover .nav-section-title,
.nav-section-header:hover .nav-section-description,
.nav-section.active .nav-section-title,
.nav-section.active .nav-section-description {
    background: transparent;
}

.nav-section-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease, color 0.3s ease;
    flex-shrink: 0;
    color: var(--theme-color);
}

.nav-section.active .nav-section-icon { transform: rotate(180deg); }

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    background: rgba(242, 250, 255, 0.8);
    display: block !important;
    flex-direction: column !important;
}

.nav-section.active .nav-links {
    max-height: 500px;
    padding: 1rem 2rem 1.5rem 2rem;
}

.nav-links li { margin-bottom: 0.75rem; }
.nav-links li:last-child { margin-bottom: 0; }

.nav-links a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--color-creation);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 1);
    border-left: 3px solid transparent;
    font-weight: 500;
}

.nav-links a:hover {
    background: var(--color-border);
    color: var(--color-primary);
    padding-left: 1.5rem;
    border-left-color: var(--theme-color);
    border-bottom-color: var(--theme-color);
}

.nav-links a:focus {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

/* =========================================
   入室ボタン & その他
   ========================================= */
.enter-room-section {
    text-align: center;
    padding: 0rem 1rem;
    animation: fadeInUp 0.6s ease 0.6s both;
}

.enter-room-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.2rem 2.5rem;
    background: var(--color-primary);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.enter-room-button:visited {
    background: var(--color-primary);
    color: white;
}

.enter-room-button:hover {
    background: var(--color-primary);
    box-shadow: 0 6px 16px rgba(79, 195, 247, 0.5);
    transform: translateY(-2px);
}

.enter-room-button:active { transform: translateY(0); }
.button-icon { font-size: 1.3rem; }
.button-text { letter-spacing: 0.05em; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 768px) {
    body { padding: 0 0.5rem 1rem 0.5rem; }
    .site-catchcopy { font-size: 0.8rem; }
    .site-title { min-height: 2.2rem; }
    .home-header { padding: 1rem 1rem 2rem 1rem; margin-bottom: 2rem; }
    .home-header.fullscreen { height: 100dvh; height: -webkit-fill-available; }
    .main-navigation { padding: 0 0.5rem; }
    .navigation-hint { font-size: 0.85rem; }
    .nav-section-header { padding: 1.2rem 1.5rem; }
    .nav-section-title { font-size: 1.2rem; }
    .nav-section-description { font-size: 0.85rem; }
    .nav-section.active .nav-links { padding: 1rem 1.5rem 1.2rem 1.5rem; }
    .enter-room-button { padding: 1rem 2rem; font-size: 1rem; }
    .enter-room-section { padding: 2rem 1rem; }
}

@media (max-width: 480px) {
    .site-catchcopy { font-size: 0.75rem; }
    .site-title { min-height: 2rem; }
    .home-header.fullscreen { height: 100dvh; height: -webkit-fill-available; }
    .nav-section-header { padding: 1rem 1.2rem; }
    .nav-section-title { font-size: 1.1rem; }
    .nav-section-description { font-size: 0.80rem; }
    .nav-links a { padding: 0.6rem 0.8rem; font-size: 0.95rem; }
    .enter-room-button { padding: 0.9rem 1.8rem; font-size: 0.95rem; width: 90%; max-width: 280px; }
}
