:root {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        "Lexend",
        -apple-system,
        BlinkMacSystemFont,
        "Hiragino Sans",
        "Hiragino Kaku Gothic ProN",
        system-ui,
        sans-serif;
    background-color: #1c1c1e; /* 画像読み込み前・失敗時の下地 */
}

/* 背景を2枚重ねて、切り替え時にopacityをクロスフェードさせる */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1; /* z-index:autoの他要素より下、bodyの背景色より上 */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 700ms ease, filter 2200ms ease;
    will-change: opacity;
}

.bg-layer.is-visible {
    opacity: 1;
}

/* 読み込み直後だけ背景をぼかしておき、bg-introクラスの除去で数秒かけてくっきりさせる */
body.bg-intro .bg-layer {
    filter: blur(24px);
}

#bg-layer-a {
    background-image: url('Asset/Gallery/05.webp');
}

@media (prefers-reduced-motion: reduce) {
    .bg-layer {
        transition: none;
    }
    /* 動きを抑える設定では、ぼかしの演出は行わず最初からくっきり表示する */
    body.bg-intro .bg-layer {
        filter: none;
    }
}

/* 写真の上でも文字とアイコンが読めるように、上下にごく薄いスクリムを敷く */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent 30%),
        linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent 35%);
}

.greeting {
    position: fixed;
    top: 30%;
    left: 28%;
    transform: translate(-50%, -50%);
    margin: 0;
    white-space: nowrap;
    color: #fff;
    font-size: clamp(2rem, 5.5vw, 3.25rem);
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: -0.01em;
    text-align: left;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85), 0 4px 18px rgba(0, 0, 0, 0.7);
    opacity: 1;
    transition: opacity 400ms ease;
}

.greeting.is-hidden {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .greeting {
        transition: none;
    }
}

.greeting strong {
    font-weight: 700;
}

/* 狭い画面では左%指定+nowrapだと画面端で欠けるので、左端基準・折り返し許可に切り替える */
@media (max-width: 600px) {
    .greeting {
        left: max(1.25rem, env(safe-area-inset-left));
        top: 22%;
        transform: translateY(-50%);
        max-width: calc(100vw - 2.5rem);
        white-space: normal;
        font-size: clamp(1.5rem, 7vw, 2rem);
    }
}

.links {
    position: fixed;
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    left: max(1.25rem, env(safe-area-inset-left));
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

/* すりガラスのチップ。上端の明るいエッジは光が素材に当たっている表現 */
.links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    color: #fff;
    text-decoration: none;
    transition:
        transform 350ms cubic-bezier(0.22, 1, 0.36, 1),
        background 350ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 350ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.links a img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: invert(1);
    mix-blend-mode: screen;
}

/* VRChatのアイコンだけ少し大きく表示する */
.links a[aria-label="VRChat"] img {
    width: 36px;
    height: 36px;
}

.links a:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* 押した瞬間に反応する。離すのを待たない */
.links a:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.3);
    transition-duration: 100ms;
}

.links a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* 右上のギャラリー切り替えボタン。左上の .site-title と対を成す配置 */
.gallery-toggle {
    position: fixed;
    top: max(1.25rem, env(safe-area-inset-top));
    right: max(1.25rem, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 60px;
    padding: 0 1.4rem;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition:
        transform 350ms cubic-bezier(0.22, 1, 0.36, 1),
        background 350ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 350ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    z-index: 11;
}

.gallery-toggle img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: invert(1);
    mix-blend-mode: screen;
}

.gallery-toggle-divider {
    width: 2px;
    height: 24px;
    background: rgba(255, 255, 255, 0.5);
}

.gallery-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.gallery-toggle:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.3);
    transition-duration: 100ms;
}

.gallery-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .links a,
    .links a:hover,
    .links a:active,
    .gallery-toggle,
    .gallery-toggle:hover,
    .gallery-toggle:active {
        transition: background 200ms ease;
        transform: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .links a,
    .gallery-toggle {
        background: rgba(40, 40, 44, 0.9);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

@media (prefers-contrast: more) {
    .links a,
    .gallery-toggle {
        background: rgba(20, 20, 22, 0.95);
        border: 2px solid #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* 右から出てくるギャラリーパネル */
.gallery-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 80vw);
    padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) 1.25rem;
    box-sizing: border-box;
    background: rgba(28, 28, 30, 0.55);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    z-index: 10;
}

.gallery-panel.is-open {
    transform: translateX(0);
}

.gallery-panel-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: calc(60px + 1rem); /* .gallery-toggle の高さ分だけ下げて隠れないようにする */
}

.gallery-panel-list img {
    width: 100%;
    border-radius: 12px;
    display: block;
    object-fit: cover;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    outline: 3px solid transparent;
    outline-offset: 2px;
    transition:
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
        outline-color 200ms ease;
}

.gallery-panel-list img:hover {
    transform: scale(1.02);
}

.gallery-panel-list img.is-active {
    outline-color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .gallery-panel {
        transition: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .gallery-panel {
        background: rgba(20, 20, 22, 0.95);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
