/* Scavenger's Nest - テーマ対応CSS */

/* CSS Variables for Theme System */
:root {
    /* Light Theme (Default) */
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --secondary-bg: #f8f9fa;
    --border-color: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --overlay-bg: rgba(0, 0, 0, 0.8);
}

/* Dark Theme */
body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --text-light: #cccccc;
    --text-muted: #999999;
    --primary-color: #ff6600;
    --primary-hover: #e55a00;
    --secondary-bg: #2a2a2a;
    --border-color: #404040;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --overlay-bg: rgba(0, 0, 0, 0.9);
}

/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Image */
.header-link {
    display: block;
    text-decoration: none;
}

.header-image {
    width: 100%;
    height: 180px;
    object-fit: contain;
    display: block;
}

/* Header Navigation */
.header {
    background: var(--bg-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
    gap: 1rem;
}

/* 全画面でサイト名を非表示 */
.site-title {
    display: none;
}

/* デスクトップでのヘッダーレイアウト */
@media (min-width: 769px) {
    .header .container {
        justify-content: flex-start;
    }
}

/* site-title のスタイル定義（非表示設定済み） */

.site-title a {
    text-decoration: none;
    color: inherit;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    width: 50px;
    height: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    padding: 2px;
    z-index: 101;
    margin-left: 1rem;
    flex-shrink: 0;
    position: relative;
}

.theme-toggle::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    transition: transform 0.3s ease;
    display: block;
}

body.dark-mode .theme-toggle::before {
    transform: translateX(22px);
}

.theme-toggle:hover {
    border-color: var(--primary-color);
}

/* Theme icons */
.theme-toggle::after {
    content: '☀️';
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
}

body.dark-mode .theme-toggle::after {
    content: '🌙';
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--primary-color);
    color: var(--bg-color);
}

/* Search Section */
.search-section {
    margin: 2rem 0;
    text-align: center;
}

.controls-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    min-width: 300px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s ease;
}

.search-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s ease;
}

.search-btn:hover {
    background: var(--primary-hover);
}

.search-clear {
    color: var(--text-light);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.search-clear:hover {
    background: var(--secondary-bg);
}

/* Sort Controls */
.sort-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-wrapper-mobile {
    display: none;
}

.sort-label {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    flex-shrink: 0;
}

.sort-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    min-width: 200px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Gallery Grid */
.gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 2rem 1rem 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.gallery-overlay h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.gallery-overlay p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 3rem 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 1rem;
}

.pagination::-webkit-scrollbar {
    display: none;
}

.pagination-btn {
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    scroll-snap-align: center;
}

.pagination-btn:hover,
.pagination-btn.active {
    background: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
}

/* Footer */
.footer {
    background: var(--secondary-bg);
    margin-top: 4rem;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-light);
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.footer-admin {
    position: absolute;
    bottom: 0;
    right: 0;
    opacity: 0.3;
}

.footer-admin:hover {
    opacity: 1;
}

.footer-admin a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-admin a:hover {
    color: var(--primary-color);
}

.footer-admin a {
    font-size: 0.8rem;
    padding: 0.25rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .header .container {
        justify-content: space-between;
        align-items: center;
    }
    
    .nav-menu {
        gap: 1rem;
    }
    
    .theme-toggle {
        margin-left: 1rem;
    }
    
    /* モバイルでアイコンを右側に配置 */
    .theme-toggle::after {
        left: auto;
        right: -30px;
    }
    
    .controls-wrapper {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input {
        min-width: 250px;
    }
    
    .gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
    
    .gallery-item img {
        height: 160px;
    }
    
    .header-image {
        height: 120px;
        object-fit: contain;
    }
    
    /* モバイル用ページネーション */
    .pagination {
        gap: 0.75rem;
        margin: 2rem 0;
        padding: 0 0.5rem;
        justify-content: flex-start;
    }
    
    .pagination-btn {
        padding: 1rem 1.25rem;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .search-input {
        min-width: auto !important;
        width: auto !important;
        flex: 1 !important;
        max-width: 200px !important;
    }
    
    /* 検索エリア全体を横並びにする - 最強制適用 */
    .search-section .controls-wrapper .search-form .search-controls {
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }
    
    /* mobile-controls-rowを無効化して横並び強制 */
    .search-section .controls-wrapper .search-form .search-controls .mobile-controls-row {
        display: contents !important;
    }
    
    /* 並び順を下段に配置 */
    .search-section .controls-wrapper .search-form .search-controls .sort-wrapper-mobile {
        flex-basis: 100% !important;
        margin-top: 0.75rem !important;
        justify-content: flex-start !important;
    }
    
    /* 検索ボタンとクリアボタンを確実に横並び */
    .search-section .search-btn {
        flex-shrink: 0 !important;
        margin: 0 !important;
    }
    
    .search-section .search-clear {
        flex-shrink: 0 !important;
        margin: 0 !important;
    }
    
    .sort-wrapper-desktop {
        display: none !important;
    }
    
    .sort-wrapper-mobile {
        display: flex !important;
        justify-content: center;
        gap: 0.25rem;
        align-items: center;
        flex-shrink: 0;
    }
    
    .sort-wrapper-mobile .sort-label {
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .sort-wrapper-mobile .sort-select {
        min-width: 120px;
        font-size: 0.9rem;
        padding: 0.6rem 0.5rem;
    }
    
    .mobile-controls-row {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        width: 100%;
        flex-wrap: nowrap;
    }
    
    .gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .gallery-item img {
        height: 120px;
    }
    
    .nav-menu {
        gap: 0.5rem;
    }
    
    .nav-menu a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .header-image {
        height: 100px;
        object-fit: contain;
    }
    
    /* 小さなモバイルでもアイコンを右側に配置 */
    .theme-toggle::after {
        left: auto;
        right: -30px;
    }
    
    /* 小画面用ページネーション */
    .pagination {
        gap: 0.5rem;
        margin: 1.5rem 0;
        padding: 0 0.5rem;
        justify-content: flex-start;
    }
    
    .pagination-btn {
        padding: 0.875rem 1rem;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }
}

/* Filter Info */
.filter-info {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--secondary-bg);
    border-radius: 4px;
}

.filter-info h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.filter-info p {
    color: var(--text-color);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.no-results p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #0066cc;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.btn:hover {
    background: #0052a3;
}

/* Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
}

.lightbox-close:hover {
    background: rgba(0,0,0,0.8);
}

#lightbox-image {
    width: 100%;
    height: auto;
    max-height: calc(90vh - 100px);
    object-fit: contain;
    background: transparent;
    display: block;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
}

.lightbox-caption {
    padding: 1rem;
    background: white;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    color: #333;
}

/* モバイル没入表示機能 - UI要素非表示状態 */
@media (max-width: 768px) {
    .lightbox-content.ui-hidden .lightbox-close,
    .lightbox-content.ui-hidden .lightbox-nav,
    .lightbox-content.ui-hidden .lightbox-counter {
        opacity: 0 !important;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    /* UI非表示時も画像クリックは有効 */
    .lightbox-content.ui-hidden #lightbox-image {
        cursor: pointer;
    }
    
    /* UI表示時のスムーズな遷移 */
    .lightbox-close,
    .lightbox-nav,
    .lightbox-counter,
    .lightbox-caption {
        transition: opacity 0.3s ease;
    }
    
    /* モバイル専用：細い線除去のための追加調整 */
    .lightbox-content {
        border: none;
        outline: none;
        box-shadow: none;
    }
    
    #lightbox-image {
        border: none;
        outline: none;
        box-shadow: none;
        vertical-align: top;
    }
}