:root {
  --bg: #0b0c10;
  --card: #11131a;
  --text: #e7e9ee;
  --muted: #a7adbb;
  --line: #24283a;
  --accent: #7c5cff;
  --chip: #1a1d29;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

@font-face {
  font-family: "BergExtrude";
  src: url("source/font/BergExtrude.woff2") format("woff2"),
    url("source/font/BergExtrude.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergInline";
  src: url("source/font/BergInline.woff2") format("woff2"),
    url("source/font/BergInline.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergInnerOrnament";
  src: url("source/font/BergInnerOrnament.woff2") format("woff2"),
    url("source/font/BergInnerOrnament.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergRegular";
  src: url("source/font/BergRegular.woff2") format("woff2"),
    url("source/font/BergRegular.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergShadow";
  src: url("source/font/BergShadow.woff2") format("woff2"),
    url("source/font/BergShadow.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergWesternRegular";
  src: url("source/font/BergWesternRegular.woff2") format("woff2"),
    url("source/font/BergWesternRegular.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BergwesternRough";
  src: url("source/font/BergwesternRough.woff2") format("woff2"),
    url("source/font/BergwesternRough.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* font-family: "BergwesternRough"; */
  background: radial-gradient(
      1200px 700px at 10% 0%,
      rgba(124, 92, 255, 0.18),
      transparent 60%
    ),
    radial-gradient(
      900px 600px at 90% 10%,
      rgba(0, 211, 255, 0.1),
      transparent 55%
    ),
    var(--bg);
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;

  /* font-size: 100px;
  background: linear-gradient(135deg, #b64339, #d1a100, #f5dfb7);
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.15),
    -4px -4px 8px rgba(0, 0, 0, 0.1),
    0 4px 6px rgba(0, 0, 0, 0.2);
  transform: rotateX(20deg); */
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(17, 19, 26, 0.65);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(124, 92, 255, 0.7);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: 0.15s ease;
}
.nav a:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}
.nav a.active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.14);
}

/* Header */
.header {
  margin-top: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.4px;
}
.sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Controls */
.controls {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 19, 26, 0.55);
  backdrop-filter: blur(10px);
}
.leftControls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: 0.15s ease;
  font-size: 13px;
}
.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.18);
}

.searchBox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
  min-width: 260px;
}
.searchBox input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.searchBox input::placeholder {
  color: rgba(231, 233, 238, 0.45);
}

.metaRight {
  color: var(--muted);
  font-size: 13px;
}

/* Grid container */
.grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

/* Year grouping */
.yearSection {
  grid-column: 1 / -1;
  margin-top: 18px;
}
.yearHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}
.yearHeaderLeft {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.yearTitle {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.yearCount {
  font-size: 13px;
  color: var(--muted);
}
.yearToggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease;
}
.yearToggle:hover {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.16);
}
.yearToggle .chev {
  display: inline-block;
  transition: transform 0.15s ease;
}
.yearSection.is-collapsed .yearGrid {
  display: none;
}
.yearSection.is-collapsed .yearToggle .chev {
  transform: rotate(-90deg);
}

/* Inner grid in each year */
.yearGrid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

/* Card */
.card {
  grid-column: span 3;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 19, 26, 0.75);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 92, 255, 0.45);
}

.thumb {
  position: relative;
  /* aspect-ratio: 4 / 3; */
  background: linear-gradient(
    135deg,
    rgba(124, 92, 255, 0.22),
    rgba(0, 211, 255, 0.1)
  );
  overflow: hidden;
}
.badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 2;
}
.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  color: var(--text);
}

/* ✅ img/video 둘 다 커버 */
.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb img {
  width: 100%;
  height: auto;
}

.body {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.titleRow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.cardTitle {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: -0.2px;
}
.cardTags {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 1100px) {
  .card {
    grid-column: span 4;
  }
}
@media (max-width: 800px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .searchBox {
    min-width: 220px;
  }
  .card {
    grid-column: span 6;
  }
}
@media (max-width: 520px) {
  .card {
    grid-column: span 12;
  }
  h1 {
    font-size: 28px;
  }
}

/* Empty */
.empty {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(17, 19, 26, 0.35);
  display: none;
}
.empty[aria-hidden="false"] {
  display: block;
}

/* Modal overlay */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}
.modalOverlay[aria-hidden="false"] {
  display: flex;
}

/* Modal box: ✅ 내부 스크롤 대응 기본 골격 */
.modal {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 16, 22, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(14px);

  display: flex;
  flex-direction: column;
  min-height: 0;
}
.modalTop {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.modalTitle {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.modalTitle strong {
  font-size: 15px;
}
.modalTitle span {
  color: var(--muted);
  font-size: 12px;
}
.modalActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:hover {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.16);
}
.btn.secondary:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
}
.btn.close {
  padding: 8px 10px;
}

/* Modal content area */
.modalBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto; /* 기본: 모달 바디 스크롤 */
  -webkit-overflow-scrolling: touch;
  padding: 16px;

  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Preview containers */
.modalPreview {
  display: grid;
  gap: 10px;
}

.mediaWrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}
#modalMedia img,
#modalMedia video {
  width: 100%;
  height: auto;
  display: block;
}

/* Iframe preview (Code) */
.iframeWrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  min-height: 280px;
}
#modalIframe {
  width: 100%;
  height: min(60vh, 520px);
  border: 0;
  display: block;
  background: #0b0c10;
}

.modalDesc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 2px 2px 6px;
}

/* Code viewer (Code mode) */
.codeWrap {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}
.codeTopbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}
.codeTabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.codeTab {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.codeTab[aria-selected="true"] {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.16);
}
.codeBlock {
  margin: 0;
  padding: 12px;
  max-height: min(40vh, 360px);
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: rgba(231, 233, 238, 0.95);
  white-space: pre;
}

@media (max-width: 520px) {
  #modalIframe {
    height: 46vh;
  }
  .codeBlock {
    max-height: 34vh;
  }
}

/* =========================================================
   Page transition (fade + slight move)
   ========================================================= */
#page {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 260ms ease;
  will-change: opacity, transform;
}

#page.is-ready {
  opacity: 1;
  transform: translateY(0);
}

#page.is-leaving {
  opacity: 0;
  transform: translateY(10px);
}

/* 모션 민감 사용자 배려 */
@media (prefers-reduced-motion: reduce) {
  #page {
    transition: none !important;
    transform: none !important;
  }
  .card {
    animation: none !important;
    transform: none !important;
  }
}

/* =========================================================
     Card stagger (grid items appear smoothly)
     - JS가 --d (delay)를 넣어줌
     ========================================================= */
.card {
  opacity: 0;
  transform: translateY(10px);
  animation: cardIn 420ms ease forwards;
  animation-delay: var(--d, 0ms);
  will-change: opacity, transform;
}

@keyframes cardIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 연도 헤더도 자연스럽게 */
.yearHeader {
  opacity: 0;
  transform: translateY(8px);
  animation: headIn 360ms ease forwards;
  animation-delay: var(--d, 0ms);
  will-change: opacity, transform;
}

@keyframes headIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pt {
  position: fixed;
  inset: 0;
  background: #0b0d10;
  z-index: 9999;
  pointer-events: none;

  opacity: 0;
  transform: translateY(18px);
  filter: blur(10px);

  transition: opacity 420ms cubic-bezier(0.2, 0.9, 0.2, 1),
    transform 420ms cubic-bezier(0.2, 0.9, 0.2, 1),
    filter 420ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

/* 떠나기(클릭 후) : 화면 덮기 */
.pt.is-leave {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* 진입 시 : 덮인 상태에서 시작 */
.pt.is-enter {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* 진입 완료 : 걷어냄 */
.pt.is-enter-done {
  opacity: 0;
  transform: translateY(-18px);
  filter: blur(10px);
}

@media (prefers-reduced-motion: reduce) {
  .pt {
    transition: none;
    opacity: 0;
    transform: none;
    filter: none;
  }
}
