/* ===== 基礎 ===== */
:root {
    --accent: #ff6d75;
    --bg: #080808;
    --panel: #0a0a0a;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* ===== 全域版面設定 ===== */
    --gallery-columns: 1;      /* 一行顯示幾張圖：1 = 一行一張 */
    --gallery-ratio: 4 / 5;    /* 每張圖的顯示比例 */
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
}

html,
body {
    height: auto;
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, "Segoe UI", Arial, Roboto,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: #fff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: inherit;
}

img {
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

/* ===== 頁面外殼 ===== */
.photo-page {
    position: relative;
    width: 100%;
    max-width: 540px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding-bottom: calc(24px + var(--safe-bottom));
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(255, 109, 117, 0.14), transparent 55%),
        radial-gradient(circle at 100% 0%, rgba(255, 213, 79, 0.06), transparent 40%),
        var(--panel);
}

/* ===== 頂部 ===== */
.lang-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: calc(12px + var(--safe-top)) 12px 12px;
    background: rgba(10, 10, 10, 0.82);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lang-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 9px;
    color: var(--accent);
    background: rgba(255, 109, 117, 0.13);
    box-shadow: inset 0 0 0 1px rgba(255, 109, 117, 0.22);
}

.brand-mark svg {
    display: block;
    width: 16px;
    height: 16px;
}

.photo-header-title {
    margin: 2px 2px 0;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.4;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.92);
}

/* ===== 主區域 ===== */
.photo-main {
    padding: 14px 12px 0;
}

.photo-gallery-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.4);
}

.photo-gallery-hint::before {
    content: "";
    width: 4px;
    height: 4px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(255, 109, 117, 0.8);
}

/* ===== 圖片網格 ===== */
.intro-gallery {
    display: grid;
    grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0 0 calc(24px + var(--safe-bottom));
}

.gallery-cell {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: var(--gallery-ratio);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    isolation: isolate;
    cursor: pointer;
    text-align: left;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.gallery-cell:active {
    transform: scale(0.98);
}

.gallery-cell img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    vertical-align: top;
    opacity: 0;
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.04);
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 0.5s ease, transform 0.7s ease;
}

.gallery-cell img.is-loaded {
    opacity: 1;
    transform: scale(1);
}

/* 懶載入中的微光骨架 */
.gallery-cell-skeleton {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(100deg,
            rgba(255, 255, 255, 0.04) 20%,
            rgba(255, 255, 255, 0.09) 36%,
            rgba(255, 255, 255, 0.04) 52%);
    background-size: 220% 100%;
    animation: cell-shimmer 1.4s linear infinite;
    transition: opacity 0.4s ease;
}

.gallery-cell.is-loaded .gallery-cell-skeleton {
    opacity: 0;
    animation: none;
}

@keyframes cell-shimmer {
    from {
        background-position: 120% 0;
    }

    to {
        background-position: -120% 0;
    }
}

/* 左上角高光，和參考頁一致 */
.gallery-cell-shine {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, transparent 42%);
    opacity: 0.28;
}

/* 非觸控裝置加一點懸浮回饋 */
@media (hover: hover) and (pointer: fine) {
    .gallery-cell:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
    }

    .gallery-cell:hover img.is-loaded {
        transform: scale(1.045);
    }
}

.photo-empty {
    margin: 0;
    padding: 48px 16px;
    text-align: center;
    font-size: 14px;
    color: #8a8a8a;
}

/* ===== 全螢幕檢視 ===== */
.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(56px + var(--safe-top)) 16px calc(72px + var(--safe-bottom));
    background: rgba(0, 0, 0, 0.94);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-sizing: border-box;
    touch-action: none;
}

.image-lightbox.show {
    display: flex;
    animation: lightbox-fade 0.18s ease;
}

@keyframes lightbox-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.image-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.25s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.image-lightbox-img.is-loaded {
    opacity: 1;
}

.image-lightbox-img:not([src]) {
    visibility: hidden;
}

.image-lightbox-close {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 2;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.image-lightbox-close:active,
.image-lightbox-nav:active {
    background: rgba(255, 255, 255, 0.22);
}

.image-lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
    -webkit-tap-highlight-color: transparent;
}

.image-lightbox-prev {
    left: max(8px, env(safe-area-inset-left, 0px));
}

.image-lightbox-next {
    right: max(8px, env(safe-area-inset-right, 0px));
}

.image-lightbox-nav[hidden],
.image-lightbox-close[hidden],
.image-lightbox-counter[hidden] {
    display: none;
}

.image-lightbox-counter {
    position: absolute;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.88);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* ===== 大螢幕微調 ===== */
@media (min-width: 541px) {
    :root {
        --gallery-columns: 2; /* 電腦端一行兩張；想始終一行一張就刪掉這一行 */
    }

    body {
        background: #050505;
    }

    .photo-page {
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.65);
    }

    .image-lightbox-prev {
        left: 24px;
    }

    .image-lightbox-next {
        right: 24px;
    }
}

/* ===== 減少動態效果 ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
