/*-- photo page specific styles --*/

/*--gallery-toolbar--*/
.gallery-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.gallery-filter-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.4em 0.9em;
    border: 1px solid var(--fg-color);
    border-radius: 999px;
    background: transparent;
    color: var(--fg-color);
    font-size: var(--font-size-small);
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.gallery-filter-button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.gallery-filter-button.is-active {
    background-color: var(--fg-color);
    border-color: var(--fg-color);
    color: var(--bg-color);
}

.gallery-filter-count[hidden] {
    display: none;
}

.gallery-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    height: 1.4em;
    padding: 0 0.3em;
    border-radius: 999px;
    background-color: var(--accent-color);
    color: var(--bg-color);
    font-size: 0.8em;
}

/*--gallery-toolbar--*/

/*--gallery-filter-panel--*/
.gallery-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(15, 37, 64, 0.8), rgba(15, 37, 64, 1));
    z-index: 9990;
    display: none;
}

.gallery-filter-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 16px;
    background-color: var(--bg-color);
    color: var(--fg-color);
    text-align: left;
    z-index: 9991;
    display: none;
}

.gallery-filter-overlay.is-open,
.gallery-filter-panel.is-open {
    display: block;
}

.gallery-filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.gallery-filter-panel-header h2 {
    margin: 0;
    font-size: var(--font-size-body);
}

.gallery-filter-close {
    border: none;
    background: transparent;
    color: var(--fg-color);
    font-size: 1.5em;
    line-height: 1;
    cursor: pointer;
}

.gallery-filter-close:hover {
    color: var(--accent-color);
}

.gallery-filter-group {
    margin-top: 16px;
}

.gallery-filter-group-title {
    margin: 0 0 8px;
    font-size: var(--font-size-small);
    opacity: 0.7;
    letter-spacing: 0.05em;
}

.gallery-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.gallery-filter-option {
    display: inline-flex;
}

.gallery-filter-option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.gallery-filter-option span {
    padding: 0.35em 0.8em;
    border: 1px solid rgba(128, 128, 128, 0.5);
    border-radius: 999px;
    color: var(--fg-color);
    font-size: var(--font-size-small);
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.gallery-filter-option input:checked+span {
    background-color: var(--fg-color);
    border-color: var(--fg-color);
    color: var(--bg-color);
}

.gallery-filter-option input:focus-visible+span {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.gallery-filter-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 0.6em;
}

.gallery-filter-reset {
    padding: 0.4em 0.9em;
    border: 1px solid var(--fg-color);
    border-radius: 999px;
    background: transparent;
    color: var(--fg-color);
    font-size: var(--font-size-small);
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.gallery-filter-reset:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.gallery-filter-apply {
    padding: 0.4em 0.9em;
    border: 1px solid var(--fg-color);
    border-radius: 999px;
    background-color: var(--fg-color);
    color: var(--bg-color);
    font-size: var(--font-size-small);
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.gallery-filter-apply:hover {
    border-color: var(--accent-color);
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.gallery-empty {
    text-align: center;
    opacity: 0.7;
}

/*--gallery-filter-panel--*/

#grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    gap: 6px;
}

.grid-row {
    display: grid;
    /* 行の高さを固定し、写真は行の高さいっぱいに広がる(全行の高さを統一するため) */
    aspect-ratio: 3 / 1;
    gap: 6px;
    min-height: 0;
}

/* 列構成を1種類(4列)に統一し、行タイプ間でのサブピクセル丸め誤差を無くす。
   pair(縦長1枚+横長1枚、合計3列)のように4列に満たない行も、この4列グリッドの
   まま3列分だけ使い、4列目は空けておく(他の行と列幅を揃え、引き伸ばしを防ぐため) */
.grid-row-landscape,
.grid-row-portrait,
.grid-row-mixed,
.grid-row-pair {
    grid-template-columns: repeat(4, 1fr);
}

.grid-row-landscape .grid-item {
    grid-column: span 2;
}

.grid-row-mixed .grid-item-wide,
.grid-row-pair .grid-item-wide {
    grid-column: span 2;
}

.grid-item {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* トリミングしてでも枠いっぱいに写真を表示し、グリッドを綺麗に見せる */
    object-fit: cover;
    /* クリックイベントを受け付けるため pointer-events のみ有効化する。
       touch-callout/user-selectはサイト共通のimg既定値(none)のままにし、
       長押しでの画像保存・選択はできないようにする */
    pointer-events: initial;
}

.grid-item:hover {
    position: relative;
    z-index: 1;
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(15, 37, 64, 0.35);
}

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

    .grid-item:hover {
        transform: none;
    }
}

/* ライトボックス自体のスタイルはassets/css/cmn/style.cssの共通定義(.msgの記事内写真と共用)を使う */
