/* ==========================================================================
   Gallery
   ========================================================================== */
/* 이 파일은 독립 `/gallery` 페이지에서 단독으로 로드되며 homepage.css를 함께
   로드하지 않으므로, homepage.css `--font-size Manage` 구역의 대상이 아니다.
   이 파일 안의 font-size는 컴포넌트 규칙에 그대로 선언한다(별도 관리 구역 없음
   — 필요해지면 이 파일 상단에 이 페이지만의 관리 구역을 새로 만들 것). */

:root {
      --bg: #ffffff;
      --tile: #e5e5e5;
      --text: #111111;
      --hero-height: 70vh;
      --search-width: min(420px, 52vw);
      --gap: 3px;
      --cols: 5;
      --topbar-height: 64px;
    }

    html,
    body {
      background: var(--bg);
    }

    body { overflow-x: hidden; }

    .hero {
      position: relative;
      height: var(--hero-height);
      min-height: 360px;
      display: grid;
      place-items: center;
      background: #fff;
    }

    /* 메인 일러스트(환경설정 > 포트폴리오 이미지 관리) — 아래쪽은 ::after 가 흰색으로 흐린다. */
    .hero.has-illust {
      background: var(--hero-image) center / cover no-repeat, #fff;
    }

    .gallery-empty {
      column-span: all;
      padding: 48px 0;
      text-align: center;
      color: #888;
    }

    .hero::after {
      content: "";
      position: absolute;
      inset: auto 0 0;
      height: 30%;
      pointer-events: none;
      background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 78%);
    }

    .center-ui {
      position: relative;
      z-index: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      transform: translateY(2vh);
    }

    .logo {
      margin: 0 0 18px;
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(28px, 3vw, 44px);
      font-weight: 400;
      letter-spacing: 0.42em;
      text-indent: 0.42em;
      line-height: 1;
    }

    .search {
      width: var(--search-width);
      height: 48px;
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 0 22px;
      border: 0;
      border-radius: 999px;
      background: rgba(229, 229, 229, 0.72);
      backdrop-filter: blur(18px);
      -webkit-backdrop-filter: blur(18px);
      box-shadow: none;
    }

    .search svg {
      width: 21px;
      height: 21px;
      flex: 0 0 auto;
      color: #777;
    }

    .search input {
      width: 100%;
      border: 0;
      outline: 0;
      background: transparent;
      color: #555;
      font-size: 14px;
    }

    .search input::placeholder { color: #aaa; }

    .sticky-search {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 20;
      height: var(--topbar-height);
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 24px;
      padding: 8px 24px;
      background: rgba(255, 255, 255, 0.82);
      backdrop-filter: blur(18px);
      -webkit-backdrop-filter: blur(18px);
      transform: translateY(-100%);
      opacity: 0;
      pointer-events: none;
      transition: transform 220ms ease, opacity 220ms ease;
    }

    .sticky-search.is-visible {
      transform: translateY(0);
      opacity: 1;
      pointer-events: auto;
    }

    .sticky-logo {
      margin: 0;
      font-family: Georgia, "Times New Roman", serif;
      font-size: 16px;
      font-weight: 400;
      letter-spacing: 0.34em;
      text-indent: 0.34em;
      white-space: nowrap;
    }

    .sticky-search .search {
      width: min(360px, 54vw);
      height: 40px;
    }

    .gallery {
      width: 100vw;
      column-count: var(--cols);
      column-gap: var(--gap);
      padding: 0;
      margin: 0;
    }

    /* 포트폴리오 그림이 채워진 타일(자리표시자는 배경색 그대로). */
    .tile.has-image {
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
    }

    .tile {
      width: 100%;
      aspect-ratio: var(--ratio, 1 / 1);
      margin: 0 0 var(--gap);
      display: block;
      break-inside: avoid;
      background: var(--tile);
      cursor: pointer;
    }

    .fixed-info {
      position: fixed;
      left: 16px;
      bottom: 14px;
      z-index: 10;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 6px;
      padding: 8px 9px;
      color: #111;
      font-size: 12px;
      line-height: 1.25;
      background: rgba(255,255,255,0.18);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
    }

    .fixed-info a,
    .fixed-info span {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      color: inherit;
      text-decoration: none;
      white-space: nowrap;
    }

    .fixed-info .social-row { display: flex; gap: 14px; }
    .fixed-info svg { width: 15px; height: 15px; flex: 0 0 auto; }

    .star-button {
      position: fixed;
      right: 22px;
      bottom: 22px;
      z-index: 21;
      width: 42px;
      height: 42px;
      display: grid;
      place-items: center;
      border: 0;
      background: transparent;
      color: #111;
      font-size: 40px;
      line-height: 1;
      cursor: pointer;
      opacity: 0;
      pointer-events: none;
      transform: scale(0.92);
      transition: opacity 220ms ease, transform 220ms ease;
    }

    .star-button.is-visible {
      opacity: 1;
      pointer-events: auto;
      transform: scale(1);
    }



    .art-modal {
      position: fixed;
      inset: 0;
      z-index: 80;
      display: grid;
      place-items: center;
      padding: 2vh 2vw;
      background: rgba(0, 0, 0, 0.62);
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
      transition: opacity 180ms ease;
    }

    .art-modal.is-open {
      visibility: visible;
      opacity: 1;
      pointer-events: auto;
    }

    .modal-artwork {
      position: relative;
      width: 96vw;
      height: 92vh;
      height: 92dvh; /* 휴대폰 주소창 높이를 뺀 화면(지원 안 하면 위 vh) */
      border-radius: 18px;
      background: #e5e5e5;
      box-shadow: 0 22px 70px rgba(0,0,0,0.25);
      /* 크기 전환 애니메이션은 뺐다(요청: 열 때마다 앞 그림 크기에서 늘어나거나 줄어들었다). */
      overflow: hidden;
      touch-action: none;
    }
    .modal-artwork.is-zoomed { cursor: grab; }
    .modal-artwork.is-dragging { cursor: grabbing; }

    .modal-close {
      position: absolute;
      top: 18px;
      right: 18px;
      z-index: 2;
      width: 34px;
      height: 34px;
      border: 0;
      background: transparent;
      color: #111;
      cursor: pointer;
    }

    .modal-close::before,
    .modal-close::after {
      content: "";
      position: absolute;
      left: 7px;
      top: 16px;
      width: 20px;
      height: 1.5px;
      background: currentColor;
    }

    .modal-close::before { transform: rotate(45deg); }
    .modal-close::after { transform: rotate(-45deg); }

    .modal-meta {
      position: absolute;
      left: 24px;
      bottom: 20px;
      z-index: 2;
      display: flex;
      flex-direction: column;
      gap: 9px;
      color: #111;
      font-size: 11px;
      line-height: 1.2;
    }

    .modal-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .modal-tags span {
      padding: 4px 8px;
      border: 1px solid rgba(0,0,0,0.26);
      border-radius: 999px;
      background: rgba(255,255,255,0.22);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
    }

    .modal-detail-row {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
    }

    .modal-detail-row span,
    .modal-detail-row a {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      white-space: nowrap;
      color: inherit;
      text-decoration: none;
    }

    .modal-detail-row svg {
      width: 14px;
      height: 14px;
      flex: 0 0 auto;
    }

    .modal-detail-row .modal-icon-link {
      width: 16px;
      height: 16px;
      justify-content: center;
    }

    @media (max-width: 700px) {
      :root {
        --search-width: 78vw;
        --gap: 2px;
        --topbar-height: 58px;
      }

      .hero { min-height: 320px; }
      .logo { margin-bottom: 14px; font-size: 24px; }
      .search { height: 44px; padding: 0 18px; }
      .sticky-search { gap: 12px; }
      .sticky-logo { font-size: 13px; letter-spacing: 0.24em; text-indent: 0.24em; }
      .sticky-search .search { width: 100%; min-width: 0; }
      .fixed-info { font-size: 11px; left: 8px; bottom: 10px; }
      .star-button { right: 12px; bottom: 14px; font-size: 34px; }
      .art-modal { padding: 2vh 2vw; }
      .modal-artwork { border-radius: 14px; }
      .modal-meta { left: 14px; bottom: 14px; max-width: calc(100% - 90px); font-size: 12px; gap: 7px; }
      .modal-tags { gap: 4px; }
      .modal-tags span { padding: 3px 6px; }
      .modal-close { top: 10px; right: 10px; }
    }

    /* 손가락으로 누를 칸은 44px 이상(그림 크기는 그대로, 눌리는 자리만 넓힌다). */
    @media (pointer: coarse) {
      .modal-close { width: 44px; height: 44px; top: 13px; right: 13px; }
      .modal-close::before,
      .modal-close::after { left: 12px; top: 21px; }
      .modal-detail-row .modal-icon-link { position: relative; }
      .modal-detail-row .modal-icon-link::after { content: ""; position: absolute; inset: -14px; }
    }
    @media (pointer: coarse) and (max-width: 700px) {
      .modal-close { top: 5px; right: 5px; }
    }
    .tile:focus-visible { outline: 2px solid #111; outline-offset: -2px; }

    /* 휴대폰에선 아래 연락처가 왼쪽 아래 그림을 가렸다. 고정을 풀고 목록 끝에 가운데로 둔다. */
    @media (max-width: 640px) {
      .fixed-info { position: static; align-items: center; width: fit-content; margin: 12px auto 72px; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
      .fixed-info a { min-height: 44px; padding: 0 10px; }
    }

/* Modal visibility hardening */
.art-modal[aria-hidden="false"] {
  visibility: visible;
}

/* 뷰어 위 정보 중 없는 것(날짜·X·유튜브·태그)은 감춘다(요청) — 위의 inline-flex 가 [hidden] 을 이겨 늘 보였다. */
.modal-meta [hidden] {
  display: none !important;
}

/* 아래 연락처 중 정하지 않은 것은 감춘다(검증: 한 사람의 연락처가 모든 스페이스에 박혀 있었다) — 위의 flex 가 [hidden] 을 이긴다. */
.fixed-info[hidden],
.fixed-info [hidden] {
  display: none !important;
}

/* 30장씩 이어 붙이는 격자(요청) — 열은 고정 개수(--cols), 새 그림은 가장 짧은 열 아래에 붙는다(gallery.js placeTile).
   예전 column-count 다단은 그림을 붙일 때마다 열을 다시 나눠 위의 그림이 옮겨 다녔다. */
.gallery {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  column-count: auto;
}
.gallery-col { flex: 1 1 0; min-width: 0; }
.gallery-empty { width: 100%; }
/* 소유자 빈 포트폴리오의 [이미지 가져오기](포트폴리오 창 안에서만). 이 페이지는 homepage.css 를 안 실으므로
   프로젝트 버튼(.small-btn.primary-button, 27px·Focus 색)의 모양을 여기서 그대로 준다. Focus 색은 템플릿의 InitialThemeCSS. */
.gallery-empty-action {
  margin-top: 12px; height: 27px; padding: 0 14px; border: 1px solid var(--focus-color, #2b97ff); border-radius: 6px;
  background: var(--focus-color, #2b97ff); color: var(--focus-font-color, #fff); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.gallery-empty-action:hover { filter: brightness(1.06); }
.gallery-sentinel { height: 1px; }
.tile { position: relative; }

/* 포트폴리오 창 안(iframe ?embed=1)의 검색 관리 중 — 그림 왼쪽 아래 검색어 칩, 태그를 끌어 놓을 자리. */
.gallery-chips {
  position: absolute;
  left: 6px;
  bottom: 6px;
  right: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  pointer-events: none;
}
.gallery-chips span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
}
.tile.is-drop-target { outline: 3px dashed #4a7cf0; outline-offset: -3px; }
.gallery-chips span.is-character { background: rgba(43, 151, 255, 0.85); }

/* 검색 태그 칩(요청) — 검색창 아래 한 줄, 넘치면 줄바꿈. 고른 칩은 진하게. */
.gallery-tag-chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin-top: 14px; max-width: min(640px, 92vw);
}
.gallery-tag-chips[hidden] { display: none; }
.gallery-tag-chip {
  padding: 5px 12px; border: 1px solid rgba(0, 0, 0, .12); border-radius: 999px;
  background: rgba(255, 255, 255, .72); color: #333; font-size: 12px; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.gallery-tag-chip:hover { border-color: rgba(0, 0, 0, .3); }
.gallery-tag-chip.is-on { background: #222; border-color: #222; color: #fff; }
/* 고른 검색 말 칩 — 오른쪽 × 로 뺀다(요청). 칩 자체는 누르는 단추가 아니다. */
.gallery-tag-chips .gallery-tag-chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 6px; cursor: default; }
.gallery-tag-chip-x {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: inherit; font-size: 14px; line-height: 1; cursor: pointer; opacity: .75;
}
.gallery-tag-chip-x:hover { opacity: 1; background: rgba(255, 255, 255, .18); }
@media (pointer: coarse) { .gallery-tag-chip-x { width: 28px; height: 28px; margin: -5px -4px -5px 0; } }
/* 검색 자동완성(요청: 태그·캐릭터 제안) — 쓰는 검색창 바로 아래, 검색창과 같은 유리 면. */
.gallery-suggest {
  position: fixed; z-index: 90; box-sizing: border-box; max-height: 320px; overflow-y: auto; padding: 6px;
  border-radius: 18px; background: rgba(245, 245, 245, .92); box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.gallery-suggest[hidden] { display: none; }
.gallery-suggest-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 9px 14px; border: 0; border-radius: 12px; background: transparent; color: #222; font-size: 14px; text-align: left; cursor: pointer;
}
.gallery-suggest-item small { color: #888; font-size: 11px; flex: 0 0 auto; }
.gallery-suggest-item.is-active,
.gallery-suggest-item:hover { background: rgba(0, 0, 0, .07); }
/* 민감 그림(gallery.js makeTile) — 칸 배경을 흐리게 덮고, 처음 누르면 걷힌다. */
.tile.is-sensitive { overflow: hidden; }
.tile.is-sensitive::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
  background: rgba(0, 0, 0, .25);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tile.is-sensitive::before { background: #333; }
}
.tile-sensitive {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px;
  color: #fff; font-size: 12px; font-weight: 600; line-height: 1.5;
  pointer-events: none;
}
/* 새 그림(최근 7일) 표시 — 칸 왼쪽 위의 작은 표. */
.tile-new {
  position: absolute; left: 8px; top: 8px; z-index: 2;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); color: #111; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  pointer-events: none;
}
/* 그림이 툭 나타나지 않고 천천히 드러난다(요청). 움직임 줄이기를 켠 사람에게는 걸지 않는다. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes tile-fade-in { from { opacity: 0; transform: translateY(6px); } }
  .tile.has-image { animation: tile-fade-in .5s ease both; }
}

/* 첫 화면 높이(gallery.js loadPortfolioImages 가 html 에 단다) — 그림이 있으면 접힌 아래가 아니라 바로 보이게.
   그림 + 메인 일러스트 = 40vh, 그림만 = 로고·검색만 담는 높이, 0장 = 로고·검색·빈 안내가 화면 가운데 한 묶음. */
html.pf-illust { --hero-height: 40vh; }
html.pf-illust .hero { min-height: 260px; }
html.pf-compact .hero { height: auto; min-height: 0; padding: 72px 0 40px; }
html.pf-empty main { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; min-height: 100dvh; }
html.pf-empty .hero { height: auto; min-height: 0; }
html.pf-empty .gallery-empty { padding: 16px 0 0; }
