/* magnumx.me — default theme
   สี ฟอนต์ และขนาดหลักมาจาก CSS variables ที่แอดมินตั้งค่าได้ใน "ปรับแต่งธีม" */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.3; margin: 0 0 .5em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 24px; }
.container.narrow { max-width: 800px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.btn {
  display: inline-block;
  padding: 12px 30px;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: max(var(--radius), 2px);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .04em;
  transition: opacity .2s, transform .2s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }

/* ---------- Hero / Header ---------- */
.hero {
  position: relative;
  min-height: 380px;
  height: var(--hero-h);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
}
.hero-media { position: absolute; inset: 0; z-index: -2; }
.hero-img { width: 100%; height: 100%; object-fit: cover; object-position: var(--hero-focus); }
.hero-shade {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.25) 0%, transparent 30%, transparent 55%, rgba(0,0,0,.45) 100%),
    rgba(0,0,0, var(--hero-overlay));
}
.hero-noimg { background: var(--surface); color: var(--text); }
.hero-noimg .hero-shade { display: none; }
.hero-inner { text-align: center; padding-block: 48px; }
.hero-title {
  font-size: clamp(34px, 7.4vw, var(--title-size));
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0;
  text-shadow: 0 2px 24px rgba(0,0,0,.35);
  text-wrap: balance;
}
.hero-subtitle { margin: 14px auto 0; max-width: 640px; font-size: clamp(15px, 2.2vw, 18px); opacity: .9; text-wrap: balance; }
.hero-btn { margin-top: 26px; background: transparent; color: #fff; border-color: rgba(255,255,255,.8); }
.hero-noimg .hero-btn { color: var(--text); border-color: var(--text); }
.hero-btn:hover { background: #fff; color: #111; opacity: 1; }
.hero-brand {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-head);
  font-size: 13px; letter-spacing: .32em; text-transform: uppercase; font-weight: 600;
  color: inherit; opacity: .92;
}
.hero-brand .brand-logo { height: 40px; width: auto; }
.hero-align-left { justify-content: flex-start; align-items: flex-end; }
.hero-align-left .hero-inner { text-align: left; margin: 0; max-width: none; padding-bottom: clamp(40px, 8vh, 80px); }
.hero-align-left .hero-subtitle { margin-left: 0; }
.hero-align-left .hero-brand { left: 24px; transform: none; }
.hero-align-bottom { align-items: flex-end; }
/* ตำแหน่งกำหนดเอง (ลากวางใน Customizer): ยึดจุดตามสัดส่วน ข้อความจึงไม่หลุดขอบภาพ */
.hero-align-custom { display: block; }
.hero-align-custom .hero-inner {
  position: absolute;
  left: var(--hero-x); top: var(--hero-y);
  transform: translate(calc(var(--hero-x) * -1), calc(var(--hero-y) * -1));
  width: max-content; max-width: min(92%, 960px);
  margin: 0; padding: clamp(16px, 4vw, 40px);
  text-align: var(--hero-text-align);
}
.hero-align-custom .hero-subtitle { max-width: none; margin-inline: 0; }
.hero-align-bottom .hero-inner { padding-bottom: clamp(40px, 8vh, 80px); }

/* ---------- Menu bar (เส้นแบ่งระหว่าง Header และ Single Pose) ---------- */
.menubar { background: var(--bg); z-index: 30; }
.menubar.is-sticky {
  position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}
.menubar-list {
  list-style: none; margin: 0 auto; padding: 0 16px;
  max-width: var(--container);
  display: flex; justify-content: safe center; gap: clamp(18px, 5vw, 56px);
  overflow-x: auto; scrollbar-width: none;
}
.menubar-list::-webkit-scrollbar { display: none; }
.menubar-list a {
  display: block; white-space: nowrap;
  padding: 17px 2px 15px;
  font-size: 14px; font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.menubar-upper .menubar-list a { text-transform: uppercase; letter-spacing: .08em; font-size: 13.5px; }
.menubar-list a:hover, .menubar-list a[aria-current] { color: var(--text); }
.menubar-list a[aria-current] { border-bottom-color: var(--text); }
.menubar-lines .menubar { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.menubar-pills .menubar-list { padding-block: 14px; gap: 10px; }
.menubar-pills .menubar-list a { padding: 7px 18px; border: 1px solid var(--line); border-radius: 999px; }
.menubar-pills .menubar-list a:hover, .menubar-pills .menubar-list a[aria-current] { border-color: var(--text); }

/* ---------- Pose grid (3 คอลัมน์แบบ IG) ---------- */
.poses { padding-bottom: 56px; }
.section-title {
  text-align: center;
  font-family: var(--font-body);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--muted);
  margin: 40px 0 22px;
}
.pose-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
}
.pose-card a { display: block; position: relative; }
.pose-cover {
  margin: 0;
  aspect-ratio: var(--ratio);
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
}
.pose-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s cubic-bezier(.2,.7,.2,1), filter .3s; }
.pose-cover.focus-top img { object-position: center top; }
.pose-cover.focus-bottom img { object-position: center bottom; }
.pose-card a:hover .pose-cover img { transform: scale(1.04); }
.pose-noimg { display: block; width: 100%; height: 100%; }
.pose-title {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 36px 14px 12px;
  color: #fff; font-size: 15px; font-weight: 500; line-height: 1.4;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  border-radius: 0 0 var(--radius) var(--radius);
  pointer-events: none;
  transition: opacity .3s;
}
.title-hover .pose-title { opacity: 0; }
.title-hover .pose-card a:hover .pose-title, .title-hover .pose-card a:focus-visible .pose-title { opacity: 1; }
@media (hover: none) { .title-hover .pose-title { opacity: 1; } }
.title-below .pose-title { position: static; background: none; color: var(--text); padding: 8px 2px 6px; }
.title-hidden .pose-title { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 24px; margin-top: 36px; color: var(--muted); font-size: 14px; }
.pagination a { color: var(--text); border-bottom: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.intro { text-align: center; padding-block: 40px 8px; color: var(--muted); }

/* ---------- Header สำหรับหน้าด้านใน ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 64px; }
.brand { font-family: var(--font-head); font-weight: 600; letter-spacing: .28em; text-transform: uppercase; font-size: 14px; white-space: nowrap; }
.brand .brand-logo { height: 36px; width: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: clamp(16px, 3vw, 36px); }
.site-nav a { color: var(--muted); font-size: 14px; white-space: nowrap; transition: color .2s; }
.menubar-upper .site-nav a { text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--text); }

/* ---------- Single pose / page ---------- */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 0; font-size: 13px; color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.entry-header { text-align: center; margin: 28px auto 32px; max-width: 760px; }
.entry-title { font-size: clamp(30px, 5vw, 46px); margin: 0; text-wrap: balance; }
.entry-date { display: block; margin-top: 8px; color: var(--muted); font-size: 14px; }
.content { max-width: 720px; margin-inline: auto; }
.content > :first-child { margin-top: 0; }
.content p { margin: 0 0 1.1em; }
.content h2 { font-size: 1.6em; margin-top: 1.6em; }
.content h3 { font-size: 1.3em; margin-top: 1.4em; }
.content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.content img { margin: 1.4em auto; border-radius: var(--radius); }
.content blockquote { margin: 1.5em 0; padding: 4px 0 4px 20px; border-left: 2px solid var(--accent); color: var(--muted); font-style: italic; }
.content ul, .content ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.content table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 15px; }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; }
.content iframe { max-width: 100%; }
.entry-content + .gallery { margin-top: 36px; }

.gallery { columns: var(--gallery-cols); column-gap: 12px; margin-top: 8px; }
.gallery-item { display: block; margin-bottom: 12px; break-inside: avoid; overflow: hidden; border-radius: var(--radius); background: var(--surface); cursor: zoom-in; }
.gallery-item img { width: 100%; transition: opacity .3s; }
.gallery-item:hover img { opacity: .92; }
.gallery-single { columns: 1; max-width: 760px; margin-inline: auto; }
.cta { text-align: center; margin: 44px 0 8px; }
.related { margin-top: 64px; border-top: 1px solid var(--line); padding-bottom: 32px; }
.page-cover { margin: 0 0 32px; }
.page-cover img { width: 100%; border-radius: var(--radius); }
.single-page { padding-bottom: 72px; }

.not-found { text-align: center; padding: 12vh 0; }
.nf-code { font-family: var(--font-head); font-size: 88px; line-height: 1; margin: 0 0 12px; color: var(--line); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 40px 0 48px; text-align: center; color: var(--muted); font-size: 14px; }
.site-footer p { margin: 6px 0; }
.social { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 14px; }
.social a, .contact a { color: var(--text); }
.contact { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }

/* ---------- Admin bar (เห็นเฉพาะแอดมิน) ---------- */
.admin-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 900;
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  padding: 6px; border-radius: 12px;
  background: rgba(20,20,20,.92); color: #fff;
  font: 13px/1.4 system-ui, sans-serif;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.admin-bar a { padding: 6px 10px; border-radius: 8px; }
.admin-bar a:hover { background: rgba(255,255,255,.12); }
.admin-bar-draft { padding: 6px 10px; color: #ffcf70; }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 1000; background: rgba(8,8,8,.95); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lb[hidden] { display: none; }
.lb img { max-width: 94vw; max-height: 88vh; width: auto; height: auto; object-fit: contain; user-select: none; }
.lb button { position: absolute; background: none; border: 0; color: #fff; font-size: 28px; padding: 16px; cursor: pointer; opacity: .8; line-height: 1; }
.lb button:hover { opacity: 1; }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 4px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 4px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.7); font-size: 13px; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .container { padding-inline: 16px; }
  .poses .container, .related .container { padding-inline: 0; }
  .pose-grid { grid-template-columns: repeat(var(--cols-m), minmax(0, 1fr)); gap: min(var(--gap), 3px); }
  .pose-title { font-size: 12px; padding: 22px 8px 7px; }
  .title-below .pose-title { padding: 6px 6px 4px; }
  .section-title { margin: 28px 0 16px; }
  .pagination { padding-inline: 16px; }
  .site-header-inner { flex-direction: column; align-items: stretch; gap: 0; min-height: 0; padding-top: 12px; }
  .brand { text-align: center; }
  .site-nav ul { overflow-x: auto; scrollbar-width: none; justify-content: safe center; padding: 10px 0 12px; }
  .gallery { columns: 1; }
  .entry-header { margin: 20px auto 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
