﻿/* =========================================
   Postcardpolis — category.css (Clean)
   Amaç: SADECE category sayfasına özel stiller
   Yapı: variables → base → components → responsive
   ========================================= */

/* -------------------------------------------------
   1) Variables (category-specific)
   ------------------------------------------------- */
:root{
  --headerH: 64px;

  --paper-dark: #E0D5C6;
  --paper-grain-opacity: 0.10;

  /* Sidebar */
  --sidebar-w: 240px;
  --sidebar-top: 8.5rem;
  --sidebar-gap: 2rem;

  /* Grid */
  --cards-gap: 1.4rem;
  --cards-cols: 4;
  --card-radius: 16px;
  --card-img-ratio: 140%; /* Delcampe oranlı kutu */

  /* Modal */
  --modal-bg: #F2ECE2;
  --modal-maxW: 1400px;
  --modal-maxH: 92vh;
  --modal-pad-y: 18px;
  --modal-pad-x: 22px;

  --thumb-w: 90px;
  --thumb-minW: 80px;

  --modal-stage-bg: #E0D5C6;

  /* Mobile fixed bars */
  --mobile-bar-x: 12px;
  --mobile-bar-w: min(240px, calc(100vw - 24px));
  --mobile-bar-gapTop: 86px; /* içerik sabit bara çarpmasın */
}

/* -------------------------------------------------
   2) Page header (breadcrumb + desc + count)
   ------------------------------------------------- */
.breadcrumb{
  font-size: 0.8rem;
  color: #777;
  margin: 0 0 0.25rem 0;
}
.breadcrumb a{ text-decoration: underline; }

.category-description{
  color: #555;
  max-width: 650px;
  margin: 0.4rem 0 0.35rem 0;
}

.category-count{
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #666;
}

/* -------------------------------------------------
   3) Base layout: sidebar + main
   ------------------------------------------------- */
.category-hero{
  padding-top: 1.6rem;
  padding-bottom: 2.2rem;
}

.category-hero-inner{
  display: flex;
  gap: var(--sidebar-gap);
  align-items: flex-start;
}

/* main */
.category-main-content{
  flex: 1;
  min-width: 0;
}

/* -------------------------------------------------
   4) Sidebar component (desktop default: sticky)
   ------------------------------------------------- */
.category-sidebar{
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: var(--sidebar-top);
  align-self: flex-start;
}

.category-sidebar-title{
  font-size: 1.05rem;
  font-weight: 700;
  color: #3b2f29;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 0.75rem;

  background: rgba(255,255,255,0.45);
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  display: inline-block;
}

.category-sidebar-toggle{
  display: none; /* desktop: kapalı */
}

.category-sidebar-menu{
  display: block; /* desktop: açık */
}

.category-sidebar-list{
  list-style: none;
  padding: 0;
  margin: 0;
}
.category-sidebar-list li{ 
  margin-bottom: 4px; 
}

.category-sidebar-list a{
  display: block;
  padding: 6px 10px;      /* ⬅️ en kritik daralma */
  border-radius: 9px;
  font-size: 0.86rem;
  line-height: 1.2;       /* ⬅️ dikey sıkılık */
  color: #4a3e3e;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(0,0,0,0.03);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.category-sidebar-list a:hover{
  background: rgba(256, 122, 0, 0.09);
  transform: translateX(1px);
}

.category-sidebar-list a.is-active-cat{
  background: rgba(255,255,255,0.92);
  color: #2a2525;
  font-weight: 700;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* -------------------------------------------------
   5) Cards grid component
   ------------------------------------------------- */
.cards-section{
  padding-top: 0.4rem;
  padding-bottom: 1.5rem;
}

.cards-grid{
  display: grid;
  grid-template-columns: repeat(var(--cards-cols), minmax(0, 1fr));
  gap: var(--cards-gap);
  margin-top: 0.9rem;
}

.postcard-card{
  background: #fff;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.postcard-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

/* Delcampe oranlı görsel kutu */
.postcard-image-wrapper{
  position: relative;
  width: 100%;
  padding-top: var(--card-img-ratio);
  background: var(--paper-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.postcard-image-wrapper img{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Başlık alanı (şu an gizli kalsın) */
.postcard-content{
  padding: 0.6rem 0.8rem 0.8rem;
  text-align: center;
  display: none;
}

/* -------------------------------------------------
   6) Pagination (single version)
   ------------------------------------------------- */
.pagination-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;

  padding: 0.45rem 0.65rem;
  margin-top: 0.65rem;
  border-radius: 18px;

  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.06);

  box-shadow: 0 6px 16px rgba(0,0,0,0.08);

  flex-wrap: wrap;
  gap: 0.5rem;
}

.pagination-total{
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: rgba(30, 25, 25, 0.72);
  flex: 1;
}

.pagination-pages{
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0.35rem;
}

.page-btn{
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0 0.7rem;
  border-radius: 999px;

  border: 1px solid rgba(201, 143, 120, 0.55);
  background: rgba(255,255,255,0.70);
  color: #3b2f29;

  font-size: 0.82rem;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    0 2px 8px rgba(120, 88, 70, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.8);

  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.page-btn:hover:not(.is-active):not([disabled]){
  transform: translateY(-1px);
  background: rgba(255,255,255,0.92);
  box-shadow:
    0 6px 16px rgba(120, 88, 70, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

.page-btn.is-active{
  background: linear-gradient(145deg, #f3e6dd, #d8b8a4);
  border-color: rgba(201,143,120,0.9);
  color: #2a2525;
  font-weight: 700;

  box-shadow:
    0 6px 18px rgba(120, 88, 70, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

.page-btn[disabled]{
  opacity: 0.55;
  background: rgba(255,255,255,0.45);
  border-color: rgba(0,0,0,0.08);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.pagination-size{
  white-space: nowrap;
  margin-left: auto;
  font-size: 0.82rem;
  color: rgba(30, 25, 25, 0.72);
}

.pagination-size label{
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-size select{
  border-radius: 999px;
  border: 1px solid rgba(201, 143, 120, 0.55);
  background: rgba(255,255,255,0.75);
  padding: 0.2rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* -------------------------------------------------
   7) Modal component (desktop default)
   ------------------------------------------------- */
.image-modal{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.image-modal.is-visible{ display: flex; }

.image-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.image-modal-dialog{
  position: relative;
  background: var(--modal-bg);
  border-radius: 12px;

  width: 96vw;
  max-width: var(--modal-maxW);
  max-height: var(--modal-maxH);

  padding: var(--modal-pad-y) var(--modal-pad-x);

  display: flex;
  flex-direction: column;

  overflow: auto;
  -webkit-overflow-scrolling: touch;

  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  z-index: 1;
}

.image-modal-body.layout{
  display: flex;
  gap: 18px;

  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.image-modal-left{
  flex: 2;
  display: flex;
  gap: 12px;
  position: relative;
}

.image-thumbs{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* thumb buttons */
.thumb-button{
  display: flex;
  flex-direction: column;
  align-items: center;

  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  cursor: pointer;

  font-size: 0.7rem;
  min-width: var(--thumb-minW);
  width: var(--thumb-w);
  height: auto;
  aspect-ratio: 3 / 4;
}

.thumb-button span{ margin-bottom: 4px; }

/* Front / Back thumbnails — never crop */
.thumb-button img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #e6e1d9;
}

.thumb-button.is-active{ border-color: #222; }

/* Main stage */
.image-main-wrapper{
  flex: 2;
  display: flex;
  justify-content: center;
  align-items: center;

  background: var(--modal-stage-bg);
  border-radius: 12px;

  position: relative;
  padding: 10px;

  /* 🔒 SABİT KAP DAVRANIŞI */
  aspect-ratio: 3 / 4;          /* postcard oranı */
  min-height: 70vh;             /* büyük olan referans */
  max-height: 88vh;

  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.08),
    0 18px 40px rgba(0,0,0,0.18);
}

.image-main-wrapper img{
  max-width: 100%;
  max-height: 100%;
  display: block;
  transition: transform 0.28s ease-out;
  transform-origin: 50% 50%;
}

/* Prevent jumpy zoom: disable transform animation while modal is visible */
.image-modal.is-visible #modal-image{
  transition: none !important;
  will-change: transform;
}

.image-modal.is-visible #modal-image{
  transform: translateZ(0);
}

.image-main-wrapper.is-zoomed{
  cursor: zoom-out;
  overflow: auto; /* zoom açıkken pan */
}

.image-modal-right{
  flex: 1.4;
  padding-left: 8px;
  border-left: 1px solid rgba(0,0,0,0.06);
  overflow-y: auto;
}

.image-modal-title{
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.card-meta-list{ margin: 0 0 0.75rem; }

.card-meta-list .meta-row{
  display: grid;
  grid-template-columns: 90px 1fr;
  column-gap: 0.5rem;
  row-gap: 0.15rem;
  font-size: 0.85rem;
}

.card-meta-list dt{ font-weight: 700; color: #555; }
.card-meta-list dd{ margin: 0; color: #333; }

.card-description-long{ font-size: 0.85rem; color: #444; }

.modal-tags{
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #666;
}

.modal-tag-pill{
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
  text-transform: lowercase;
}

.image-modal-close{
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.image-modal-close:hover{ background: rgba(0,0,0,0.9); }

/* arrows */
.modal-arrow{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 48px;
  border: none;
  border-radius: 24px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 5;              /* ✅ EKLE: oklar görselin üstünde kalsın */
  pointer-events: auto;    /* ✅ güvenli */
}

.modal-arrow-left{ left: 8px; }
.modal-arrow-right{ right: 8px; }
.modal-arrow:hover{ background: rgba(0,0,0,0.85); }

/* Paper texture grain */
.image-main-wrapper::before,
.postcard-image-wrapper::before{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;

  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.03),
      rgba(0,0,0,0.03) 1px,
      transparent 1px,
      transparent 2px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.02),
      rgba(0,0,0,0.02) 1px,
      transparent 1px,
      transparent 3px
    );

  opacity: var(--paper-grain-opacity);
}

/* Back card tone */
.image-main-wrapper.is-back{
  background: #D8CCBA;
}

/* Prevent drag/select on modal image */
#modal-image{
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.image-main-wrapper.is-zoomed{ cursor: grab; }
.image-main-wrapper.is-zoomed:active{ cursor: grabbing; }

/* Lock page scroll when modal open */
body.is-modal-open{
  overflow: hidden;
  touch-action: none;
}

/* Hide the mobile sidebar while modal open */
body.is-modal-open .category-sidebar{
  display: none;
}

/* -------------------------------------------------
   8) Responsive (order: 1200+ → 1100 → 768 → 480)
   ------------------------------------------------- */

/* Desktop wide “gallery spine” */
@media (min-width: 1200px){
  .category-hero .category-hero-inner{
    max-width: 1320px;
    margin-left: 64px;
    margin-right: auto;
  }

  .category-main-content{
    max-width: 920px;
  }

  /* Featured alignment hooks (only if featured exists on category page) */
  .category-main-content .featured-postcard{
    width: fit-content;
    margin: 0 0 0.6rem 24px;
    gap: 0.35rem;
  }
}

/* ≤1100: grid 3 cols */
@media (max-width: 1100px){
  :root{
    --cards-cols: 3;
  }
}

/* ==================================================
   MOBILE/TABLET (≤768px) — SINGLE BLOCK
   Sidebar dropdown + pagination + modal layout + UX
   ================================================== */
@media (max-width: 768px){
  :root{
    --cards-cols: 2; /* Mobile'de 2 sütun */
  }

  /* Base layout becomes stacked */
  .category-hero-inner{
    flex-direction: column;
    gap: 1.2rem;
  }

  /* Hide desktop title on mobile */
  .category-sidebar-title{ display: none; }

  /* Content goes below fixed bar */
  .category-main-content{
    padding-top: var(--mobile-bar-gapTop);
  }

   /* =========================
     MOBILE Dropdown – single truth
     Transparent glass, NO beige/grey ground
     ========================= */

  /* Fixed bar: ARTIK zemin yok (asıl çirkin bej kutu buydu) */
  .category-sidebar{
    position: fixed;
    top: calc(var(--headerH) + 12px);
    left: var(--mobile-bar-x);
    right: auto;
    width: var(--mobile-bar-w);
    z-index: 9999;

    background: transparent;            /* ✅ bej/gri kutu kalktı */
    border: none;                       /* istersen ince border ekleriz */
    padding: 0;                         /* bar kutusunu yok ediyoruz */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Toggle: sadece buton görünsün (pill) */
  .category-sidebar-toggle{
    display: flex;
    width: auto;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 0.5rem;

    padding: 0.42rem 0.78rem;
    border-radius: 999px;

    border: 1px solid rgba(201, 143, 120, 0.65);
    background: linear-gradient(145deg, rgba(243,230,221,0.96), rgba(216,184,164,0.96));
    color: #3b2f29;

    font-weight: 700;
    letter-spacing: 0.04em;
    -webkit-tap-highlight-color: transparent;
  }

  .category-sidebar-toggle::after{
    content: "";
    margin-left: auto;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(59,47,41,0.85);
    border-bottom: 2px solid rgba(59,47,41,0.85);
    transform: rotate(45deg);
    opacity: 0.85;
  }

  /* Dropdown panel: GERÇEK transparan cam (bej/gri tint yok) */
  .category-sidebar-menu{
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);

    border-radius: 18px;
    padding: 10px;

    /* ✅ “bej/gri zemin”i yaratan şey bu tint idi.
       Çok düşük alpha ile blur aktif, ama renk basmıyor. */
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid rgba(255,255,255,0.22);
    box-shadow: 0 18px 40px rgba(0,0,0,0.22);

    max-height: 60vh;
    overflow: auto;
  }

  .category-sidebar-menu.is-open{ display: block; }

  /* Scrollbar: bej çerçeve yok */
  .category-sidebar-menu::-webkit-scrollbar{ width: 10px; }
  .category-sidebar-menu::-webkit-scrollbar-thumb{
    background: rgba(201,143,120,0.35);
    border-radius: 999px;
    border: 0;
  }
  /* Pagination mobile */
  .pagination-bar{
    border-radius: 18px;
    padding: 0.55rem 0.7rem;
  }
  .pagination-pages{
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .pagination-total{
    width: 100%;
    text-align: left;
  }
  .pagination-size{
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  /* Modal: stacked layout */
  .image-modal-dialog{
    width: 96vw;
    max-width: 96vw;
    padding: 12px 12px;
  }

  .image-modal-body.layout{
    flex-direction: column;
    gap: 10px;
    overflow: visible; /* whole dialog scrolls */
  }

  .image-modal-left{
    flex: none;
    flex-direction: column;
  }

  .image-thumbs{
    flex-direction: row;
    gap: 10px;
    justify-content: center;
  }

  .thumb-button{
    width: 120px;
    aspect-ratio: 3 / 4;
    padding: 6px;
  }

  /* Main stage larger */
  .image-main-wrapper{
    width: 100%;
    min-height: 62vh;
    max-height: 68vh;
    padding: 8px;
  }

  .image-modal-right{
    border-left: none;
    padding-left: 0;
    overflow: visible;
    max-height: none;
  }

  /* Bigger tap targets */
  #modal-close,
  #modal-focus,
  .modal-arrow{
    min-width: 44px;
    min-height: 44px;
  }
  .modal-arrow{
    width: 48px;
    height: 48px;
  }

  /* Touch behavior for zoom/pan */
  #image-main-wrapper{
    touch-action: manipulation;
  }
  #image-main-wrapper.is-zoomed{
    touch-action: none;
  }

  /* Prevent arrows jumping on tap */
  .image-modal.is-visible .modal-arrow{
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
  }
  .image-modal.is-visible .modal-arrow:active{
    opacity: 0.85;
  }

  /* Mobile badge: show the opposite side (Front/Back swap)
     - If main image is FRONT: show BACK badge
     - If main image is BACK : show FRONT badge
     Uses :has(.image-main-wrapper.is-back) so no JS change needed (Chrome/Edge support).
  */

  /* thumbs strip should feel "invisible" */
  .image-thumbs{
    display: block;
    padding: 0;
    margin: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
    max-width: none;
  }

  /* Both badges share same look */
  #thumb-front,
  #thumb-back{
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    z-index: 10055;

    width: 52px;
    height: 70px;
    padding: 6px;
    border-radius: 14px;

    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

/* Badge: remove any Back/Front text + label remnants */
#thumb-front,
#thumb-back{
  font-size: 0 !important;
  line-height: 0 !important;
}

#thumb-front span,
#thumb-back span,
#thumb-front .label,
#thumb-back .label,
#thumb-front .thumb-label,
#thumb-back .thumb-label,
#thumb-front .thumb-title,
#thumb-back .thumb-title{
  display: none !important;
}

  #thumb-front img,
  #thumb-back img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    display: block;
  }

 /* Default: hide both (reliable) */
#thumb-front,
#thumb-back{ 
  display: none !important; 
}

/* Reliable swap: drive with a modal class, not :has() */
/* If modal shows BACK -> show FRONT badge */
.image-modal.is-visible.is-back-view #thumb-front{ 
  display: block !important; 
}

/* If modal shows FRONT -> show BACK badge */
.image-modal.is-visible:not(.is-back-view) #thumb-back{ 
  display: block !important; 
}

  /* Hide mobile arrows if swipe is used */
  .modal-nav-prev,
  .modal-nav-next{
    display: none;
  }
  #arrow-prev,
  #arrow-next{
    display: none;
  }

  /* Safe-area for Close button */
  .image-modal.is-visible .image-modal-close{
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    z-index: 10060;
  }
}

/* ≤480: grid becomes 1 col + smaller thumbs */
@media (max-width: 480px){
  :root{
    --cards-cols: 1;
  }

  .thumb-button{
    width: 75px;
    padding: 5px;
  }
}

/* -------------------------------------------------
   9) Focus Mode (kept, but organized)
   ------------------------------------------------- */
.image-modal.is-focus .image-modal-dialog{
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  padding: 0;
  border-radius: 0;
  background: var(--modal-stage-bg);
}

.image-modal.is-focus .image-modal-right{ display: none; }

.image-modal.is-focus .image-modal-left{
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
}

.image-modal.is-focus .image-thumbs{
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 10;
  background: rgba(247,244,239,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 8px;
}

.image-modal.is-focus .image-main-wrapper{
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.image-modal.is-focus #modal-image{
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.image-modal.is-focus .image-modal-body.layout,
.image-modal.is-focus .image-modal-left{
  padding: 0;
  margin: 0;
  background: transparent;
}