/* The Art of Luo Pan 羅盤 — collection gallery blocks.
   Page chrome (two-column layout, sidebar, related posts) comes from post-feng-shui.css;
   theme tokens come from the shared body.page-light scope. */

/* Centered colophon title: cinnabar Chinese characters and a gold
   hairline-and-diamond ornament between title and meta */
.luopan-header {
  text-align: center;
}

.luopan-page-title {
  font-size: clamp(2rem, 3.5vw + 1rem, 2.6rem);
  letter-spacing: 0.02em;
}

/* On mobile the article stylesheet pins .post-title-custom to a fixed 2rem,
   which wraps this long title onto two lines; scale it with the viewport at
   the largest size that still keeps "The Art of Luo Pan 羅盤" on one line
   (the fit-text script in luopan.php trims it further if a wider fallback
   font is active before the webfont swaps in) */
@media (max-width: 768px) {
  .luopan-page-title {
    font-size: clamp(1.35rem, calc(7.6vw - 0.5px), 2.6rem);
    white-space: nowrap;
  }
}

.luopan-title-cn {
  margin-left: 0.35rem;
  color: var(--cinnabar);
}

.luopan-title-ornament {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(320px, 70%);
  margin: 0 auto 20px;
}

.luopan-title-ornament::before,
.luopan-title-ornament::after {
  content: "";
  flex: 1;
  height: 1px;
}

.luopan-title-ornament::before {
  background: linear-gradient(90deg, rgba(201, 162, 39, 0), #C9A227);
}

.luopan-title-ornament::after {
  background: linear-gradient(90deg, #C9A227, rgba(201, 162, 39, 0));
}

.luopan-title-ornament span {
  width: 7px;
  height: 7px;
  background: #C9A227;
  transform: rotate(45deg);
}

.luopan-header .post-meta-custom {
  justify-content: center;
}

/* Sidebar featured image (desktop): overlay blocks right-click save
   without editing the shared post-right-column component. */
.post-right-column .sidebar-image-container {
  position: relative;
}

.post-right-column .sidebar-image-container::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
}

/* Mobile: lead with the collection's main image instead of leaving it
   in the sidebar stack at the bottom; lazy + display:none means each
   device only downloads the copy it actually shows */
.luopan-mobile-hero {
  display: none;
}

@media (max-width: 992px) {
  .luopan-mobile-hero {
    display: block;
    position: relative;
    margin: 0 0 28px;
  }

  .luopan-mobile-hero img {
    display: block;
    width: 100%;
    height: auto;
  }

  .luopan-hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: transparent;
  }

  .post-right-column .sidebar-image-container {
    display: none;
  }
}

.luopan-category {
  margin: 2.25rem 0 2.75rem;
}

/* Category headings reuse the article section-heading design (ink text + red left bar) */
.post-content-custom h3.luopan-category-title {
  display: flex;
  align-items: baseline;
  /* Let the Chinese label drop to a second line on narrow phones instead of
     being pushed past the container edge */
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 40px 0 30px;
  border-left: 6px solid var(--cinnabar);
  padding-left: 20px;
  color: #1A1A1A;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
}

/* The collection heading is the page title, not a section: no red bar */
.post-content-custom h2#collection {
  border-left: 0;
  padding-left: 0;
}

/* Keep "On this page" jumps below the sticky site header so the heading
   stays visible instead of landing under the nav. */
html.page-luopan {
  scroll-padding-top: 100px;
}

#collection,
.luopan-category-title {
  scroll-margin-top: 100px;
}

.luopan-category-cn {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
}

.luopan-category-desc {
  max-width: 60rem;
  margin: 0.4rem 0 1.25rem;
  color: var(--text-3);
  line-height: 1.7;
}

.luopan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* Tile wrapper: holds the square tile button + optional caption label below */
.luopan-tile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.luopan-tile-label {
  font-size: 0.82rem;
  color: #5A4E42;
  text-align: center;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.luopan-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.luopan-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

/* Transparent overlay: sits above the image so right-click hits the
   overlay (no "Save image as…") instead of the <img>. Clicks still
   bubble up to the tile button for the lightbox. */
.luopan-tile-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
}

.luopan-tile:hover,
.luopan-tile:focus-visible {
  border-color: rgba(201, 162, 39, 0.65);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  transform: translateY(-3px);
}

.luopan-tile:hover img,
.luopan-tile:focus-visible img {
  transform: scale(1.05);
}

.luopan-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.luopan-empty {
  padding: 2.25rem 1.5rem;
  border: 1px dashed rgba(201, 162, 39, 0.35);
  border-radius: 12px;
  color: var(--text-3);
  font-style: italic;
  text-align: center;
}

/* Contact CTA band before the related posts: the faded Luo Pan plate
   (luopan_bg.jpg) sits as a watermark on the right. multiply blends its
   white backdrop into the cream panel, and the mask fades it out towards
   the text column so the ink copy stays readable. */
.luopan-cta {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 3.25rem 0 2.75rem;
  padding: 3rem 2.75rem;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 14px;
  background: #FCF8EF;
}

.luopan-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* Oversized plate hung off the bottom-right corner: the calc() offset
     pushes its right edge past the band edge, and the negative top offset
     clips the plate's faded halo so it runs flush to the band's top edge */
  background: url("/assets/img/luopan/luopan_bg.jpg") calc(100% + 110px) -18px / auto 150% no-repeat;
  opacity: 0.55;
  mix-blend-mode: multiply;
  -webkit-mask-image: linear-gradient(100deg, transparent 20%, rgba(0, 0, 0, 0.5) 55%, #000 85%);
  mask-image: linear-gradient(100deg, transparent 20%, rgba(0, 0, 0, 0.5) 55%, #000 85%);
}

.luopan-cta-eyebrow {
  margin: 0 0 0.55rem;
  color: var(--cinnabar);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.luopan-cta-title {
  margin: 0 0 0.9rem;
  color: #1A1A1A;
  font-family: var(--font-heading);
  font-size: clamp(1.45rem, 2.2vw + 0.8rem, 1.9rem);
  font-weight: 700;
}

.luopan-cta-text {
  max-width: 36rem;
  margin: 0 0 1.7rem;
  color: var(--text-2);
  line-height: 1.75;
}

/* .btn-cta (post-feng-shui.css) carries a 20px top margin for its own
   centered layout; here the paragraph above already provides the gap */
.luopan-cta .btn-cta {
  margin-top: 0;
  letter-spacing: 0.08em;
}

.luopan-cta .btn-cta i {
  margin-left: 0.55rem;
  transition: transform 0.25s ease;
}

/* Hover: the arrow tilts up-right, pointing the way to the contact page */
.luopan-cta .btn-cta:hover i,
.luopan-cta .btn-cta:focus-visible i {
  transform: rotate(-45deg);
}

/* Full-size photo viewer (always a dark overlay, on any theme) */
.luopan-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(12, 9, 7, 0.94);
}

.luopan-lightbox[hidden] {
  display: none;
}

.luopan-lightbox-figure {
  position: relative;
  margin: 0;
  max-width: min(92vw, 1000px);
  text-align: center;
}

.luopan-lightbox-viewport {
  position: relative;
  overflow: auto;
  max-width: min(92vw, 1000px);
  max-height: 78vh;
  -webkit-overflow-scrolling: touch;
}

.luopan-lightbox-figure img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

/* Lightbox overlay: same deterrent as the grid tiles — right-click
   hits this transparent layer instead of the full-size <img>. */
.luopan-lightbox-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
  pointer-events: auto;
}

.luopan-lightbox-figure figcaption {
  margin-top: 0.85rem;
  /* The lightbox is always a dark overlay, so keep cream text regardless of page theme */
  color: #D8CBB2;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.luopan-lightbox-zoom-controls {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.luopan-lightbox-zoom-pill {
  display: inline-flex;
  align-items: center;
  height: 2.6rem;
  padding: 0 1rem;
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 999px;
  background: rgba(23, 18, 14, 0.7);
  color: #C9A227;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.luopan-lightbox-close,
.luopan-lightbox-zoom-btn {
  height: 2.6rem;
  border: 1px solid rgba(201, 162, 39, 0.5);
  background: rgba(23, 18, 14, 0.7);
  color: #C9A227;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.luopan-lightbox-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  border-radius: 50%;
  font-size: 1.1rem;
}

.luopan-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.15rem;
}

.luopan-lightbox-close:hover,
.luopan-lightbox-close:focus-visible,
.luopan-lightbox-zoom-btn:hover:not(:disabled),
.luopan-lightbox-zoom-btn:focus-visible:not(:disabled) {
  background: #C9A227;
  color: #17120E;
}

.luopan-lightbox-zoom-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Mobile */
@media (max-width: 640px) {
  .luopan-category {
    margin: 1.75rem 0 2.25rem;
  }

  .luopan-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .luopan-tile {
    border-radius: 10px;
  }

  .luopan-lightbox {
    padding: 1rem;
  }

  .luopan-lightbox-viewport {
    max-height: 70vh;
  }

  .luopan-lightbox-figure img {
    max-height: 70vh;
  }

  .luopan-cta {
    padding: 2.25rem 1.5rem;
  }

  .luopan-cta::before {
    /* Size/offset tuned so the plate bleeds past every band edge —
       no halo or cut edge shows inside the panel */
    background-position: calc(100% + 120px) calc(100% + 35px);
    background-size: auto 130%;
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .luopan-tile,
  .luopan-tile img {
    transition: none;
  }

  .luopan-tile:hover,
  .luopan-tile:focus-visible {
    transform: none;
  }

  .luopan-tile:hover img,
  .luopan-tile:focus-visible img {
    transform: none;
  }
}
