/* Galeri bölümü — liste, detay ve düzenleme ekranları */

.gallery-list-card {
    padding: 1rem;
}

/* Araç çubuğu — .home-top-actions üzerine yalnızca alt boşluk ekler.
   Sıralama sekmeleri .topics-sort-tabs (home-page.css), arama
   .search-compose-fused (navbar-menus-extra.css) ile ortak. */
.gallery-toolbar {
    margin-bottom: 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.gallery-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--site-home-radius, var(--site-box-radius, 4px));
    /* overflow:hidden + lazy img sorununu önlemek için kırpma cover'da */
    background: color-mix(in srgb, var(--bs-body-bg, #fff) 92%, var(--primary-color, #2aa8c9) 8%);
    border: 1px solid color-mix(in srgb, var(--text-color, #222) 16%, transparent);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--text-color, #222) 6%, transparent);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.gallery-card:hover {
    border-color: color-mix(in srgb, var(--primary-color, #2aa8c9) 42%, transparent);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--text-color, #222) 10%, transparent);
}

[data-bs-theme="dark"] .gallery-card {
    background: rgba(255, 255, 255, .03);
    border-color: rgba(255, 255, 255, .14);
    box-shadow: none;
}

[data-bs-theme="dark"] .gallery-card:hover {
    border-color: rgba(255, 255, 255, .28);
}

.gallery-card__cover {
    position: relative;
    display: block;
    aspect-ratio: 3 / 2;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--site-home-radius, var(--site-box-radius, 4px)) var(--site-home-radius, var(--site-box-radius, 4px)) 0 0;
    background: rgba(0, 0, 0, .25);
}

.gallery-card__cover img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    display: block;
}

.gallery-card__count {
    position: absolute;
    right: .5rem;
    bottom: .5rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    background: rgba(0, 0, 0, .65);
    color: #fff;
}

.gallery-card__body {
    padding: .65rem .75rem .75rem;
}

.gallery-card__title {
    margin: 0 0 .4rem;
    font-size: .95rem;
    line-height: 1.3;
}

.gallery-card__title a {
    color: inherit;
    text-decoration: none;
}

.gallery-card__title a:hover {
    text-decoration: underline;
}

.gallery-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .5rem;
    align-items: center;
    font-size: .78rem;
    opacity: .9;
}

.gallery-card__author {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.gallery-card__author span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-card__avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.gallery-card__footer {
    display: flex;
    align-items: stretch;
    gap: .4rem;
    margin-top: .55rem;
}

.gallery-card__stats {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-around;
    gap: .15rem;
    min-width: 0;
    padding: .28rem .4rem;
    border-radius: var(--site-home-radius, var(--site-box-radius, 4px));
    border: 1px solid color-mix(in srgb, var(--text-color, #222) 14%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg, #fff) 88%, var(--text-color, #222) 12%);
    font-size: .74rem;
    line-height: 1.2;
}

[data-bs-theme="dark"] .gallery-card__stats {
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .05);
}

.gallery-card__stat {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    opacity: .9;
    white-space: nowrap;
}

.gallery-card__stat i {
    font-size: .72rem;
    opacity: .75;
}

.gallery-card__share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    flex: 0 0 auto;
    margin: 0;
    padding: .28rem .55rem;
    border-radius: var(--site-home-radius, var(--site-box-radius, 4px));
    border: 1px solid color-mix(in srgb, var(--primary-color, #2aa8c9) 38%, transparent);
    background: color-mix(in srgb, var(--primary-color, #2aa8c9) 10%, transparent);
    color: inherit;
    font-size: .74rem;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.gallery-card__share:hover,
.gallery-card__share:focus-visible {
    background: color-mix(in srgb, var(--primary-color, #2aa8c9) 22%, transparent);
    border-color: color-mix(in srgb, var(--primary-color, #2aa8c9) 55%, transparent);
    outline: none;
}

.gallery-card__share.is-copied {
    border-color: color-mix(in srgb, #2e9e5b 55%, transparent);
    background: color-mix(in srgb, #2e9e5b 16%, transparent);
}

.gallery-card__share-label {
    font-weight: 500;
}

@media (max-width: 399.98px) {
    .gallery-card__share-label {
        display: none;
    }

    .gallery-card__share {
        padding: .28rem .45rem;
    }
}

@media (max-width: 575.98px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: .65rem;
    }

}

/* --- Form ve düzenleme ekranı --- */

.gallery-form-card {
    padding: 1.25rem;
}

.gallery-form-title {
    font-size: 1.25rem;
    margin: 0 0 .5rem;
}

.gallery-form-subtitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: 1.05rem;
    margin: 0 0 .5rem;
}

.gallery-media-counter {
    font-size: .85rem;
    opacity: .8;
    font-weight: 400;
}

.gallery-form-help {
    font-size: .87rem;
    opacity: .8;
    margin-bottom: 1rem;
}

.gallery-upload-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: .75rem;
}

.gallery-youtube-add {
    display: flex;
    gap: .35rem;
    align-items: center;
    flex: 1 1 260px;
    min-width: 0;
}

.gallery-upload-status {
    min-height: 1.25rem;
    font-size: .85rem;
    margin-bottom: .75rem;
    opacity: .9;
}

.gallery-upload-status.is-error {
    color: #ff8b8b;
}

.gallery-item {
    position: relative;
    margin: 0;
    border-radius: 10px;
    /* overflow:hidden + loading=lazy birlikte Chrome'da IntersectionObserver
       görünürlük hesabını bozabiliyor; köşe kırpma media kutusunda. */
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .08);
}

.gallery-item.is-cover {
    border-color: #f0c040;
    box-shadow: 0 0 0 1px #f0c040 inset;
}

.gallery-item.is-dragging {
    opacity: .5;
}

.gallery-item__media {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    max-width: 100%;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, .25);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
}

.gallery-item__media img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #ff0033;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
    pointer-events: none;
}

.gallery-item__caption {
    padding: .5rem .6rem;
    font-size: .8rem;
    line-height: 1.35;
}

.gallery-item__caption span {
    display: block;
    opacity: .8;
}

.gallery-item__actions {
    position: absolute;
    top: .4rem;
    right: .4rem;
    display: flex;
    gap: .25rem;
    align-items: center;
}

.gallery-item__btn,
.gallery-item__drag {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .8rem;
    cursor: pointer;
}

.gallery-item__drag {
    cursor: grab;
}

.gallery-item__btn:hover {
    background: rgba(0, 0, 0, .85);
}

@media (max-width: 575.98px) {
    .gallery-upload-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-youtube-add {
        flex: 1 1 auto;
    }
}

/* --- Detay sayfası (forum topic-page-card kalıbı) --- */

.gallery-page-card.topic-page-card {
    margin-bottom: 1rem;
}

.gallery-detail-grid {
    margin-top: 0.25rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

@media (min-width: 768px) {
    .gallery-detail-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Oynatılan video: satırı kaplar, büyük 16:9 alan */
.gallery-detail-grid > .gallery-item.is-playing {
    grid-column: 1 / -1;
}

/* Eski kompakt detay başlığı — geriye dönük sınıf temizliği */
.gallery-detail-card {
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* Yorumlar: forum topic-comments-panel / forum-comment-post stilleri topic.css'ten gelir */
.gallery-comments-panel {
    margin-bottom: 1rem;
}

.gallery-comment-list {
    margin-top: 0.25rem;
}

.gallery-comment-list > .forum-comment-post:last-child {
    margin-bottom: 0 !important;
}

/* Beğenilmiş durum — topic like-badge active ile uyumlu; fantasy buton kalıntısı */
.home-page .home-toolbar-cluster .btn-fantasy.is-liked {
    --ab-fill-color: #e05a6d;
}

.home-page .home-toolbar-cluster .btn-fantasy.is-liked > i::before {
    color: #fff !important;
}

.gallery-item__embed {
    aspect-ratio: 3 / 2;
    max-width: 100%;
    position: relative;
    background: #000;
}

.gallery-item.is-playing .gallery-item__embed {
    aspect-ratio: 16 / 9;
    max-height: min(70vh, 720px);
}

.gallery-item__embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

@media (max-width: 575.98px) {
    .gallery-item__embed {
        max-width: 100%;
    }
}

/* --- Form butonları ---
   .btn-fantasy ailesi site geneli (home-toolbar.css). İkincil (vazgeç / geri)
   butonlar için group-form.css'teki .group-form-btn--secondary ile aynı
   muamele; o kurallar .create-group-page / .edit-group-page kapsamına bağlı
   olduğu için galeri sayfaları kendi kapsamını tanımlar. */

.create-gallery-page .btn-fantasy.gallery-form-btn--secondary,
.edit-gallery-page .btn-fantasy.gallery-form-btn--secondary {
    background: linear-gradient(
        135deg,
        rgba(var(--secondary-color-rgb), 0.22),
        rgba(var(--secondary-color-rgb), 0.08)
    ) !important;
    box-shadow: none !important;
    border-color: rgba(var(--text-color-rgb), 0.38) !important;
}

[data-bs-theme="dark"] .create-gallery-page .btn-fantasy.gallery-form-btn--secondary,
[data-bs-theme="dark"] .edit-gallery-page .btn-fantasy.gallery-form-btn--secondary {
    border-color: rgba(var(--text-color-rgb), 0.35) !important;
}

.create-gallery-page .btn-fantasy.gallery-form-btn--secondary:hover,
.create-gallery-page .btn-fantasy.gallery-form-btn--secondary:focus-visible,
.edit-gallery-page .btn-fantasy.gallery-form-btn--secondary:hover,
.edit-gallery-page .btn-fantasy.gallery-form-btn--secondary:focus-visible {
    background: linear-gradient(
        135deg,
        rgba(var(--secondary-color-rgb), 0.48),
        rgba(var(--secondary-color-rgb), 0.18)
    ) !important;
    border-color: rgba(var(--text-color-rgb), 0.68) !important;
}

[data-bs-theme="dark"] .create-gallery-page .btn-fantasy.gallery-form-btn--secondary:hover,
[data-bs-theme="dark"] .edit-gallery-page .btn-fantasy.gallery-form-btn--secondary:hover {
    border-color: rgba(var(--text-color-rgb), 0.68) !important;
}

/* Yükle / YouTube ekle butonları .home-toolbar-cluster içinde; görünümü
   home-page.css veriyor (sol ikon bloğu + hover dolgusu). Burada yalnızca
   label'ın alt boşluğu sıfırlanır, gap/display'e DOKUNULMAZ — ezerse
   ikon bloğu hizası bozulur. */
.gallery-upload-bar label.btn-fantasy {
    margin-bottom: 0;
}

/* Yazar satırı — avatar çerçeve rengi user_forum_avatar_img_attributes()
   tarafından --user-avatar-forum-border-color ile veriliyor; sarmalayıcı
   yalnızca hizalama sağlar. Kullanıcı adı efektleri username-effects.css'ten
   gelir (global bundle). */
.gallery-card__avatar-wrap {
    display: inline-flex;
    flex-shrink: 0;
    line-height: 0;
}

.gallery-card__author-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Yazar rozetleri — user-badge-v4 boyutları global; kartta taşmayı önle */
.gallery-card__badges {
    max-width: 100%;
    overflow: hidden;
}

.gallery-card__badges .user-badge-v4 {
    flex-shrink: 0;
}

/* Yıkıcı buton — home-page.css'teki sol-ikon + hover-dolgu mekanizmasının
   aynısı; yalnızca dolgu tokenı tehlike tonuna çevrilir. Ayrı bir bileşen
   (action-badge delete-badge) kullanmak yerine bu yol seçildi ki galerideki
   tüm butonlar aynı etkileşimi paylaşsın. */
.home-page .home-toolbar-cluster .btn-fantasy.gallery-btn--danger {
    --ab-fill-color: var(--bs-danger, #dc3545);
}

.home-page .home-toolbar-cluster .btn-fantasy.gallery-btn--danger:is(:hover, :focus-visible, :active) > span {
    color: #fff !important;
}
