/* ARCHIVE PRO APP — viewer.css
   Grid/card/control layout + the lightbox viewer. Assumes style.css already
   sets up color variables (--bg, --text, --gold, --card-bg, --card-border
   etc.) and the header/hero. If any of these variables aren't defined yet
   there, the fallbacks below (var(--x, #fallback)) keep this file usable
   standalone. */

:root {
  --ap-bg: var(--bg, #0b0f14);
  --ap-text: var(--text, #f2ead8);
  --ap-text-dim: var(--text-dim, rgba(242,234,216,.62));
  --ap-gold: var(--gold, #d4b46d);
  --ap-gold-bright: var(--gold-bright, #e9d59b);
  --ap-card-bg: var(--card-bg, rgba(255,255,255,.03));
  --ap-card-border: var(--card-border, rgba(212,180,109,.18));
}

/* ---- Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  min-width: 0;
}
@media (min-width: 640px) and (max-width: 899px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
}

.card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-card-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--ap-gold); }

.thumb-wrap {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #060a0e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb-wrap .thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .3s ease;
}
.thumb-wrap .thumb.is-loaded { opacity: 1; }

.card .meta { padding: 9px 11px 13px; }
.card .meta .t { font-size: 13px; color: var(--ap-text); }
.card .meta .s { font-size: 11px; color: var(--ap-text-dim); margin-top: 3px; }

/* ---- Empty state ---- */
.empty-state {
  width: 100%;
  min-height: clamp(240px, 36vh, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ap-text-dim);
  padding: 40px 20px;
}

/* ---- Load more ---- */
.load-wrap { text-align: center; margin-top: 26px; }
.load-wrap .btn {
  background: none;
  border: 1px solid var(--ap-card-border);
  color: var(--ap-text-dim);
  border-radius: 999px;
  padding: 9px 22px;
  font: inherit;
  cursor: pointer;
}
.load-wrap .btn:hover { color: var(--ap-gold-bright); border-color: var(--ap-gold); }

/* ==================================================================
   LIGHTBOX VIEWER
   ================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  background: rgba(6, 10, 14, .99);
  overflow: hidden;
  isolation: isolate;
}
.lightbox.open { display: block; }

.lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 20;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.4);
  color: var(--ap-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 48px;
  height: 68px;
  border-radius: 999px;
  border: 1px solid rgba(212,180,109,.28);
  background: rgba(7,10,20,.5);
  color: var(--ap-gold);
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: .82;
  transition: opacity .16s ease, border-color .16s ease, background .16s ease;
}
.lightbox-nav:hover { opacity: 1; border-color: rgba(212,180,109,.5); background: rgba(7,10,20,.72); }
.lightbox-prev { left: max(16px, env(safe-area-inset-left)); }
.lightbox-next { right: max(16px, env(safe-area-inset-right)); }

.lightbox-inner {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.lightbox-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 20px 16px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.lightbox-stage.is-zoomed { cursor: grab; }
.lightbox-stage.is-zoomed.is-dragging { cursor: grabbing; }

#lightboxImage {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  background: #091018;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity .25s ease;
}
#lightboxImage.is-ready { opacity: 1; }
#lightboxImage.no-transition { transition: none !important; }

.lightbox-side {
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid rgba(255,255,255,.08);
}
.lb-id { font-size: 11px; letter-spacing: .08em; color: var(--ap-gold); margin: 0 0 4px; }
.lb-title { font-size: 19px; color: var(--ap-text); margin: 0 0 4px; }
.lb-section { font-size: 12px; color: var(--ap-text-dim); margin: 0 0 14px; }
.lb-meta { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; gap: 14px; font-size: 13px; }
.lb-key { min-width: 48px; color: var(--ap-text-dim); }
.lb-val { color: var(--ap-text); word-break: break-all; }
.lb-actions { display: flex; gap: 14px; margin-top: 16px; }
.lb-link { font-size: 12.5px; color: var(--ap-gold); text-decoration: none; border-bottom: 1px solid rgba(212,180,109,.4); }
.lb-link:hover { color: var(--ap-gold-bright); }

/* Desktop wide layout: image stage + fixed sidebar, side by side. */
@media (min-width: 881px) {
  .lightbox-inner {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1fr) 380px;
  }

  .lightbox-stage {
    height: 100vh;
    padding: 32px 100px;
  }

  .lightbox-next { right: calc(380px + 20px + env(safe-area-inset-right, 0px)); }

  .lightbox-side {
    max-height: 100vh;
    height: 100vh;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,.08);
    padding: 90px 28px 28px;
  }
}

/* ============================================================
   Artist Bio 전체화면 뷰어 (2026-07-24 전체화면으로 재작성 — 스펙 §8~§13)
   ============================================================ */
.artist-bio-viewer {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: #050914;
  color: #d1b274;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.artist-bio-viewer[hidden] { display: none; }

.artist-bio-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 16px;
  background: rgba(5, 9, 20, 0.96);
  border-bottom: 1px solid rgba(202, 169, 99, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.artist-bio-header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d4b46d;
  outline: none;
}
.artist-bio-language {
  display: flex;
  gap: 6px;
}
.artist-bio-lang-btn {
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(202, 169, 99, 0.3);
  background: transparent;
  color: rgba(209, 178, 116, 0.6);
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.artist-bio-lang-btn.active {
  color: #050914;
  background: #d1b274;
  border-color: #d1b274;
}
.artist-bio-lang-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.artist-bio-close {
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(202, 169, 99, 0.3);
  background: transparent;
  color: #d1b274;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.artist-bio-close:hover { background: rgba(202, 169, 99, 0.12); }

.artist-bio-content {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 30px 24px calc(env(safe-area-inset-bottom, 0px) + 80px);
  font-size: clamp(17px, 4.4vw, 20px);
  line-height: 1.85;
  word-break: keep-all;
}
.artist-bio-name {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #d4b46d;
}
.artist-bio-text {
  margin: 0;
  color: #e7e7ea;
  white-space: pre-line;
}

/* 헤더의 Artist Bio 트리거 버튼 — 데스크톱: 다른 보조 버튼(KR/EN/KR+EN,
   dungzak.art)보다 한 단계 높은 시각적 우선순위 (2026-07-24 최종 마감).
   NOTE: style.css 쪽에 .hero-home-link를 34px/44px로 고정하거나
   (body.archive-entered 상태에서) box-shadow·transform을 none으로
   되돌리는 !important 규칙이 여러 군데 있어, 아래는 전부 !important +
   ID 선택자로 명시해 그 규칙들을 확실히 이기도록 한다. */
#artistBioTrigger.hero-home-link,
body.archive-entered #artistBioTrigger.hero-home-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 42px !important;
  height: auto !important;
  padding: 0 19px !important;
  margin-left: 8px !important;
  margin-right: 6px !important;
  border: 1px solid rgba(216, 183, 119, 0.95) !important;
  border-radius: 28px !important;
  color: var(--gold, #d4b46d) !important;
  background: rgba(216, 183, 119, 0.06) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  box-shadow: 0 0 0 1px rgba(216, 183, 119, 0.06) !important;
  transition: background 0.15s ease, transform 0.15s ease !important;
  transform: none;
}
#artistBioTrigger.hero-home-link:hover,
body.archive-entered #artistBioTrigger.hero-home-link:hover {
  background: rgba(216, 183, 119, 0.11) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 0 0 1px rgba(216, 183, 119, 0.08) !important;
}
#artistBioTrigger.hero-home-link:active,
body.archive-entered #artistBioTrigger.hero-home-link:active {
  background: rgba(216, 183, 119, 0.14) !important;
  transform: none !important;
}
#artistBioTrigger.hero-home-link:focus-visible {
  background: rgba(216, 183, 119, 0.11) !important;
}

/* 작가 링크 버튼 — 스펙 §5: 항상 실제 URL(축약형) 표시, 길면 말줄임.
   Bio 버튼보다 한 단계 낮은 우선순위 — hover 시 확대/글로우 효과(전역
   .hero-home-link:hover 규칙)를 여기서만 눌러 차분하게 유지한다. */
.artist-external-link.hero-home-link {
  display: inline-block !important;
  min-width: 0 !important;
  max-width: 220px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
}
.artist-external-link.hero-home-link:hover,
.artist-external-link.hero-home-link:active {
  transform: none !important;
  box-shadow: none !important;
}
@media (max-width: 480px) {
  .artist-external-link.hero-home-link { max-width: 42vw !important; }
}

/* ============================================================
   모바일·태블릿 — 최종 마감 (2026-07-24)
   1행: KR / EN / KR+EN
   2행: 작가 링크(보조, 축소) | Artist Bio(핵심, 강조)
   3행: 한국어 기준
   터치 영역(min-height)은 절대 줄이지 않는다 — 폭·존재감만 조정.
   ============================================================ */
@media (max-width: 767px) {
  .lang-inline {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px 12px !important; /* 세로 gap 10→8px, 정보 밀도 소폭 상향 */
    padding-bottom: 0 !important; /* 기존 2px에서 추가로 줄임 */
  }
  .lang-tabs {
    flex-basis: 100% !important; /* 1행: 언어 탭이 한 줄을 그대로 차지 */
  }

  /* 2행 폭 비율 — 링크 44% : Artist Bio 54%(작품보다 앞서지 않도록 5% 축소) */
  .artist-external-link.hero-home-link {
    max-width: none !important;
    flex: 0 1 44% !important;
    min-width: 0 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    border-color: rgba(216, 183, 119, 0.45) !important;
    color: rgba(216, 183, 119, 0.88) !important;
  }
  #artistBioTrigger.hero-home-link,
  body.archive-entered #artistBioTrigger.hero-home-link {
    flex: 0 1 54% !important;
    min-width: 125px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    min-height: 52px !important;
    padding: 0 22px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    border-color: rgba(216, 183, 119, 0.95) !important;
    background: rgba(216, 183, 119, 0.06) !important;
  }

  .hero-mode-line {
    flex-basis: 100% !important; /* 3행: "한국어 기준" */
    margin-top: -6px !important; /* 위로 6px — Artist Bio와 한 그룹처럼 보이게 */
    margin-bottom: -4px !important; /* 통계 영역과의 여백도 소폭 축소 */
  }
}
@media (max-width: 380px) {
  .lang-inline .artist-external-link.hero-home-link,
  .lang-inline #artistBioTrigger.hero-home-link {
    flex-basis: 100% !important;
    width: 100% !important;
  }
}
