/* 말풍선 글꼴: 마루부리(네이버, OFL) — 네이버 공식 웹폰트 서버에서 불러옴 */
@font-face {
  font-family: "MaruBuriCard";
  font-weight: 400;
  font-display: swap;
  src: url("https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Regular.woff2") format("woff2"),
       url("https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Regular.woff") format("woff");
}
@font-face {
  font-family: "MaruBuriCard";
  font-weight: 600;
  font-display: swap;
  src: url("https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-SemiBold.woff2") format("woff2"),
       url("https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-SemiBold.woff") format("woff");
}

:root {
  --maru: "MaruBuriCard", "MaruBuri", "AppleMyungjo", "Nanum Myeongjo", serif;
  --navy: #293C73;      /* AI FIELDNOTE 로고·하양이 모자 */
  --navy-deep: #1C2A52;
  --pencil: #F2C94C;    /* 로고 노랑·명함 속 연필 */
  --tongue: #EE8FA0;    /* 하트 */
  --studio: #E0DDDE;    /* 하양이 사진 배경 */
  --studio-b: #DDC5B6;  /* Jay 사진 배경 */
  --paper: #FFFFFF;
  --ink: #1E2433;
  --ink-soft: #5B6070;
  --rule: #E6E3E4;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  --radius: 28px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--navy);
  background-image: radial-gradient(120% 80% at 50% 0%, #34498A 0%, var(--navy) 55%, var(--navy-deep) 100%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.desk {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.card-wrap { width: min(100%, 400px); perspective: 1600px; }

/* ── 폴더 탭: Side A / Side B ── */
.tabs { display: flex; gap: 4px; }
.tab {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 10px 18px 9px;
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, .16);
  color: rgba(255, 255, 255, .82);
  font: 600 13.5px/1 var(--maru);
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.tab:hover { background: rgba(255, 255, 255, .26); }
.tab:focus-visible { outline: 3px solid var(--pencil); outline-offset: -3px; }
#tabA.is-active { background: var(--studio); color: var(--ink); }
#tabB.is-active { background: var(--studio-b); color: var(--ink); }
.card-wrap.flipped #tabA.is-active,
.card-wrap.flipped #tabB.is-active { background: #010000; color: #fff; }

/* ── 카드 (앞·뒤 겹쳐 놓고 뒤집기) ── */
.card {
  position: relative;
  width: 100%;
  display: grid;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}
.card.is-flipped { transform: rotateY(180deg); }

.face {
  grid-area: 1 / 1;
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 24px 60px rgba(8, 14, 36, .45);
  display: flex;
  flex-direction: column;
}
.back { transform: rotateY(180deg); }
/* 탭이 붙는 모서리는 각지게(폴더 모양). 뒷면은 뒤집히므로 오른쪽 위가 화면의 왼쪽 위 */
.front { border-top-left-radius: 0; }
.back { border-top-right-radius: 0; }

/* ── 무대: 하양이 / Jay ── */
.stage {
  position: relative;
  height: clamp(250px, 46svh, 400px);
  background: var(--studio);
  transition: background .3s;
  overflow: hidden;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}
.stage:focus-visible { box-shadow: inset 0 0 0 3px var(--pencil); }
.side-b .stage { background: var(--studio-b); }

/* Side B: 누르면 오른쪽 창에서 Jay가 말함(말풍선은 왼쪽) */
.talk-video {
  position: absolute;
  top: 60px; right: 12px; bottom: 12px;
  width: 48%;
  height: calc(100% - 72px);
  object-fit: cover;
  object-position: 50% 30%;
  border-radius: 18px;
  background: #15120F;
  box-shadow: 0 10px 24px rgba(30, 20, 10, .25);
  opacity: 0;
  transform: translateX(14px);
  transition: opacity .3s, transform .35s cubic-bezier(.3, 1.2, .5, 1);
  pointer-events: none;
}
.stage.video-talk .talk-video { opacity: 1; transform: none; }
.stage.video-talk .pup.is-on { opacity: 0; }
.stage.video-talk .hud-right { opacity: 0; }
.stage.video-talk .bubble { max-width: calc(52% - 32px); }
.hud-right { transition: opacity .25s; }

.pup {
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: none;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .35s ease, left .45s cubic-bezier(.3, 1.2, .5, 1), height .45s cubic-bezier(.3, 1.2, .5, 1);
  pointer-events: none;
}
.pup.is-on { opacity: 1; }
.pup.is-gif { height: 112%; bottom: -6%; }
/* 말하는 장면: 하양이가 오른쪽 아래로 작게 비켜서고, 말풍선은 왼쪽 빈자리에만 */
.stage.talking .pup { left: 78%; height: 70%; bottom: 17%; }
.stage.talking .pup.is-gif { height: 79%; bottom: 12.5%; }
.pup { transition: opacity .35s ease, left .45s cubic-bezier(.3, 1.2, .5, 1), height .45s cubic-bezier(.3, 1.2, .5, 1), bottom .45s cubic-bezier(.3, 1.2, .5, 1); }
.pup.hop { animation: hop .45s cubic-bezier(.3, 1.6, .5, 1); }
.pup.slide-l { animation: slideL .35s ease-out; }
.pup.slide-r { animation: slideR .35s ease-out; }
.pup.squish { animation: squish .35s ease-out; }

@keyframes hop {
  0% { transform: translateX(-50%) translateY(0); }
  40% { transform: translateX(-50%) translateY(-4.5%); }
  100% { transform: translateX(-50%) translateY(0); }
}
@keyframes slideL { from { transform: translateX(-20%); } to { transform: translateX(-50%); } }
@keyframes slideR { from { transform: translateX(-80%); } to { transform: translateX(-50%); } }
@keyframes squish {
  0% { transform: translateX(-50%) scale(1, 1); }
  35% { transform: translateX(-50%) scale(1.04, .95); }
  100% { transform: translateX(-50%) scale(1, 1); }
}

/* 말풍선 */
.bubble {
  position: absolute;
  top: 16px;
  left: 14px;
  margin: 0;
  width: max-content;
  max-width: 50%;
  padding: 12px 14px;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--maru);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(30, 36, 51, .14);
  transform: translateX(-8px) scale(.92);
  transform-origin: 100% 20%;
  opacity: 0;
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
  pointer-events: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
/* 꼬리: 오른쪽의 하양이를 가리킴 */
.bubble::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 22px;
  width: 12px; height: 12px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 2px;
}
.bubble.show { opacity: 1; transform: translateX(0) scale(1); }
.bubble b, .bubble small { display: block; }
/* 다음 장면: 말한 사람 */
.bubble.by { background: var(--navy); color: #fff; }
.bubble.by b { font-weight: 600; font-size: 15px; line-height: 1.4; }
.bubble.by b::before { content: "— "; color: var(--pencil); }
.bubble.by small { margin-top: 4px; font-size: 12.5px; line-height: 1.45; color: rgba(255, 255, 255, .78); }
/* 질문 */
.bubble.ask { background: var(--pencil); color: var(--ink); font-weight: 600; }
/* 추천곡 */
.bubble.song { background: #EEF1F9; color: var(--navy); }
.bubble.song small { font-size: 12.5px; color: var(--ink-soft); }
.bubble.song b { font-weight: 600; font-size: 16px; line-height: 1.35; margin-top: 2px; }
/* 명언 아래 말한 사람 */
.bubble.quote small {
  margin-top: 7px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  color: var(--navy);
}
/* Side B: AI 생각. 대표 문장은 영문 표지를 위에 */
.bubble em {
  display: block;
  margin-bottom: 6px;
  font: 700 10.5px/1.2 var(--sans);
  font-style: normal;
  letter-spacing: .1em;
  color: #B4462F;
}
.bubble.featured { box-shadow: 0 0 0 2px var(--pencil), 0 6px 18px rgba(30, 36, 51, .14); }
.bubble.featured span { font-weight: 600; font-size: 16px; }

/* 하트 파티클 */
.hearts-fx { position: absolute; inset: 0; pointer-events: none; }
.hearts-fx i {
  position: absolute;
  width: 18px; height: 18px;
  color: var(--tongue);
  animation: float 1.1s ease-out forwards;
}
.hearts-fx i svg { width: 100%; height: 100%; display: block; }
@keyframes float {
  0% { transform: translate(0, 0) scale(.4); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), -90px) scale(1.1) rotate(var(--rot)); opacity: 0; }
}

/* 친밀도·기록 */
.hud {
  position: absolute;
  left: 14px; right: 14px; bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.hud { align-items: flex-end; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.pet-name {
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 600 12.5px/1.4 var(--maru);
}
.affinity { display: flex; gap: 3px; padding-bottom: 5px; }
.affinity span {
  width: 16px; height: 15px;
  background: rgba(30, 36, 51, .16);
  -webkit-mask: var(--heart) center / contain no-repeat;
  mask: var(--heart) center / contain no-repeat;
  transition: background .2s, transform .2s;
}
.affinity span.on { background: var(--tongue); transform: scale(1.15); }
:root {
  --heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21.4 10.3 19.9C4.2 14.3 0 10.6 0 6.1 0 2.6 2.7 0 6.1 0c1.9 0 3.8.9 5.9 3.1C14.1.9 16 0 17.9 0 21.3 0 24 2.6 24 6.1c0 4.5-4.2 8.2-10.3 13.8z'/%3E%3C/svg%3E");
}
.closet {
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--ink-soft);
  font: 600 12px/1.4 var(--sans);
}
.closet.done { background: var(--pencil); color: var(--ink); }

.hint {
  position: absolute;
  left: 50%; bottom: 82px;
  margin: 0;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(30, 36, 51, .72);
  color: #fff;
  font: 500 12.5px/1.3 var(--sans);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .4s;
}
.hint.gone { opacity: 0; }

.flip-btn {
  position: absolute;
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  color: var(--navy);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.flip-btn svg { width: 20px; height: 20px; }
.flip-btn:focus-visible, .ghost:focus-visible, .row:focus-visible, .flip-back:focus-visible {
  outline: 3px solid var(--pencil);
  outline-offset: 2px;
}

/* 레벨 업: 픽셀 하양이 연출(종류는 card-data.js의 levelups) */
.levelup {
  --lv-bg: #010100;
  --lv-ink: var(--pencil);
  position: absolute;
  inset: 0;
  background: var(--lv-bg);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 0 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s;
}
.levelup.show { opacity: 1; visibility: visible; }
.lv-video { display: none; width: 100%; border-radius: 14px; background: #000; }
.levelup.video-mode .sprite { display: none; }
.levelup.video-mode .lv-video { display: block; }
.sprite {
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
}
.lv-text {
  margin: 0;
  color: var(--lv-ink);
  font: 800 24px/1.2 ui-monospace, "SF Mono", Menlo, "Apple SD Gothic Neo", monospace;
  letter-spacing: .04em;
  text-align: center;
  text-shadow: 3px 3px 0 rgba(180, 70, 47, .85);
  animation: blink .5s steps(2) infinite;
}
.levelup.light .lv-text { text-shadow: 2px 2px 0 rgba(30, 36, 51, .18); }
@keyframes blink { 50% { opacity: .6; } }

/* ── 이름 ── */
.who { text-align: center; padding: 22px 20px 6px; }
.title {
  margin: 0;
  font: 400 21px/1.2 var(--serif);
  letter-spacing: .04em;
  color: var(--ink);
}
.name {
  margin: 6px 0 0;
  font: 400 26px/1.25 var(--serif);
  color: var(--ink);
}

/* ── 연락처: 원래 명함의 '라벨 … 값' 줄을 그대로 누르는 줄로 ── */
.contacts { padding: 8px 12px 2px; display: grid; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 10px 0 12px;
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.row:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 1px;
  background: var(--rule);
}
.sns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 9px 2px 2px;
}
.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 0 4px;
  border-radius: 999px;
  background: #EEF1F9;
  color: var(--navy);
  font: 600 12.5px/1 var(--sans);
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.chip svg {
  flex: none;
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chip:active { transform: scale(.96); background: #E2E7F5; }
.chip.kakao { background: #FEE500; color: #191919; }
.chip.kakao svg { fill: currentColor; stroke: none; }
.chip.kakao:active { background: #F2D900; }
.chip:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; }
.row:hover { background: #F5F3F4; }
.row:active { background: #EEEAF0; transform: scale(.985); }
.lbl { font: 700 15.5px/1 var(--serif); }
.val {
  font: 700 clamp(13.5px, 3.9vw, 15.5px)/1.25 var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.act {
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #EEF1F9;
  color: var(--navy);
}
.act svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.extras {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 20px;
}
.ghost {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: 600 13.5px/1 var(--sans);
  padding: 11px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.ghost:active { transform: scale(.97); }

/* ── 뒷면 ── */
.back-stage {
  background: #010000;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
}
.pixel-hero { flex: none; height: 118px; width: auto; image-rendering: pixelated; }
.pixel-hero.is-photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; image-rendering: auto; }
.roles li { word-break: keep-all; }
.back-id { min-width: 0; }
.back-name { margin: 0 0 6px; font: 400 23px/1.25 var(--serif); color: #fff; }
.roles li { font: 500 14px/1.6 var(--sans); color: rgba(255, 255, 255, .8); }
.back-body {
  padding: 18px 22px 4px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.qr { margin: 0; }
.qr img {
  display: block;
  width: clamp(132px, 22svh, 176px);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 16px;
  image-rendering: pixelated;
}
.qr figcaption { margin-top: 10px; font: 500 13.5px/1.5 var(--sans); color: var(--ink-soft); }
.qr figcaption span { font-weight: 700; color: var(--ink); }
.roles, .links { list-style: none; margin: 0; padding: 0; }
.links { width: 100%; margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.links a {
  color: var(--navy);
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  padding: 9px 11px;
  border-radius: 999px;
  background: #EEF1F9;
}
.fieldnote-box { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fieldnote { display: block; width: 52%; margin: 0 auto; }
.yt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: 600 13px/1 var(--sans);
  text-decoration: none;
}
.yt svg { width: 20px; height: 20px; flex: none; }
.yt:active { transform: scale(.97); }
.yt:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; }
.flip-back {
  margin: 8px auto 20px;
  appearance: none;
  border: 0;
  background: var(--navy);
  color: #fff;
  font: 600 14px/1 var(--sans);
  padding: 13px 22px;
  border-radius: 999px;
  cursor: pointer;
}

/* 토스트 */
.toast {
  position: fixed;
  left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  margin: 0;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 600 14px/1.3 var(--sans);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 작은 화면(아이폰 SE 등) */
@media (max-height: 700px) {
  .who { padding-top: 14px; }
  .title { font-size: 18px; }
  .name { font-size: 22px; }
  .row { min-height: 44px; }
  .extras { padding-bottom: 14px; }
  .stage { height: clamp(230px, 40svh, 400px); }
  .tab { padding: 8px 16px 7px; }
}

/* 움직임 줄이기 */
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .pup.hop, .pup.slide-l, .pup.slide-r, .pup.squish { animation: none; }
  .sprite { animation-duration: 1.6s; }
  .lv-text { animation: none; }
}
