/* === Intro Splash (door open + terminal typing) === */
.intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.intro.fade-out {
  pointer-events: none;
}
.intro.fade-out .intro-content {
  opacity: 0;
  transform: scale(1.15);
  transition: opacity 0.4s ease, transform 0.6s ease;
}
.intro.fade-out .door-left {
  transform: translateX(-100%);
}
.intro.fade-out .door-right {
  transform: translateX(100%);
}

.intro-door {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50.5%; /* 살짝 겹치게 */
  background:
    radial-gradient(ellipse at 50% 50%, #1F1F1F 0%, #0A0A0A 100%),
    var(--color-dark);
  z-index: 1;
  transition: transform 0.9s cubic-bezier(0.65, 0, 0.35, 1);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
}
.door-left {
  left: 0;
  border-right: 1px solid rgba(218, 119, 86, 0.15);
}
.door-right {
  right: 0;
  border-left: 1px solid rgba(218, 119, 86, 0.15);
}
.intro-door::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

.intro-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 16px;
  transition: opacity 0.4s ease, transform 0.6s ease;
}

.intro-bug {
  width: 220px;
  height: 220px;
  color: var(--color-orange);
  animation:
    intro-pulse 2.4s ease-in-out infinite,
    intro-blink-bug 1.8s ease-in-out infinite;
  filter:
    drop-shadow(0 16px 36px rgba(218, 119, 86, 0.5))
    drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
  cursor: pointer;
}
.intro-bug svg { width: 100%; height: 100%; display: block; }
@keyframes intro-pulse {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50%      { transform: scale(1.06) rotate(2deg); }
}
@keyframes intro-blink-bug {
  0%, 30%, 60%, 100% { opacity: 1; }
  40%, 50%           { opacity: 0.35; }
}

.intro-terminal {
  margin-top: 24px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 16px;
  color: var(--color-cream);
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(218, 119, 86, 0.2);
  padding: 8px 16px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  letter-spacing: -0.01em;
}
.intro-prompt {
  color: var(--color-orange);
  font-weight: 700;
}
.intro-typing { display: inline-block; }
.intro-caret {
  color: var(--color-orange);
  font-weight: 900;
  animation: caret-blink 1s step-end infinite;
  display: inline-block;
}
@keyframes caret-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.intro-content h2 {
  margin-top: 24px;
  font-size: 42px;
  letter-spacing: -0.03em;
  font-weight: 900;
  color: var(--color-cream);
}
.intro-sub {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--color-orange);
  font-weight: 700;
}
.intro-cta {
  margin-top: 32px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-cream);
  opacity: 0.55;
  animation: intro-blink 1.6s ease-in-out infinite;
  letter-spacing: -0.01em;
}
@keyframes intro-blink {
  0%, 100% { opacity: 0.5; transform: translateY(0); }
  50%      { opacity: 0.95; transform: translateY(4px); }
}

@media (max-width: 768px) {
  .intro-bug { width: 140px; height: 140px; }
  .intro-content h2 { font-size: 28px; }
  .intro-sub { font-size: 10px; letter-spacing: 0.25em; }
  .intro-cta { font-size: 13px; }
  .intro-terminal { font-size: 13px; padding: 6px 12px; }
}

/* === Congratulations + Wipe out === */
.congrats {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  background: rgba(20, 20, 20, 0);
  pointer-events: none;
  animation: congrats-bg 0.6s ease 0.4s forwards;
}
@keyframes congrats-bg {
  to {
    background: rgba(20, 20, 20, 0.94);
    pointer-events: auto;
  }
}
.congrats-content {
  text-align: center;
  color: var(--color-cream);
  z-index: 2;
  opacity: 0;
  transform: scale(0.8);
  animation:
    congrats-pop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s forwards,
    congrats-fadeout 1.2s ease 5s forwards;
}
@keyframes congrats-pop {
  to { opacity: 1; transform: scale(1); }
}
@keyframes congrats-fadeout {
  to { opacity: 0; transform: scale(0.92); }
}
.congrats-trophy {
  font-size: 100px;
  filter: drop-shadow(0 16px 36px rgba(218, 119, 86, 0.6));
  animation: trophy-spin 2.5s ease-in-out infinite;
}
@keyframes trophy-spin {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(4deg); }
}
.congrats-title {
  margin-top: 16px;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--color-orange);
  background: linear-gradient(135deg, #FFB088 0%, #DA7756 50%, #B85F3E 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.congrats-sub {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-cream);
  opacity: 0.85;
}
.congrats-meta {
  margin-top: 32px;
  font-size: 11px;
  opacity: 0.4;
}

/* Wipe-out: 모든 책상 콘텐츠가 검게 흡수됨 */
body.wipe-out .desk,
body.wipe-out .header,
body.wipe-out .footer,
body.wipe-out .bug,
body.wipe-out .object {
  animation: wipe-erase 1.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
@keyframes wipe-erase {
  0%   { filter: brightness(1) blur(0); opacity: 1; }
  60%  { filter: brightness(0.4) blur(8px); opacity: 0.5; }
  100% { filter: brightness(0) blur(20px); opacity: 0; }
}

/* === Ending screen (claude end terminal + restart) === */
.ending {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: var(--color-dark);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.ending.show { opacity: 1; }
.ending::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.5;
}
.ending-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px;
}
.ending-bug {
  width: 180px;
  height: 180px;
  color: var(--color-orange);
  animation: intro-pulse 2.4s ease-in-out infinite;
  filter:
    drop-shadow(0 16px 36px rgba(218, 119, 86, 0.45))
    drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}
.ending-bug svg { width: 100%; height: 100%; display: block; }
.ending-terminal {
  margin-top: 28px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 16px;
  color: var(--color-cream);
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(218, 119, 86, 0.3);
  padding: 8px 18px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  letter-spacing: -0.01em;
}
.ending-typing { display: inline-block; }
.ending-restart {
  margin-top: 36px;
  padding: 14px 32px;
  background: var(--color-orange);
  color: var(--color-dark);
  border-radius: 28px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 22px rgba(218, 119, 86, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
  opacity: 0;
  pointer-events: none;
}
.ending.show .ending-restart {
  animation: ending-restart-in 0.6s ease 1.6s forwards;
}
.ending-restart:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 30px rgba(218, 119, 86, 0.65);
}
@keyframes ending-restart-in {
  to { opacity: 1; pointer-events: auto; }
}
@media (max-width: 768px) {
  .ending-bug { width: 130px; height: 130px; }
  .ending-terminal { font-size: 13px; padding: 6px 12px; }
  .ending-restart { padding: 12px 24px; font-size: 14px; }
}

/* === Header === */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  z-index: 50;
  background: linear-gradient(180deg, rgba(20,20,20,0.92) 0%, transparent 100%);
}
.header-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.header h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
}
.tagline {
  font-size: 11px;
  color: var(--color-orange);
  letter-spacing: 0.22em;
  font-weight: 700;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-bar {
  width: 140px;
  height: 6px;
  background: rgba(244, 229, 217, 0.18);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--color-orange);
  border-radius: 3px;
  transition: width 0.6s ease;
}
.progress-label {
  font-size: 12px;
  color: var(--color-cream);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  min-width: 40px;
}
.reset-btn {
  font-size: 12px;
  color: var(--color-cream);
  background: rgba(244, 229, 217, 0.08);
  border: 1px solid rgba(244, 229, 217, 0.22);
  border-radius: 14px;
  padding: 5px 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: all 0.2s;
}
.reset-btn:hover {
  background: var(--color-orange);
  color: var(--color-dark);
  border-color: var(--color-orange);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .header { padding: 10px 14px; gap: 10px; }
  .header h1 { font-size: 16px; }
  .tagline { display: none; }
  .progress-bar { width: 80px; }
  .progress-label { font-size: 11px; min-width: 32px; }
  .reset-btn { font-size: 11px; padding: 4px 8px; }
}

/* === Social links (하단 floating, 주황 원 배경) === */
.social-links {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 12px;
  z-index: 55;
}
.social-links a {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-orange);
  color: var(--color-cream);
  box-shadow:
    0 6px 16px rgba(218, 119, 86, 0.45),
    0 2px 4px rgba(20, 20, 20, 0.4);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.social-links a:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow:
    0 12px 24px rgba(218, 119, 86, 0.6),
    0 4px 8px rgba(20, 20, 20, 0.5);
}
.social-links svg {
  width: 22px;
  height: 22px;
}
@media (max-width: 768px) {
  .social-links { bottom: 16px; left: 50%; transform: translateX(-50%); gap: 10px; }
  .social-links a { width: 40px; height: 40px; }
  .social-links svg { width: 18px; height: 18px; }
}

/* === 책상 표면 (가로 중앙 정렬) === */
.desk {
  position: relative;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 50%, var(--color-wood-1) 0%, var(--color-wood-2) 100%),
    var(--color-dark);
  background-blend-mode: multiply;
  padding-top: 80px;
  overflow: hidden;
}
.desk::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* === Zone (CREAM 베이지 매트) === */
.zone {
  position: absolute;
  border-radius: var(--zone-radius);
  background:
    linear-gradient(135deg, #F8E9D5 0%, #F4E5D9 50%, #EFD9C4 100%);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.55),
    0 4px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.06);
  padding: 16px;
  border: 1px solid rgba(20, 20, 20, 0.08);
  overflow: hidden;
}
.zone::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

.zone-label {
  position: absolute;
  top: -28px; left: 0;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--color-cream);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 8px;
}
.zone-label .ko {
  font-size: 13px;
  opacity: 1;
  font-weight: 700;
}
.zone-label::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-cream);
  opacity: 0.5;
}
.zone[data-id="understand"] .zone-label::before { background: #5B9BD5; opacity: 0.9; }
.zone[data-id="apply"] .zone-label::before      { background: #7AC74F; opacity: 0.9; }
.zone[data-id="develop"] .zone-label::before    { background: #DA7756; opacity: 0.9; }

/* === Mobile: zone 가로 가운데 정렬 (episodes.js의 inline left:50% 활용) === */
@media (max-width: 768px) {
  .zone {
    transform: translateX(-50%);
  }
}

/* === Object: 4:5 카드 (Instagram 카드뉴스 비율) === */
:root {
  --object-w: 88px;
  --object-h: 110px;
}
@media (max-width: 768px) {
  :root {
    --object-w: 68px;
    --object-h: 85px;
  }
}

.object {
  position: absolute;
  width: var(--object-w);
  height: var(--object-h);
  border-radius: 10px;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.35),
    0 14px 28px rgba(0, 0, 0, 0.18);
  transition:
    transform var(--dur-fast) var(--ease-bounce),
    box-shadow var(--dur-fast),
    background var(--dur-fast),
    color var(--dur-fast),
    outline var(--dur-fast);
  cursor: pointer;
  overflow: visible; /* 카드 아래 라벨 표시 위해 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Cover 이미지 카드 (01-04편) — 배경은 이미지가 채움 */
.object-cover {
  background: var(--color-dark);
}
.object-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  border-radius: 10px;
  transition: transform var(--dur-fast), filter var(--dur-fast);
}
.object-cover:hover {
  transform: translateY(-10px) scale(1.08);
  outline: 3px solid var(--color-orange);
  outline-offset: -3px;
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.55),
    0 24px 50px rgba(218, 119, 86, 0.45);
}
.object-cover:hover img {
  filter: saturate(1.15) brightness(1.05);
}

/* 텍스트 카드 (05-12편) — DARK 배경 + CREAM 텍스트 */
.object-text {
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
  background: var(--color-dark);
}
.object-text .object-num {
  font-size: 32px;
  font-weight: 900;
  color: var(--color-cream);
  letter-spacing: -0.04em;
  line-height: 1;
}
.object-text .object-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--color-cream);
  opacity: 0.7;
  line-height: 1.2;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

/* 텍스트 카드 호버: ORANGE 배경 + DARK 텍스트 */
.object-text:hover {
  transform: translateY(-10px) scale(1.08);
  background: var(--color-orange);
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.55),
    0 24px 50px rgba(218, 119, 86, 0.55);
}
.object-text:hover .object-num,
.object-text:hover .object-title {
  color: var(--color-dark);
  opacity: 1;
}

/* === 호버 라벨 (카드 아래) === */
.object-label {
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: rgba(20, 20, 20, 0.88);
  color: var(--color-cream);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--dur-fast), transform 0.2s var(--dur-fast);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 6;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.object:hover .object-label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === 책상 배경 장식 (12 아이콘 옅게 흩뿌림) === */
.desk-deco {
  position: absolute;
  width: 56px;
  height: 56px;
  pointer-events: none;
  opacity: 0.07;
  filter: brightness(0.5) saturate(0.6);
  z-index: 0;
  user-select: none;
  animation: deco-float 8s ease-in-out infinite;
}
@keyframes deco-float {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(var(--r, 0deg)) scale(var(--s, 1)); }
  50%      { transform: translate3d(0, -3px, 0) rotate(calc(var(--r, 0deg) + 2deg)) scale(var(--s, 1)); }
}

/* === 자율 이동 배경 벌레 === */
.bg-bug {
  position: fixed;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 2;
  opacity: 0.42;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
  color: var(--color-orange);
  will-change: transform;
}
.bg-bug svg {
  width: 100%;
  height: 100%;
  display: block;
}
@media (max-width: 768px) {
  .bg-bug { width: 16px; height: 16px; opacity: 0.32; }
}

/* === 완료 도장 === */
.stamp {
  position: absolute;
  top: -8px; right: -8px;
  width: 28px; height: 28px;
  border: 2px solid var(--color-orange);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--color-orange);
  font-weight: 900;
  background: var(--color-cream);
  transform: rotate(-12deg);
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* === 트로피 === */
.trophy {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  z-index: 30;
  filter: drop-shadow(0 20px 30px rgba(218,119,86,0.5));
}

/* === Error === */
.error-card {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-cream);
  color: var(--color-dark);
  padding: 24px 32px;
  border-radius: 12px;
}
.error-card button {
  margin-left: 12px;
  background: var(--color-orange);
  color: var(--color-dark);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 700;
}

.footer {
  position: fixed;
  bottom: 8px; right: 16px;
  font-size: 11px;
  opacity: 0.5;
  z-index: 50;
}
