/* 公開ギャラリー：カード一覧と詳細モーダル */
.gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 28px 24px;
}

.card {
  width: 100%;
  padding: 12px 12px 10px;
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s;
}

/* カードを少しずつ傾けて、手作り感を出す */
.gallery li:nth-child(4n + 1) .card { transform: rotate(-1.2deg); }
.gallery li:nth-child(4n + 2) .card { transform: rotate(0.8deg); }
.gallery li:nth-child(4n + 3) .card { transform: rotate(-0.5deg); }
.gallery li:nth-child(4n) .card { transform: rotate(1.3deg); }

.gallery li .card:hover,
.gallery li .card:focus-visible {
  transform: rotate(0deg) translateY(-4px) scale(1.02);
}

.card-frame {
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--pink-soft);
}

.gallery li:nth-child(3n + 2) .card-frame { background: var(--mint); }
.gallery li:nth-child(3n) .card-frame { background: var(--lavender); }

.card-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 10px 4px 0;
}

.card-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.card-character {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.card-likes {
  margin: 4px 0 0;
  text-align: right;
  font-size: 0.9rem;
  color: var(--pink-deep);
}

.card-likes .heart {
  margin-right: 0.25em;
}

/* ---- 詳細モーダル ---- */
.detail {
  width: min(100% - 24px, 760px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 0 rgba(107, 79, 63, 0.2);
}

.detail::backdrop {
  background: rgba(91, 67, 52, 0.45);
}

.detail[open] {
  animation: pop-in 0.25s ease-out;
}

@keyframes pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.detail-inner {
  position: relative;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 2.5px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.detail-figure {
  margin: 0;
  background: var(--pink-soft);
  border-bottom: 2.5px solid var(--line);
}

.detail-figure img {
  width: 100%;
  max-height: 70dvh;
  object-fit: contain;
}

.detail-body {
  padding: 18px 20px 22px;
}

.chip {
  display: inline-block;
  margin: 0 0 6px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--mint);
  font-size: 0.85rem;
}

.detail-title {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-date {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.detail-description {
  margin: 12px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 18px;
  min-height: 48px;
  padding: 6px 22px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--pink-soft);
  box-shadow: 0 4px 0 var(--line);
  font-weight: 700;
  cursor: pointer;
}

.like-button .heart {
  color: var(--pink-deep);
  font-size: 1.3rem;
}

.like-button:disabled {
  background: var(--pink);
  cursor: default;
}

.like-button.pop .heart {
  animation: heart-pop 0.5s ease-out;
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.7); }
  100% { transform: scale(1); }
}

.like-count {
  min-width: 1.5em;
  text-align: center;
}
