/* ==========================
   :root & 테마 변수
========================== */
:root {
  --bg: #0b0c0f;
  --card: #11131a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --ring: #93c5fd66;
}

/* 사용자 선택 모드 */
:root[data-theme="light"] {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --ring: #2563eb33;
}
:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --card: #11131a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --ring: #93c5fd66;
}

/* OS/브라우저 기본 선호 모드 */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --accent: #2563eb;
    --ring: #2563eb33;
  }
}

/* ==========================
   기본 스타일
========================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, Segoe UI, Roboto, Noto Sans KR, Apple SD Gothic Neo,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

/* ==========================
   헤더
========================== */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--text) 10%, transparent);
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 2.8vw, 36px);
  letter-spacing: -0.02em;
}

.sub {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.mode-toggle {
  display: flex;
  align-items: center;
}

#toggle-mode {
  font-size: 1em;
  padding: 6px 12px;
}

/* ==========================
   버튼 스타일
========================== */
.btn {
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #6d5dfc, #4f46e5);
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  background: linear-gradient(135deg, #7c6dff, #5c3ed1);
}

.btn:active,
.btn[aria-pressed="true"] {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, #4f46e5, #312e81);
}

/* ==========================
   검색
========================== */
.search {
  flex: 1 1 220px;
  position: relative;
}

.search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  background: var(--card);
  color: var(--text);
}

/* ==========================
   갤러리
========================== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.card {
  position: relative;
  overflow: clip;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--text) 10%, transparent);
}

.card img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover img {
  transform: scale(1.04);
}

.card .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 500;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.card button {
  all: unset;
  cursor: zoom-in;
  position: absolute;
  inset: 0;
}

.card .comment {
  margin-top: 0.5em;
  font-size: 0.9em;
  color: #f0f0f0;
  background: rgba(25, 30, 45, 0.85);
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  line-height: 1.4;
  font-weight: 500;
  transition: background 0.3s, box-shadow 0.3s;
}

.card:hover .comment {
  background: rgba(30, 35, 50, 0.95);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ==========================
   라이트박스
========================== */
dialog#lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  border: none;
  padding: 0;
  background: color-mix(in oklab, #000 75%, transparent);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.viewer {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.viewer img {
  max-width: min(92vw, 1400px);
  max-height: 80vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.viewer figcaption {
  margin-top: 12px;
  color: #fff;
  text-align: center;
  font-size: 20px;
}

.nav {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.nav button {
  pointer-events: auto;
  border: 1px solid color-mix(in oklab, var(--text) 10%, transparent);
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin: 0 16px;
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
}

#lbComment {
  margin-top: 12px;
  font-size: 1em;
  color: #f0f0f0;
  background: rgba(25, 30, 45, 0.85);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  line-height: 1.5;
  font-weight: 500;
  text-align: center;
  max-width: 90%;
  word-break: break-word;
  transition: background 0.3s, box-shadow 0.3s;
}

.viewer figure:hover #lbComment {
  background: rgba(30, 35, 50, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ==========================
   반응형
========================== */
@media (max-width: 768px) {
  #lbComment {
    font-size: 0.95em;
    padding: 8px 12px;
  }
}

/* ==========================
   Footer
========================== */
footer {
  text-align: center;
  color: var(--muted);
  padding: 30px 0 50px;
}

footer a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.3s, text-shadow 0.3s;
}

footer a:hover {
  color: #93c5fd;
  text-shadow: 0 0 6px rgba(147, 197, 253, 0.6);
}

/* ==========================
   스크롤 및 보조 클래스
========================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
