/* 명함 본체(.face 안쪽)는 a-terminal.html 초안의 수치를 그대로 옮겼다. 720x400 고정.
   화면 폭에 맞추는 일은 .stage 통짜 scale(--s)가 하고, 내부 px 는 건드리지 않는다. */

@font-face {
  font-family: "Fira Code Local";
  src: url("/fonts/FiraCode-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fira Code Local";
  src: url("/fonts/FiraCode-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Nanum Local";
  src: url("/fonts/NanumGothicBold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #191c21;
  --card: #0d0f12;
  --line: #1e232a;
  --fg: #e6e6e6;
  --muted: #5c6470;
  --green: #3ddc84;
  --claude: #d97757;  /* Anthropic 로고 색 */
  --amber: #e8b34a;
  --mono: "Fira Code", "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 96px;
  /* 아주 옅은 격자. 터미널 배경 느낌만 주고 카드를 방해하지 않는 정도로. */
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 28px 28px;
}

.wrap { width: 100%; max-width: 720px; }

/* ── 카드 ───────────────────────────────────────────────── */
.stage-wrap { height: calc(400px * var(--s, 1)); display: flex; justify-content: center; }

.stage {
  flex: none;  /* flex item 으로 줄어들면 scale(--s) 위에 축소가 한 번 더 먹는다 */
  width: 720px; height: 400px;
  transform: scale(var(--s, 1));
  transform-origin: top center;
  perspective: 1600px;
  background: none; border: 0; padding: 0;
  cursor: pointer;
  font: inherit; color: inherit; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.stage:focus-visible { outline: 2px solid var(--green); outline-offset: 8px; border-radius: 8px; }

.flip {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.2,.7,.2,1);
}
.stage.flipped .flip { transform: rotateY(180deg); }

.face {
  position: absolute; inset: 0;
  border-radius: 6px; overflow: hidden;
  background: var(--card); color: var(--fg);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}

.front { padding: 56px 60px; display: flex; flex-direction: column; justify-content: space-between; }
.dots { display: flex; gap: 9px; position: absolute; top: 24px; left: 26px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.prompt { font-size: 19px; color: var(--muted); letter-spacing: .02em; }
.prompt b { color: var(--green); font-weight: 500; }
.out { margin-top: 14px; }
.name-main { font-family: "Noto Sans KR", var(--mono); font-size: 62px; font-weight: 900; letter-spacing: .14em; color: #fff; line-height: 1.05; }
.name-sub { font-size: 20px; color: #7a8492; letter-spacing: .22em; margin-top: 12px; text-transform: uppercase; }
/* 영어에서는 주/부가 뒤집힌다 — 라틴 이름이 커지므로 mono 로, 한글이 부제로 내려간다. */
body.en .name-main { font-family: var(--mono); font-size: 50px; font-weight: 700; letter-spacing: .04em; }
body.en .name-sub { font-family: "Noto Sans KR", var(--mono); letter-spacing: .3em; text-transform: none; }
.role { font-size: 16px; color: var(--amber); letter-spacing: .03em; margin-top: 10px; }
.cursor { display: inline-block; width: 11px; height: 20px; background: var(--green); vertical-align: -3px; margin-left: 6px; animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.back { transform: rotateY(180deg); padding: 52px 56px; display: flex; align-items: center; gap: 40px; }
.rows { flex: 1; min-width: 0; }
.back .row { display: flex; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.back .row[hidden] { display: none; }
.back .row:last-child { border-bottom: 0; }
.k { width: 96px; flex: none; color: var(--muted); }
.v { color: var(--fg); letter-spacing: .01em; }
.v.hl { color: var(--green); }
/* QR: 어두운 배경 위 반전 QR 은 못 읽는 스캐너가 있어 흰 타일 + quiet zone 을 준다. */
.qr { flex: none; text-align: center; }
.qr .tile { width: 126px; height: 126px; background: #fff; border-radius: 8px; padding: 9px; }
.qr img { display: block; width: 100%; height: 100%; }
.qr .cap { margin-top: 11px; font-size: 11px; letter-spacing: .16em; color: var(--muted); }
.qr .cap b { color: var(--green); font-weight: 400; }

/* ── 카드 밖 ────────────────────────────────────────────── */
.hint { margin-top: 22px; text-align: center; font-size: 13px; color: var(--muted); transition: opacity .3s; }
.hint.gone { opacity: 0; }

.actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn {
  position: relative;  /* .pop 배지의 기준점 */
  font: inherit; font-size: 13px;
  padding: 9px 16px; border-radius: 6px;
  border: 1px solid var(--line); background: #101318; color: #9aa4b0;
  text-decoration: none; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--green); color: var(--green); }

/* ── 플로팅 버튼 ────────────────────────────────────────── */
.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: var(--card); border: 1px solid #2a3038;
  color: var(--green); font: inherit; font-size: 18px; cursor: pointer;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  transition: transform .18s, border-color .18s;
}
.fab:hover { transform: translateY(-2px); border-color: var(--green); }
/* Claude 별. 프레임 문자마다 폭이 달라 자리가 떨리므로 폭을 고정한다. */
.star { display: inline-block; width: 1em; text-align: center; color: var(--claude); font-size: 19px; line-height: 1; }
.fab.on .star { opacity: .4; }

/* ── 터미널 패널 ────────────────────────────────────────── */
.term {
  position: fixed; right: 24px; bottom: 92px; z-index: 29;
  width: 400px; height: min(560px, 68dvh);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .2s, transform .2s;
  overflow: hidden;
}
.term.open { opacity: 1; transform: none; pointer-events: auto; }

.term-head { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.dots.sm { position: static; gap: 6px; }
.dots.sm i { width: 9px; height: 9px; }
.term-title { flex: 1; font-size: 12px; color: var(--muted); }
.term-x { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 2px 4px; }
.term-x:hover { color: var(--fg); }

.log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px; font-size: 13px; line-height: 1.65; }
.log .me { color: var(--green); white-space: pre-wrap; word-break: break-word; }
.log .me::before { content: "$ "; color: var(--muted); }
.log .bot { color: var(--fg); white-space: pre-wrap; word-break: break-word; margin: 6px 0 16px; }
.log .sys { color: var(--muted); margin-bottom: 14px; }
.log .err { color: #ff7b72; margin: 6px 0 16px; }
.log .think { color: var(--muted); font-size: 12px; margin: 6px 0; display: flex; align-items: center; gap: 7px; }
.log .think .star { font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { font: inherit; font-size: 12px; padding: 6px 10px; border-radius: 5px; border: 1px solid var(--line); background: #101318; color: #9aa4b0; cursor: pointer; }
.chip:hover { border-color: var(--green); color: var(--green); }

.ask { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.ps1 { color: var(--green); font-size: 13px; }
.ask input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--fg); font: inherit; font-size: 13px; }
.ask input::placeholder { color: #3d444d; }
.send { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 2px 6px; }
.send:hover { color: var(--green); }
.ask.busy { opacity: .5; pointer-events: none; }

@media (max-width: 560px) {
  /* 가상 키보드가 올라와도 layout viewport 는 그대로라 100dvh 로는 키보드 높이를
     뺄 수 없다(dvh 는 브라우저 UI 에만 반응한다). 그대로 두면 브라우저가 입력창을
     보여주려고 화면을 밀어 올려서 헤더와 인사말이 위로 잘려 나간다. 그래서 실제
     가시 영역을 app.js 가 visualViewport 로 재서 --vv-top/--vv-h 에 넣어 준다. */
  .term { right: 0; top: var(--vv-top, 0px); bottom: auto; width: 100%; height: var(--vv-h, 100dvh); border-radius: 0; border: 0; transform: translateY(20px); }
  .fab { right: 16px; bottom: 16px; }
  /* 전체화면 패널 위에 떠서 입력창을 가린다. 닫기는 헤더의 X 로 한다. */
  .fab.on { opacity: 0; pointer-events: none; }
}

/* ── 언어 피커 ──────────────────────────────────────────── */
.lang {
  position: fixed; top: 18px; right: 22px; z-index: 31;
  display: flex; gap: 2px; padding: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
}
.lang-btn {
  font: inherit; font-size: 11px; letter-spacing: .1em;
  padding: 5px 10px; border: 0; border-radius: 5px;
  background: none; color: var(--muted); cursor: pointer; transition: .15s;
}
.lang-btn:hover { color: var(--fg); }
.lang-btn.on { background: #161b21; color: var(--green); }

/* ── 복사 피드백 ────────────────────────────────────────── */
.btn.ok { border-color: var(--green); color: var(--green); }
.btn.no { border-color: #ff7b72; color: #ff7b72; }
.pop {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 8px;
  transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; color: var(--green);
  padding: 4px 9px; border-radius: 5px;
  background: #101318; border: 1px solid var(--green);
  box-shadow: 0 6px 16px rgba(0,0,0,.5);
  pointer-events: none;
  animation: pop 1.5s cubic-bezier(.2,.7,.2,1) forwards;
}
.pop.bad { color: #ff7b72; border-color: #ff7b72; }
@keyframes pop {
  0%   { opacity: 0; transform: translate(-50%, 6px)  scale(.9); }
  18%  { opacity: 1; transform: translate(-50%, -2px) scale(1); }
  70%  { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -18px) scale(1); }
}

@media (max-width: 560px) {
  .lang { top: 12px; right: 12px; }
}

body.local-fonts { --mono: "Fira Code Local", ui-monospace, SFMono-Regular, Menlo, monospace; }
body.local-fonts .name-main { font-family: "Nanum Local", var(--mono); }
body.en.local-fonts .name-main { font-family: var(--mono); }
body.en.local-fonts .name-sub { font-family: "Nanum Local", var(--mono); }

body.calm .flip,
body.calm .term,
body.calm .hint { transition: none; }
body.calm .cursor,
body.calm .pop { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .flip, .term, .hint { transition: none; }
  .cursor, .pop { animation: none; }
}
