/*
Theme Name: FB Gallery
Description: Theme dang Facebook profile - sidebar trai la danh sach tac gia, main la dong bai viet, xem anh full man hinh cuon doc het album.
Version: 1.0
Text Domain: fbgallery
*/

:root {
  --fb-blue:   #1877f2;
  --bg:        #f0f2f5;
  --card:      #ffffff;
  --text:      #1c1e21;
  --text-2:    #65676b;
  --line:      #ced0d4;
  --hover:     #f2f2f2;
  --radius:    10px;

  /* bong nhieu lop cho co chieu sau, khong phai 1 vien xam bet */
  --bong-1: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --bong-2: 0 2px 4px rgba(16,24,40,.06), 0 8px 20px rgba(16,24,40,.10);
  --bong-3: 0 4px 8px rgba(16,24,40,.07), 0 18px 40px rgba(16,24,40,.14);
  --nhanh: .18s cubic-bezier(.4,0,.2,1);
  --cham:  .35s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.44 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* -------------------------------------------------------------------- menu */
/* Nam tren cung cot main, bam dinh man hinh khi cuon. */
.fb-nav {
  position: sticky; top: 8px; z-index: 60;
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px; padding: 8px;
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  backdrop-filter: saturate(1.6) blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--bong-1);
}
.fb-nav a {
  padding: 8px 14px; border-radius: var(--radius);
  color: var(--text-2); font-weight: 600;
  transition: background var(--nhanh), color var(--nhanh);
}
.fb-nav a:hover { background: var(--hover); }
.fb-nav a.active { color: var(--fb-blue); background: #e7f0fe; }

/* --------------------------------------------------------------- o logo --- */
.logo-card {
  display: block; text-align: center; padding: 18px 16px;
  background: linear-gradient(160deg, #e7f0fe 0%, var(--card) 74%);
  transition: box-shadow var(--cham);
}
.logo-card:hover { box-shadow: var(--bong-2); }
.logo-card img { max-height: 46px; width: auto; margin: 0 auto 6px; }
.logo-card .mark {
  width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--fb-blue); color: #fff;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
  box-shadow: var(--bong-2);
}
.logo-card .ten { display: block; font-size: 19px; font-weight: 700; }
.logo-card .mota {
  display: block; margin-top: 4px; font-size: 13px; color: var(--text-2);
}

/* ------------------------------------------------------------------ layout */
.fb-wrap {
  max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px;
  display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start;
}
/* Cot trai cao het noi dung cua no, KHONG co thanh cuon rieng.
 * JavaScript ghim no lai: keo xuong thi giu chan, keo len thi giu dau.
 * Khong co JavaScript thi lui ve sticky thuong - van dung, chi kem muot.
 */
.fb-side { position: sticky; top: 20px; align-self: start; }
.js .fb-side { position: static; }
.js .fb-side-in { will-change: transform; }

/* ----------------------------------------------------------------- sidebar */
.side-card {
  background: var(--card); border-radius: var(--radius); padding: 12px;
  box-shadow: var(--bong-1); margin-bottom: 16px;
}
.side-card h2 {
  margin: 4px 8px 10px; font-size: 17px; color: var(--text-2);
}
/* luoi model 5 cot */
.model-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.model-item {
  position: relative; display: block; padding: 6px 2px 5px;
  border-radius: var(--radius); text-align: center; min-width: 0;
}
.model-item:hover { background: var(--hover); }
.model-item.current { background: #e7f0fe; }
.model-item .ava { display: block; }
.model-item .av,
.model-item img {
  width: 100%; aspect-ratio: 1 / 1; height: auto;
  border-radius: 50%; object-fit: cover; display: block;
}
.model-item .av {
  display: grid; place-items: center; background: var(--fb-blue);
  color: #fff; font-weight: 700; font-size: 18px;
}
.model-item .nm {
  display: block; margin-top: 4px; font-size: 11px; line-height: 1.35;
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-item .cnt {
  position: absolute; top: 2px; right: 0;
  min-width: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--fb-blue); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px;
}


/* --------------------------------------------- bang thong tin cua model ---
 * Chi hien o trang cua 1 model, nam tren cung cot trai.
 */
.model-card { padding: 0; overflow: hidden; }

.mc-top {
  position: relative; padding: 20px 16px 14px; text-align: center;
  background: linear-gradient(160deg, #e7f0fe 0%, var(--card) 72%);
}
.mc-top .avatar, .mc-top .av {
  width: 96px; height: 96px; margin: 0 auto 10px;
  border-radius: 50%; object-fit: cover;
  border: 3px solid var(--card);
  box-shadow: var(--bong-2);
}
.mc-top .av {
  display: grid; place-items: center;
  background: var(--fb-blue); color: #fff; font-size: 38px; font-weight: 700;
}
.mc-ten { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); }
.mc-uid { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.mc-so {
  display: flex; border-top: 1px solid rgba(16,24,40,.08);
  border-bottom: 1px solid rgba(16,24,40,.08);
}
.mc-so div {
  flex: 1; padding: 10px 4px; text-align: center;
  border-left: 1px solid rgba(16,24,40,.06);
}
.mc-so div:first-child { border-left: 0; }
.mc-so b { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; }
.mc-so span { font-size: 12px; color: var(--text-2); }

.mc-bio {
  margin: 12px 16px 0; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}

.mc-gt { margin: 10px 16px 0; padding: 0; list-style: none; }
.mc-gt li {
  position: relative; padding-left: 16px; margin-bottom: 3px;
  font-size: 13px; color: var(--text-2);
}
.mc-gt li::before {
  content: ""; position: absolute; left: 4px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--fb-blue);
  opacity: .55;
}

.mc-link { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 16px 0; }
.mc-link a {
  padding: 4px 10px; border-radius: 999px; background: var(--hover);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  transition: background var(--nhanh), color var(--nhanh);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mc-link a:hover { background: #e7f0fe; color: var(--fb-blue); }

.mc-phu { margin: 10px 16px 0; font-size: 12px; color: var(--text-2); }

.mc-fb {
  display: block; margin: 14px 16px 16px; padding: 9px 0;
  border-radius: var(--radius); text-align: center;
  background: var(--fb-blue); color: #fff; font-weight: 600; font-size: 14px;
  transition: filter var(--nhanh), transform var(--nhanh);
}
.mc-fb:hover { filter: brightness(1.08); }
.mc-fb:active { transform: scale(.98); }

/* luoi bai noi bat 3 cot */
.hot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.hot-item {
  position: relative; display: block; aspect-ratio: 1 / 1;
  overflow: hidden; border-radius: 6px; background: #e4e6eb;
}
.hot-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hot-item:hover img { filter: brightness(.9); }

/* -------------------------------------------------------------- post cards */
.post-card {
  background: var(--card); border-radius: var(--radius); margin-bottom: 20px;
  box-shadow: var(--bong-1); overflow: hidden;
  transition: box-shadow var(--cham), transform var(--cham);
}
.post-card:hover { box-shadow: var(--bong-2); transform: translateY(-1px); }
.post-head {
  position: relative;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
}

/* nut xoa nhanh, chi hien voi nguoi du quyen */
.fbg-del {
  position: absolute; top: 8px; right: 10px; z-index: 4;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--text-2); font-size: 22px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s;
}
.fbg-del:hover { background: #fde8e8; color: #c72d2d; }
.fbg-del:disabled { opacity: .5; cursor: default; }

/* nut xoa 1 tam anh, nam trong o anh o trang bai */
.fbg-del-img {
  position: absolute; top: 10px; right: 10px; z-index: 4;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s, background .15s;
}
.cell:hover .fbg-del-img,
.fbg-del-img:focus { opacity: 1; }
.fbg-del-img:hover { background: #c72d2d; }
.fbg-del-img:disabled { opacity: .5; cursor: default; }

/* man hinh cham: khong co rê chuot nen cu hien san */
@media (hover: none) {
  .fbg-del-img { opacity: .85; }
}

.post-card.dang-xoa, .cell.dang-xoa { opacity: .5; pointer-events: none; }
.post-card.da-xoa, .cell.da-xoa {
  opacity: 0; transform: scale(.97);
  transition: opacity .2s, transform .2s;
}
.post-head .av, .post-head img.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
}
.post-head .av { display: grid; place-items: center; background: var(--fb-blue); color: #fff; font-weight: 700; }
.post-head .nm { font-weight: 600; }
.post-head .tm { font-size: 12px; color: var(--text-2); }
.post-text { padding: 0 16px 12px; white-space: pre-wrap; word-wrap: break-word; }
.post-text a.more { color: var(--fb-blue); font-weight: 600; }

/* luoi anh kieu Facebook */
.grid { display: grid; gap: 2px; background: var(--card); cursor: pointer; }
.grid .cell { position: relative; overflow: hidden; background: #e4e6eb; }
.grid .cell img { width: 100%; height: 100%; object-fit: cover; }
.grid .cell:hover img { filter: brightness(.94); }

.grid.g1 { grid-template-columns: 1fr; }
.grid.g1 .cell { max-height: 640px; }
.grid.g1 .cell img { height: auto; max-height: 640px; object-fit: contain; background: #000; }

.grid.g2 { grid-template-columns: 1fr 1fr; }
.grid.g2 .cell { aspect-ratio: 1 / 1; }

.grid.g3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.grid.g3 .cell:nth-child(1) { grid-row: span 2; aspect-ratio: auto; height: 100%; }
.grid.g3 .cell { aspect-ratio: 1 / 1; }
.grid.g3 { aspect-ratio: 3 / 2; }

.grid.g4 { grid-template-columns: 1fr 1fr; }
.grid.g4 .cell { aspect-ratio: 1 / 1; }

.grid.g5 { grid-template-columns: repeat(6, 1fr); }
.grid.g5 .cell:nth-child(1), .grid.g5 .cell:nth-child(2) { grid-column: span 3; aspect-ratio: 3 / 2; }
.grid.g5 .cell:nth-child(n+3) { grid-column: span 2; aspect-ratio: 1 / 1; }

/* nhan diem ho hang de tren goc anh - mau cang nong cang de thay */
.media { position: relative; }

.score-badge {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.7;
  color: #fff; background: rgba(0,0,0,.6);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  cursor: help; white-space: nowrap;
}
.score-badge.safe { background: rgba(45,138,86,.92); }
.score-badge.rev  { background: rgba(214,124,20,.94); }
.score-badge.exp  { background: rgba(199,45,45,.94); }

/* trong che do thu vien: nho lai, khong chan cu bam vao anh */
.photo-cell { position: relative; }
.score-badge.sm {
  top: 6px; left: 6px; padding: 1px 7px;
  font-size: 11px; pointer-events: none;
}

/* Kieu "hang": anh doc xep ngang, cao bang nhau, cat vua o.
   So cot lay theo lop n1..n5 de bai it anh khong bi hut cot. */
.grid.gr { --h: 420px; }
.grid.gr .cell { height: var(--h); aspect-ratio: auto; }
.grid.gr.n1 { grid-template-columns: 1fr; }
.grid.gr.n2 { grid-template-columns: repeat(2, 1fr); }
.grid.gr.n3 { grid-template-columns: repeat(3, 1fr); }
.grid.gr.n4 { grid-template-columns: repeat(4, 1fr); }
.grid.gr.n5 { grid-template-columns: repeat(5, 1fr); }

/* 1 tam thi de nguyen kho, cat mot tam chan dung thanh dai ngang la mat dau */
.grid.gr.n1 .cell { height: auto; max-height: 640px; }
.grid.gr.n1 .cell img {
  height: auto; max-height: 640px; object-fit: contain; background: #000;
}

.cell .more-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff;
  display: grid; place-items: center; font-size: 30px; font-weight: 700;
}

.post-foot {
  display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid #e4e6eb;
  color: var(--text-2); font-size: 13px;
}

/* --------------------------------------------------------- gallery ca trang */
.photo-grid {
  /* 5 o moi hang: cot chinh 768px -> moi o ~152px, dung bang kho thumbnail */
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.photo-grid a { display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 6px; background: #e4e6eb; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid a:hover img { filter: brightness(.92); }


/* ------------------------------------------------ anh hien len muot ---
 * O anh co nen xam chay nhe khi dang tai, anh tai xong thi mo dan len.
 * Chi ap dung khi JavaScript chay duoc (the <html class="js">), khong thi
 * tat JS se thanh trang trang khong thay anh nao.
 */
.js .cell img,
.js .photo-cell img,
.js .hot-item img,
.js .model-item img {
  opacity: 0;
  transition: opacity var(--cham), transform var(--cham);
}
.js .cell img.hien,
.js .photo-cell img.hien,
.js .hot-item img.hien,
.js .model-item img.hien { opacity: 1; }

/* nen chay khi cho anh */
.js .cell:not(.xong),
.js .photo-cell:not(.xong),
.js .hot-item:not(.xong) {
  background-image: linear-gradient(100deg,
      #e7e9ec 30%, #f3f4f6 50%, #e7e9ec 70%);
  background-size: 220% 100%;
  animation: fbg-cho 1.3s ease-in-out infinite;
}
@keyframes fbg-cho {
  from { background-position: 130% 0; }
  to   { background-position: -30% 0; }
}

/* o anh phong to nhe khi re chuot - co chieu sau hon la chi lam toi di */
.photo-cell, .hot-item, .grid .cell { transition: transform var(--nhanh); }
.photo-cell img, .hot-item img, .grid .cell img {
  transition: opacity var(--cham), transform var(--cham), filter var(--nhanh);
}
.photo-cell:hover img, .hot-item:hover img { transform: scale(1.06); }
.grid .cell:hover img { transform: scale(1.03); }

/* avatar model nhun nhe */
.model-item { transition: transform var(--nhanh), background var(--nhanh); }
.model-item:hover { transform: translateY(-2px); }
.model-item .av, .model-item img { box-shadow: 0 1px 3px rgba(16,24,40,.18); }

/* nhan diem ro hon tren nen anh sang */
.score-badge { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

/* nut o thanh loc va phan trang nhun nhe */
.filter-bar a { transition: background var(--nhanh), transform var(--nhanh); }
.filter-bar a:active { transform: scale(.96); }

@media (prefers-reduced-motion: reduce) {
  .js .cell img, .js .photo-cell img, .js .hot-item img, .js .model-item img {
    opacity: 1; transition: none;
  }
  .js .cell:not(.xong), .js .photo-cell:not(.xong), .js .hot-item:not(.xong) {
    animation: none;
  }
  .post-card, .model-item, .photo-cell img, .hot-item img, .grid .cell img {
    transition: none;
  }
  .post-card:hover { transform: none; }
  .photo-cell:hover img, .hot-item:hover img, .grid .cell:hover img { transform: none; }
}

/* --------------------------------------------------------------- lightbox */
.lb {
  position: fixed; inset: 0; background: rgba(0,0,0,.97); z-index: 999;
  display: none; overflow-y: auto; overscroll-behavior: contain;
}
.lb.open { display: block; }
.lb-bar {
  position: sticky; top: 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; color: #fff; background: linear-gradient(rgba(0,0,0,.75), transparent);
  z-index: 2;
}
.lb-bar .t { font-weight: 600; }
.lb-bar .c { color: #b0b3b8; font-size: 13px; }
.lb-bar .x {
  margin-left: auto; width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff; font-size: 22px; cursor: pointer;
}
.lb-bar .x:hover { background: rgba(255,255,255,.28); }
.lb-body { padding: 0 16px 60px; display: flex; flex-direction: column;
           align-items: center; gap: 18px; }
.lb-body figure { margin: 0; max-width: 1100px; width: 100%; }
.lb-body img { width: auto; max-width: 100%; max-height: 92vh; margin: 0 auto; }
.lb-body figcaption { color: #b0b3b8; font-size: 12px; text-align: center; padding-top: 6px; }
.lb-hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  color: #fff; background: rgba(0,0,0,.6); padding: 6px 14px; border-radius: 20px;
  font-size: 12px; pointer-events: none;
}
body.lb-lock { overflow: hidden; }

/* ------------------------------------------------------------ phan trang */
/* ------------------------------------------------------- trang bai HOT --- */
.hot-head {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.hot-head .page-title { margin: 0 0 10px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-bar a {
  padding: 6px 14px; border-radius: 999px; background: var(--hover);
  font-size: 14px; font-weight: 600; color: var(--text-2);
}
.filter-bar a:hover { background: #dfe3e8; }
.filter-bar a.active { background: var(--fb-blue); color: #fff; }

/* vung bao hieu dang tai them khi cuon */
.fbg-more {
  min-height: 60px; display: grid; place-items: center;
  padding: 14px 0 40px; color: var(--text-2); font-size: 14px;
}
.fbg-more .spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid #d8dade; border-top-color: var(--fb-blue);
  opacity: 0; transition: opacity .15s;
}
.fbg-more.on .spin { opacity: 1; animation: fbg-spin .7s linear infinite; }
.fbg-more.het { font-weight: 600; }
.fbg-more.loi .spin { border-top-color: #c72d2d; }
@keyframes fbg-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .fbg-more.on .spin { animation: none; }
}

.pager { display: flex; gap: 8px; justify-content: center; padding: 8px 0 30px; }
.pager a, .pager span {
  padding: 8px 14px; background: var(--card); border-radius: var(--radius); font-weight: 600;
}
.pager .current { background: var(--fb-blue); color: #fff; }

.empty { background: var(--card); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--text-2); }

.page-title { font-size: 22px; margin: 0 0 16px; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 900px) {
  .fb-wrap { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .fb-side { position: static; }
  /* man hinh hep: 5 cot qua chat -> giai it cot hon, o to hon */
  .model-grid { grid-template-columns: repeat(6, 1fr); }
  .hot-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 520px) {
  .model-grid { grid-template-columns: repeat(4, 1fr); }
  .hot-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  /* dien thoai: hang anh thap lai, 5 cot thanh soi chi -> ha xuong 3 */
  .grid.gr { --h: 240px; }
  .grid.gr.n4, .grid.gr.n5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) and (min-width: 521px) {
  .grid.gr { --h: 330px; }
}
