/* ============================================================
   components.css — 재사용 요소
   타일 / 그리드 / 레일 / 버튼 / 배지 / 쇼릴 모달
   각 요소는 이 파일에서만 정의한다.
   ============================================================ */

/* ---------- 작품 타일 ---------- */
.tile { display: block; }
.tile:focus-visible { outline: 2px solid var(--paper); outline-offset: -2px; }

.frame {
  position: relative;
  aspect-ratio: var(--poster);
  overflow: hidden;
  background: var(--shade);
}

.frame > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--ease), opacity .5s ease;
}
.tile:hover .frame > img { transform: scale(1.015); }

.ph { position: absolute; inset: 0; background: var(--shade); }

/* 두 번째 이미지 — 마우스 올리면 교차 */
.tile-swap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .5s ease, transform 1.1s var(--ease);
  z-index: 1;
}
.tile:hover .tile-swap,
.tile:focus-visible .tile-swap { opacity: 1; transform: scale(1); }
.tile:has(.tile-swap):hover .frame > img:not(.tile-swap) { opacity: 0; }

/* 호버 재생 클립 */
.tile-clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .45s ease;
  pointer-events: none;
  z-index: 1;
}
.tile.playing .tile-clip { opacity: 1; }
.tile.playing .frame > img:not(.tile-clip) { opacity: 0; }

.frame .has-clip {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 0; height: 0;
  border-left: 7px solid var(--on-dark);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  opacity: .8;
  transition: opacity .3s;
  z-index: 3;
}
.tile.playing .has-clip { opacity: 0; }

/* 타일 위 정보 */
.tile-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(to top,
    rgba(10,11,13,.85) 0%, rgba(10,11,13,.1) 55%, transparent 100%);
  opacity: .9;
  transition: opacity .4s;
}
.tile:hover .tile-veil { opacity: 1; }

.tile-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  padding: 14px 16px;
  color: var(--on-dark);
}
.tile-ttl {
  margin: 0;
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--on-dark);
}
.tile-sub {
  margin: 5px 0 0;
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--on-dark-dim);
}
.tile-sub .dot { margin: 0 7px; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-block;
  margin-right: 10px;
  padding: 3px 9px;
  border: 1px solid var(--on-dark-line);
  border-radius: 100px;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--on-dark);
  vertical-align: 1px;
}

/* ---------- 필터 칩 ---------- */
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 var(--pad) 20px;
}
.chip {
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 100px;
  border: 1px solid rgba(20,22,26,.22);
  color: rgba(20,22,26,.62);
  transition: border-color .2s, color .2s, background .2s;
}
.chip:hover { border-color: rgba(20,22,26,.5); color: var(--paper); }
.chip.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }

/* ---------- 작품 그리드 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
}
@media (max-width: 820px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- 가로 스크롤 레일 ---------- */
.rail-sec { padding: clamp(28px, 5vw, 56px) 0 0; }

.rail-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 0 var(--pad) 14px;
}
.rail-ttl {
  margin: 0;
  font-size: clamp(17px, 2.1vw, 23px);
  font-weight: 500;
  letter-spacing: -0.015em;
}
.rail-more {
  margin-left: auto;
  font-size: 12px;
  letter-spacing: .05em;
  color: var(--dim);
  transition: color .2s;
}
.rail-more:hover { color: var(--paper); }

.rail-wrap { position: relative; }

.rail {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  padding: 0 var(--pad) 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(20,22,26,.25) transparent;
}
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-track { background: transparent; }
.rail::-webkit-scrollbar-thumb { background: rgba(20,22,26,.22); border-radius: 100px; }
.rail::-webkit-scrollbar-thumb:hover { background: rgba(20,22,26,.4); }

.rail .tile {
  flex: 0 0 clamp(150px, 14vw, 210px);
  scroll-snap-align: start;
}

.rail-nav {
  position: absolute;
  top: 0;
  bottom: 12px;
  width: 54px;
  border: 0;
  cursor: pointer;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--paper);
  background: linear-gradient(to right, var(--ink) 30%, transparent);
  transition: opacity .2s;
}
.rail-nav.prev { left: 0; }
.rail-nav.next { right: 0; background: linear-gradient(to left, var(--ink) 30%, transparent); }
.rail-wrap:hover .rail-nav { display: flex; }
.rail-nav[hidden] { display: none; }
.rail-nav:hover { opacity: .7; }

@media (hover: none) { .rail-nav { display: none; } }

/* ---------- 버튼 ---------- */
.cta-btn {
  display: inline-block;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 30px;
  border-radius: 100px;
  font-size: 13px;
  letter-spacing: .06em;
  transition: opacity .2s;
}
.cta-btn:hover { opacity: .82; }

.cta-alt {
  font-size: 13px;
  letter-spacing: .05em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: color .2s, border-color .2s;
}
.cta-alt:hover { color: var(--paper); border-color: var(--paper); }

/* ---------- 비교 슬라이더 (공통) ---------- */
.bd-frame,
.dhero-bd {
  position: relative;
  overflow: hidden;
  background: var(--stage);
  --split: 50%;
  cursor: ew-resize;
}
.bd-after, .bd-before {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bd-before { clip-path: inset(0 calc(100% - var(--split)) 0 0); }

.bd-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--split);
  width: 1px;
  background: rgba(251,250,248,.9);
  pointer-events: none;
  z-index: 2;
}
.bd-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 46px; height: 46px;
  border: 1px solid rgba(251,250,248,.9);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12,13,15,.4);
}
.bd-range {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: ew-resize;
  margin: 0;
  z-index: 3;
}

/* ---------- 쇼릴 모달 ---------- */
.reel-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8,8,9,.97);
  padding: clamp(16px, 4vw, 56px);
}
.reel-modal.on { display: flex; }

.reel-box { width: 100%; max-width: 1500px; }
.reel-box video {
  width: 100%;
  height: auto;
  max-height: 82vh;
  display: block;
  background: #000;
}

.reel-close {
  position: absolute;
  top: clamp(14px, 3vw, 30px);
  right: clamp(14px, 3vw, 30px);
  width: 42px; height: 42px;
  border: 1px solid var(--on-dark-line);
  border-radius: 50%;
  background: transparent;
  color: var(--on-dark);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s;
}
.reel-close:hover { background: rgba(251,250,248,.16); }

body.reel-open { overflow: hidden; }
