/* Anime Gallery Master - Gallery Styles */

/* CSS変数のデフォルト値 */
.agm-gallery-page {
    --agm-main: #FF69B4;
    --agm-sub: #87CEEB;
    --agm-bg: #FFF5F8;
    --agm-text: #333333;
    --agm-light-main: #FFB6D9;
}

.agm-gallery-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, var(--agm-bg) 0%, #F0F8FF 100%);
    min-height: 100vh;
    color: var(--agm-text);
}

/* ========================================
   ギャラリーナビヘッダー
   ======================================== */
.agm-gallery-page .gallery-nav-header {
    background: white;
    border-radius: 15px;
    padding: 12px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--agm-light-main);
}

.agm-gallery-page .gallery-nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.agm-gallery-page .gallery-nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.agm-gallery-page .gallery-nav-btn {
    padding: 8px 18px;
    background: linear-gradient(135deg, var(--agm-light-main), var(--agm-sub));
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.agm-gallery-page .gallery-nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: white;
}

.agm-gallery-page .gallery-nav-btn.has-icon {
    padding: 8px;
    min-width: 40px;
    justify-content: center;
}

.agm-gallery-page .nav-btn-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

.agm-gallery-page .nav-btn-text { display: none; }
.agm-gallery-page .gallery-nav-btn.has-icon:hover .nav-btn-text { display: inline; }

.agm-gallery-page .gallery-lang-switch {
    display: flex;
    gap: 5px;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 20px;
}

.agm-gallery-page .lang-btn {
    padding: 6px 14px;
    text-decoration: none;
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.agm-gallery-page .lang-btn:hover { color: var(--agm-main); }
.agm-gallery-page .lang-btn.active { background: var(--agm-main); color: white; }

/* ========================================
   ページヘッダー・ロゴ
   ======================================== */
.agm-gallery-page .gallery-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--agm-light-main) 0%, var(--agm-sub) 100%);
    border-radius: 20px;
    margin-bottom: 40px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.agm-gallery-page .gallery-header::before {
    content: '';
    position: absolute;
    width: 100px; height: 100px;
    background: var(--agm-sub);
    opacity: 0.3;
    border-radius: 50%;
    top: -30px; right: -30px;
}

.agm-gallery-page .gallery-header::after {
    content: '';
    position: absolute;
    width: 80px; height: 80px;
    background: var(--agm-main);
    opacity: 0.3;
    border-radius: 50%;
    bottom: -20px; left: -20px;
}

.agm-gallery-page .page-logo {
    max-width: 600px;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1));
}

.agm-gallery-page .page-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    margin: 0;
    position: relative;
    z-index: 1;
}

/* ========================================
   フィルターコンテナ
   ======================================== */
.agm-gallery-page .filter-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 3px solid var(--agm-light-main);
}

.agm-gallery-page .filter-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--agm-main);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.agm-gallery-page .filter-title::before {
    content: '▶';
    color: var(--agm-sub);
    font-size: 0.8em;
}

/* ========================================
   キャラクターフィルター
   ======================================== */
.agm-gallery-page .character-filter-section { margin-bottom: 30px; }

.agm-gallery-page .character-filter-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.agm-gallery-page .character-filter-scroll {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 5px 0 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--agm-main) #f1f1f1;
}

.agm-gallery-page .character-filter-scroll::-webkit-scrollbar { height: 8px; }
.agm-gallery-page .character-filter-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.agm-gallery-page .character-filter-scroll::-webkit-scrollbar-thumb { background: var(--agm-main); border-radius: 10px; }

.agm-gallery-page .scroll-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 36px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.agm-gallery-page .scroll-hint.visible { opacity: 1; pointer-events: auto; }
.agm-gallery-page .scroll-hint-left { left: -5px; background: linear-gradient(to right, rgba(255,255,255,1) 60%, transparent); padding-right: 10px; }
.agm-gallery-page .scroll-hint-right { right: -5px; background: linear-gradient(to left, rgba(255,255,255,1) 60%, transparent); padding-left: 10px; }

.agm-gallery-page .scroll-arrow {
    font-size: 28px;
    font-weight: bold;
    color: var(--agm-main);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    animation: agmScrollPulse 1.5s ease-in-out infinite;
}

@keyframes agmScrollPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.agm-gallery-page .character-filter {
    display: flex;
    gap: 15px;
    min-width: min-content;
    padding: 5px;
}

.agm-gallery-page .character-btn {
    flex-shrink: 0;
    width: 100px;
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.agm-gallery-page .character-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--agm-main), var(--agm-sub));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.agm-gallery-page .character-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.agm-gallery-page .character-btn.active {
    border-color: var(--agm-main);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.agm-gallery-page .character-btn.active::before { opacity: 0.1; }

.agm-gallery-page .character-btn img {
    width: 70px; height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--agm-light-main);
    position: relative;
    z-index: 1;
}

.agm-gallery-page .character-btn .all-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--agm-main);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.agm-gallery-page .character-btn .char-initial {
    width: 70px; height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agm-light-main), var(--agm-sub));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    position: relative;
    z-index: 1;
}

.agm-gallery-page .character-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--agm-text);
    position: relative;
    z-index: 1;
}

.agm-gallery-page .character-btn.active .character-name { color: var(--agm-main); }

/* ========================================
   テキストフィルター
   ======================================== */
.agm-gallery-page .text-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.agm-gallery-page .filter-group {
    background: linear-gradient(135deg, #FFF 0%, var(--agm-bg) 100%);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid var(--agm-light-main);
}

.agm-gallery-page .filter-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.agm-gallery-page .filter-btn {
    padding: 8px 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.agm-gallery-page .filter-btn::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    background: var(--agm-sub);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: 0;
}

.agm-gallery-page .filter-btn:hover::before { width: 200%; height: 200%; }
.agm-gallery-page .filter-btn:hover { color: white; border-color: var(--agm-sub); }

.agm-gallery-page .filter-btn.active {
    background: linear-gradient(135deg, var(--agm-main), var(--agm-sub));
    color: white;
    border-color: var(--agm-main);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ========================================
   ソート
   ======================================== */
.agm-gallery-page .sort-container {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 2px dashed var(--agm-light-main);
}

.agm-gallery-page .sort-container label { font-weight: 600; color: var(--agm-main); font-size: 0.95rem; }

.agm-gallery-page .sort-select {
    padding: 10px 35px 10px 15px;
    border: 2px solid var(--agm-light-main);
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--agm-text);
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23FF69B4' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.agm-gallery-page .sort-select:hover, .agm-gallery-page .sort-select:focus {
    border-color: var(--agm-main);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    outline: none;
}

/* ========================================
   ギャラリー
   ======================================== */
.agm-gallery-page .gallery-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
}

.agm-gallery-page .gallery-item { break-inside: avoid; margin-bottom: 15px; }

.agm-gallery-page .gallery-link {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: white;
}

.agm-gallery-page .gallery-link::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: linear-gradient(135deg, var(--agm-main), var(--agm-sub), #FFD700);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 15px;
}

.agm-gallery-page .gallery-link:hover::before { opacity: 1; }
.agm-gallery-page .gallery-link:hover { transform: translateY(-8px) scale(1.02); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); }
.agm-gallery-page .gallery-link img { width: 100%; height: auto; display: block; border-radius: 15px; }

.agm-gallery-page .gallery-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 20px 15px 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.agm-gallery-page .gallery-link:hover .gallery-overlay { opacity: 1; }
.agm-gallery-page .gallery-title { color: white; font-size: 0.9rem; font-weight: 600; display: block; }

/* ========================================
   ローディング・メッセージ
   ======================================== */
.agm-gallery-page .loading-indicator { text-align: center; padding: 40px; display: none; }

.agm-gallery-page .spinner {
    width: 50px; height: 50px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--agm-main);
    border-radius: 50%;
    animation: agmSpin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes agmSpin { to { transform: rotate(360deg); } }
.agm-gallery-page .loading-indicator p { color: var(--agm-main); font-weight: 600; }

.agm-gallery-page .no-more-posts { text-align: center; padding: 40px; color: #999; font-size: 0.95rem; }
.agm-gallery-page .no-more-posts p {
    background: white;
    display: inline-block;
    padding: 15px 30px;
    border-radius: 25px;
    border: 2px dashed var(--agm-light-main);
}

/* ========================================
   TOPに戻るボタン
   ======================================== */
.agm-gallery-page .back-to-top {
    position: fixed;
    bottom: 30px; right: 30px;
    width: 55px; height: 55px;
    background: linear-gradient(135deg, var(--agm-main), var(--agm-sub));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.agm-gallery-page .back-to-top.visible { opacity: 1; visibility: visible; }
.agm-gallery-page .back-to-top:hover { transform: translateY(-5px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); }
.agm-gallery-page .back-to-top svg { width: 24px; height: 24px; }

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 768px) {
    .agm-gallery-page { padding: 15px; }
    .agm-gallery-page .gallery-header { padding: 30px 15px; }
    .agm-gallery-page .page-logo { max-width: 100%; }
    .agm-gallery-page .filter-container { padding: 20px; }
    .agm-gallery-page .text-filters { grid-template-columns: 1fr; }
    .agm-gallery-page .gallery-nav-inner { justify-content: center; }
    .agm-gallery-page .gallery-nav-buttons { justify-content: center; }
    .agm-gallery-page .character-btn { width: 90px; }
    .agm-gallery-page .character-btn img, .agm-gallery-page .character-btn .all-text, .agm-gallery-page .character-btn .char-initial { height: 60px; width: 60px; }
    .agm-gallery-page .character-btn .char-initial { font-size: 1.5rem; }
    .agm-gallery-page .scroll-hint { width: 32px; height: 60px; }
    .agm-gallery-page .scroll-arrow { font-size: 24px; }
    .agm-gallery-page .gallery-masonry { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .agm-gallery-page .sort-container { flex-direction: column; align-items: flex-start; gap: 10px; }
    .agm-gallery-page .back-to-top { bottom: 20px; right: 20px; width: 50px; height: 50px; }
}

@media (min-width: 1200px) {
    .agm-gallery-page .gallery-masonry { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@keyframes agmFadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.agm-gallery-page .gallery-item { animation: agmFadeInUp 0.5s ease forwards; }
