/* 
   DRAWEST — GÖNDERİ KARTI STİLLERİ
   profile/feed.php ve profile/view.php tarafından yüklenir.

   TEMA SİSTEMİ
   -------------
   Her gönderi kartı, satır içi `--pt-*` CSS değişkenleriyle gelir
   (bkz. includes/dw_post_themes.php → dw_post_theme_css_vars()):
       --pt-bg           kart arka planı
       --pt-text         ana metin (kontrastı garanti edilmiş)
       --pt-muted        isim / zaman
       --pt-faint        ikincil bilgi
       --pt-border       kenarlık + avatar çerçevesi
       --pt-accent       vurgu (beğeni)
       --pt-field        yorum kutusu arka planı
       --pt-field-border yorum kutusu kenarlığı
       --pt-on-accent    vurgu üstündeki metin

   Burada o değişkenler tüketilir. AŞAĞIDA `color:#fff` gibi SABİT
   renk YOKTUR — renk her zaman temadan gelir. Bu yüzden koyu temada
   yazılar kaybolmaz, açık temada okunur kalır.
*/

/* ══════════════════════════════════════════════════════════════
   1) KART
   ══════════════════════════════════════════════════════════════ */
.feed-post {
    background: var(--pt-bg);
    color: var(--pt-text);
    border: 1px solid var(--pt-border);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
    box-shadow: var(--pt-shadow, 0 1px 2px rgba(0, 0, 0, 0.08));
}

.feed-post a {
    color: inherit;
}

.feed-post a:hover {
    text-decoration: underline;
}

/* Tema seçilmemiş gönderilerde site değişkenlerine uy */
:root {
    --pt-bg: var(--bg-elevated, #fff);
    --pt-text: var(--text, #0f172a);
    --pt-muted: var(--muted, #64748b);
    --pt-faint: var(--muted, #94a3b8);
    --pt-border: var(--border, #e2e8f0);
    --pt-accent: #ef4444;
    --pt-field: rgba(0, 0, 0, 0.04);
    --pt-field-border: var(--border, #e2e8f0);
    --pt-on-accent: #fff;
}

/* ══════════════════════════════════════════════════════════════
   2) BAŞLIK
   ══════════════════════════════════════════════════════════════ */
.post-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.post-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--pt-border);
    flex-shrink: 0;
}

.post-info {
    flex: 1;
    min-width: 0;
}

.post-author {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--pt-text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.post-feeling {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--pt-muted);
}

.post-feeling strong {
    color: var(--pt-text);
}

.post-time {
    display: block;
    font-size: 0.8rem;
    color: var(--pt-faint);
}

.post-time-link {
    color: inherit;
    text-decoration: none;
}

.post-menu {
    margin-left: auto;
    flex-shrink: 0;
}

/* Sil butonu — her temada okunur */
.action-icon-btn {
    background: none;
    border: none;
    padding: 6px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--pt-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: background 0.2s, color 0.2s;
}

@media (hover: hover) {
    .action-icon-btn:hover {
        background: rgba(239, 68, 68, 0.12);
        color: #ef4444;
    }
}

/* ══════════════════════════════════════════════════════════════
   3) İÇERİK
   ══════════════════════════════════════════════════════════════ */
.post-content {
    padding: 2px 14px 14px;
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--pt-text);
    position: relative;
    z-index: 2;
}

.post-content a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════
   4) GÖRSELLER — büyütülebilir
   ══════════════════════════════════════════════════════════════ */
.post-media-container {
    padding: 0 14px 14px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.post-media {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--pt-border);
    background: var(--pt-field);
}

.post-media-img {
    width: 100%;
    display: block;
    cursor: zoom-in;
    /* Görsele dokununca parmağın kaydırmasını engelle */
    touch-action: manipulation;
    transition: opacity 0.2s;
}

@media (hover: hover) {
    .post-media-img:hover {
        opacity: 0.92;
    }
}

/* Birden çok görsel varsa ipucu göster */
.feed-post[data-multi="1"] .post-media-container::after {
    content: "🔍 Büyütmek için dokun";
    display: block;
    text-align: center;
    font-size: 0.72rem;
    color: var(--pt-faint);
    margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   5) AKSİYON ÇUBUĞU
   ══════════════════════════════════════════════════════════════ */
.post-actions {
    display: flex;
    gap: 2px;
    border-top: 1px solid var(--pt-border);
    padding: 4px 6px;
    position: relative;
    z-index: 2;
}

.post-actions .action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 6px;
    border: none;
    border-radius: 10px;
    background: none;
    cursor: pointer;
    color: var(--pt-muted);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    touch-action: manipulation;
    transition: background 0.2s, color 0.2s;
}

.post-actions .action-btn i {
    font-size: 1.15rem;
    line-height: 1;
}

@media (hover: hover) {
    .post-actions .action-btn:hover {
        background: var(--pt-field);
        color: var(--pt-text);
    }
}

/* Beğeni durumu rengi — gönderi beğenisi VE yorum beğenisi.
   Kapsam `.post-actions` ile sınırlıydı; yorum beğeni düğmesi
   bu kapsamın dışında kaldığı için rengini temadan alamıyordu. */
.action-btn.liked {
    color: var(--pt-accent);
}

/* Yorum beğenisi düğmesi kart içinde olduğu için temadan beslenir */
.comment-list .action-btn {
    color: var(--pt-muted);
    font-weight: 700;
}

.comment-list .action-btn:hover {
    color: var(--pt-text);
}

.comment-list .action-btn.liked {
    color: var(--pt-accent);
}

.post-actions .action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Simge yardımcıları (yorum kutusu) */
.pt-icon {
    color: var(--pt-muted) !important;
}

.pt-icon-accent {
    color: var(--pt-text) !important;
}

/* ══════════════════════════════════════════════════════════════
   6) YORUMLAR
   ══════════════════════════════════════════════════════════════ */
.post-comments {
    display: none;
    border-top: 1px solid var(--pt-border);
    padding: 12px 14px;
    position: relative;
    z-index: 2;
}

.comment-list .d-flex {
    color: var(--pt-text);
}

.comment-list .comment-bubble {
    background: var(--pt-field);
    border: 1px solid var(--pt-field-border);
    color: var(--pt-text);
}

/* Yorum yazma alanı */
.post-comments input[type="text"] {
    font-size: 16px;           /* iOS otomatik zoom engeli */
    color: var(--pt-text);
}

.comment-media-box img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--pt-border);
}

/* ══════════════════════════════════════════════════════════════
   7) PAYLAŞ MENÜSÜ
   ══════════════════════════════════════════════════════════════ */
.share-menu {
    position: fixed;
    inset: 0;
    z-index: 100200;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 20px;
}

.share-menu.open {
    display: flex;
}

.share-menu-box {
    background: var(--bg-elevated, #fff);
    color: var(--text, #0f172a);
    border-radius: 18px;
    width: 100%;
    max-width: 340px;
    overflow: hidden;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border, #e2e8f0);
    animation: dwSharePop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dwSharePop {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .share-menu-box {
        animation: none;
    }
}

.share-menu-title {
    padding: 14px 16px 10px;
    font-size: 0.95rem;
    font-weight: 800;
    border-bottom: 1px solid var(--border, #e2e8f0);
    display: flex;
    align-items: center;
    gap: 8px;
}

.share-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text, #0f172a);
    text-align: left;
    touch-action: manipulation;
    transition: background 0.15s;
}

.share-menu-item + .share-menu-item {
    border-top: 1px solid var(--border, #e2e8f0);
}

@media (hover: hover) {
    .share-menu-item:hover {
        background: var(--bg-surface, #f1f5f9);
    }
}

.share-menu-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.share-menu-item .sm-sub {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted, #64748b);
    margin-top: 1px;
}

/* ══════════════════════════════════════════════════════════════
   8) LIGHTBOX — sabit kare, oklar, klavye
   ══════════════════════════════════════════════════════════════ */
.dw-lb {
    position: fixed;
    inset: 0;
    z-index: 100300;
    display: none;
    background: rgba(0, 0, 0, 0.94);
    flex-direction: column;
}

.dw-lb.open {
    display: flex;
}

.dw-lb-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    padding-top: calc(10px + env(safe-area-inset-top));
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.dw-lb-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

.dw-lb-close {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
}

@media (hover: hover) {
    .dw-lb-close:hover {
        background: rgba(255, 255, 255, 0.26);
    }
}

/* Görsel alanı — ekranı doldurur, taşmaz */
.dw-lb-stage {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 60px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    touch-action: pan-y;
}

.dw-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    animation: dwLbIn 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

@keyframes dwLbIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dw-lb-img {
        animation: none;
    }
}

.dw-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    z-index: 2;
    transition: background 0.2s, opacity 0.2s;
}

@media (hover: hover) {
    .dw-lb-nav:hover {
        background: rgba(255, 255, 255, 0.28);
    }
}

.dw-lb-prev {
    left: 8px;
}

.dw-lb-next {
    right: 8px;
}

/* Tek görselde oklar gereksiz */
.dw-lb[data-single="1"] .dw-lb-nav {
    display: none;
}

/* Mobilde oklar kenarlarda, daha büyük */
@media (max-width: 700px) {
    .dw-lb-stage {
        padding: 8px 8px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .dw-lb-nav {
        width: 52px;
        height: 52px;
        background: rgba(0, 0, 0, 0.45);
        font-size: 1.7rem;
    }

    .dw-lb-prev {
        left: 6px;
    }

    .dw-lb-next {
        right: 6px;
    }
}

/* ══════════════════════════════════════════════════════════════
   9) GERİ BİLDİRİM BALONU
   ══════════════════════════════════════════════════════════════ */
.feed-toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translate(-50%, 200px);
    z-index: 100400;
    display: flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 12px 20px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.3;
    text-align: center;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.feed-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

.feed-toast[data-kind="ok"] {
    background: #047857;
}

.feed-toast[data-kind="err"] {
    background: #b91c1c;
}

.feed-toast[data-kind="warn"] {
    background: #b45309;
}

/* ══════════════════════════════════════════════════════════════
   10) MOBİL — postlar ekranı tam doldurur
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
    /* Yatay boşluk kalmasın: wrapper yastığı sıfırlanır,
       kart kenardan kenara uzanır */
    .feed-wrapper {
        max-width: none;
        margin: 0;
        padding: 0 0 72px;
    }

    /* Feed başlığı ve oluşturma kartı da tam genişlik */
    .feed-header,
    .create-post-card,
    .controls-row,
    .stats-bar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .feed-header {
        padding-top: 14px;
    }

    /* Kart kenarlara yapışsın, köşeler yuvarlak kalsın */
    .feed-post {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 8px;
    }

    /* İç boşluk biraz artsın ama ekranı taşırmasın */
    .post-header {
        padding: 10px 12px;
    }

    .post-content {
        padding: 2px 12px 12px;
    }

    .post-media-container {
        padding: 0 0 0;
        gap: 2px;
    }

    .post-media {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .post-actions {
        padding: 4px;
    }

    .post-comments {
        padding: 12px;
    }

    /* Görsel ipucu mobilde gereksiz yere yer kaplıyor */
    .feed-post[data-multi="1"] .post-media-container::after {
        content: "";
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════
   11) YÜKLEME GÖSTERGESİ + "daha fazla"
   ══════════════════════════════════════════════════════════════ */
#feed-sentinel {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

#feed-loader {
    color: var(--drawest-accent, #0a84ff);
}

.feed-more-btn {
    display: none;
    margin: 16px auto;
    min-height: 46px;
    padding: 12px 28px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 999px;
    background: var(--bg-elevated, #fff);
    color: var(--text, #0f172a);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.feed-more-btn.show {
    display: block;
}

@media (hover: hover) {
    .feed-more-btn:hover {
        border-color: var(--drawest-accent, #0a84ff);
        color: var(--drawest-accent, #0a84ff);
    }
}

/* ══════════════════════════════════════════════════════════════
   12) TEMA SEÇİCİ — açılır-kapanır gruplar
   ══════════════════════════════════════════════════════════════ */
.dw-themes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dw-theme-group {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-elevated, #fff);
}

.dw-theme-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: none;
    background: var(--bg-surface, #f1f5f9);
    color: var(--text, #0f172a);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
}

.dw-theme-caret {
    transition: transform 0.25s;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.dw-theme-group.open .dw-theme-caret {
    transform: rotate(180deg);
}

.dw-theme-gicon {
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.dw-theme-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dw-theme-count {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border, #e2e8f0);
    color: var(--muted, #64748b);
    flex-shrink: 0;
}

/* Kapalıyken ızgarayı gizle */
.dw-theme-group .dw-theme-grid {
    display: none;
}

.dw-theme-group.open .dw-theme-grid {
    display: grid;
}

.dw-theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(62px, 100%), 1fr));
    gap: 10px;
    padding: 12px;
}

/* Kare — her temada kontrastlı kenar ZORUNLU.
   Beyaz/açık temalar (paper, light, Varsayılan) kenarlık olmadan
   beyaz zemin üzerinde yok oluyordu. */
.dw-theme-sw {
    position: relative;
    aspect-ratio: 1;
    min-height: 52px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    transition: transform 0.18s, box-shadow 0.18s;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.dw-theme-sw:hover {
    transform: translateY(-2px);
}

.dw-theme-sw.active {
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.55),
        0 0 0 3px var(--drawest-accent, #0a84ff);
}

/* Seçili işareti — arka plan renginden bağımsız okunur */
.dw-theme-sw.active::after {
    content: "✓";
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--drawest-accent, #0a84ff);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    border: 2px solid #fff;
}

.dw-theme-sw:focus-visible {
    outline: 3px solid var(--drawest-accent, #0a84ff);
    outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════
   13) ERİŞİLEBİLİRLİK
   ══════════════════════════════════════════════════════════════ */
.feed-post :focus-visible,
.share-menu-item:focus-visible,
.dw-lb-nav:focus-visible,
.dw-lb-close:focus-visible {
    outline: 3px solid var(--drawest-accent, #0a84ff);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .feed-post,
    .post-media-img,
    .post-actions .action-btn,
    .action-icon-btn {
        transition: none !important;
    }
}
