/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Custom cursor ─── */
@media (pointer: fine) {
  *, *::before, *::after { cursor: none !important; }
}

.custom-cursor {
  position: fixed;
  width: 17px;
  height: 17px;
  background: #7cf1f8;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: left, top;
}

:root {
  --nav-h:    48px;
  --footer-h: 40px;
  --content-h: calc(100vh - var(--nav-h) - var(--footer-h));
  --black:  #111;
  --gray:   #888;
  --light:  #f5f5f5;
  --border: #ddd;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--black);
  font-family: 'Pretendard', sans-serif;
  font-weight: 300;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }

/* ─── Navigation ─── */
#nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.nav-inner { display: flex; gap: 28px; }

.nav-link {
  font-family: 'Pretendard', sans-serif;
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 0.01em;
  color: var(--black);
  transition: opacity 0.15s;
}
.nav-link:hover { opacity: 0.4; }
.nav-link.active { border-bottom: 1px solid var(--black); }

/* ─── Footer ─── */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Pretendard', sans-serif;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--gray);
  background: #fff;
  z-index: 80;
}

/* ─── Page ─── */
.page {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  height: var(--content-h);
  overflow: hidden;
}

/* ─── Admin Bar ─── */
.admin-bar {
  position: fixed;
  bottom: calc(var(--footer-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  padding: 6px 14px;
  backdrop-filter: blur(8px);
  z-index: 90;
}

.admin-btn {
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border: 1px solid var(--black);
  cursor: pointer;
  background: #fff;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.admin-btn:hover { background: var(--black); color: #fff; }
.admin-btn.danger { border-color: #c00; color: #c00; }
.admin-btn.danger:hover { background: #c00; color: #fff; }

.admin-size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.admin-size-controls input {
  width: 48px;
  border: 1px solid var(--border);
  padding: 2px 4px;
  font-size: 12px;
  text-align: center;
}

/* ─── MAIN PAGE ─── */
#main-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.main-image-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

#mainImage {
  object-fit: contain;
  max-width: 90vw;
  max-height: calc(var(--content-h) * 0.9);
}

.main-placeholder {
  width: clamp(200px, 30vw, 320px);
  height: clamp(150px, 22vw, 240px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* ─── PROJECTS — index / detail split ─── */
.projects-split-page {
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* Left: project index list (1/3) */
.project-index {
  width: 33.333%;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
}

.project-index-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0px 20px;
  cursor: pointer;
  user-select: none;
}

.project-index-name {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  color: #9e9e9e;
  transition: color 0.15s;
}

.project-index-year {
  font-size: 14px;
  font-weight: 400;
  color: #9e9e9e;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  transition: color 0.15s;
}

.project-index-item:hover .project-index-name,
.project-index-item:hover .project-index-year { color: #555; }

.project-index-item.active .project-index-name,
.project-index-item.active .project-index-year { color: var(--black); }

.project-index-empty {
  padding: 28px 20px;
  font-size: 13px;
  color: var(--gray);
}

/* Right: project detail (2/3) */
.project-detail {
  flex: 1;
  height: 100%;
  overflow-y: auto;
}

.detail-info {
  padding: 24px 32px 20px;
}

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.detail-name {
  font-size: 14px;
  font-weight: 300;
  flex: 1;
}

.detail-year {
  font-size: 14px;
  font-weight: 400;
  color: var(--black);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.detail-edit-btn {
  flex-shrink: 0;
  margin-left: auto;
}

.detail-desc {
  font-size: 14px;
  font-weight: 300;
  line-height: 1.4;
  color: var(--black);
  white-space: pre-wrap;
}

.detail-img {
  width: 100%;
  height: auto;
  display: block;
}

.detail-placeholder {
  padding: 60px 32px;
  text-align: center;
  color: var(--gray);
  font-size: 13px;
}

/* ─── EDIT MODAL ─── */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.94);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.popup-overlay.open { display: flex; }

.popup { position: relative; background: #fff; }

.popup-close {
  position: absolute;
  top: 12px; right: 14px;
  font-size: 14px;
  color: var(--gray);
  z-index: 10;
  line-height: 1;
}
.popup-close:hover { color: var(--black); }

.popup-edit {
  width: clamp(320px, 40vw, 560px);
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(24px, 3vw, 40px);
}
.edit-title {
  font-size: 14px;
  font-weight: 300;
  margin-bottom: 20px;
}
.edit-form { display: flex; flex-direction: column; gap: 12px; }
.edit-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 5px 0;
  font-size: 14px;
  font-weight: 300;
  outline: none;
  background: transparent;
}
.edit-input:focus { border-bottom-color: var(--black); }
.edit-textarea {
  width: 100%;
  border: 1px solid var(--border);
  padding: 10px;
  font-size: 14px;
  font-weight: 300;
  min-height: 100px;
  resize: vertical;
  outline: none;
}
.edit-textarea:focus { border-color: var(--black); }

.edit-images-section { display: flex; flex-direction: column; gap: 8px; }
.cover-preview img { max-height: 70px; object-fit: contain; margin-top: 4px; }

.images-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.images-preview img {
  width: 56px; height: 56px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.edit-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ─── INFO links ─── */
.info-link {
  color: inherit;
  text-decoration: none;
}
.info-link:hover { font-weight: 500; }

/* ─── INFO PAGE ─── */
.info-page { overflow-y: auto; }

.info-content {
  padding: clamp(24px, 3vw, 48px) clamp(24px, 4vw, 48px) 20px;
  font-family: 'Pretendard', sans-serif;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.info-edit-panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(255,255,255,0.97);
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-edit-inner {
  width: 100%;
  max-width: 860px;
  padding: clamp(24px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.edit-hint {
  font-size: 12px;
  color: var(--gray);
  letter-spacing: 0.03em;
}
.info-textarea {
  width: 100%;
  height: clamp(200px, 60vh, 560px);
  border: 1px solid var(--border);
  padding: 14px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.65;
  resize: none;
  outline: none;
  background: transparent;
}
.info-textarea:focus { border-color: var(--black); }

/* ─── DIARY PAGE ─── */
.diary-page { overflow-y: auto; }

.diary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 18vw, 220px), 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.diary-block {
  background: #fff;
  min-height: clamp(120px, 16vh, 160px);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: filter 0.1s;
}
.diary-block:hover { filter: brightness(0.94); }

.diary-block-inner {
  padding: clamp(12px, 1.5vw, 18px);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.diary-block.type-image .diary-block-inner { padding: 0; justify-content: flex-start; }
.diary-block.type-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex: 1;
}

.diary-block-text {
  font-family: 'Pretendard', sans-serif;
  font-size: clamp(12px, 1.3vw, 15px);
  font-weight: 300;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.diary-block-meta {
  font-size: 10px;
  letter-spacing: 0.05em;
  margin-top: 8px;
  opacity: 0.55;
  color: inherit;
}

.diary-block-type-badge {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
  color: inherit;
}

.diary-admin { justify-content: center; }

.popup-text-editor {
  width: clamp(300px, 40vw, 520px);
  max-height: 80vh;
  padding: clamp(24px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.block-textarea {
  width: 100%;
  height: clamp(180px, 30vh, 280px);
  border: 1px solid var(--border);
  padding: 12px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.6;
  resize: none;
  outline: none;
  background: transparent;
}
.block-textarea:focus { border-color: var(--black); }

.popup-block-detail {
  width: clamp(300px, 50vw, 600px);
  max-height: 80vh;
  padding: clamp(24px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.popup-block-detail img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
}
.popup-block-detail .block-text-full {
  font-size: 14px;
  font-weight: 300;
  line-height: 1.7;
  white-space: pre-wrap;
}
.block-detail-meta {
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.block-detail-actions {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  :root {
    --nav-h: 40px;
    --footer-h: 36px;
  }
  .nav-link { font-size: 13px; }
  .nav-inner { gap: 20px; }

  .projects-split-page { flex-direction: column; }
  .project-index {
    width: 100%;
    height: 38%;
  }
  .project-detail { height: 62%; }
  .detail-info { padding: 16px 20px; }

  .diary-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-bar { width: 90vw; flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 480px) {
  .diary-grid { grid-template-columns: repeat(2, 1fr); }
}
