/* ============================================
   kdy.works — Active Business Card
   Design: Editorial Minimal
   Font: Space Grotesk + JetBrains Mono
============================================ */

/* ===== Design Tokens ===== */
:root {
  --bg:            #f0ede6;
  --text:          #111111;
  --text-muted:    #999999;
  --accent:        #c8ff00;
  --accent-dark:   #a3d400;
  --cf-bg:         #ffffff;
  --cb-bg:         #111111;
  --cb-text:       #f0ede6;
  --border:        #111111;
  --border-faint:  rgba(17,17,17,0.12);
  --shadow:        5px 5px 0 #111111;
  --radius:        12px;
  --font:          'Space Grotesk', -apple-system, sans-serif;
  --mono:          'JetBrains Mono', 'Courier New', monospace;
  --transition:    0.2s ease;
}

[data-theme="dark"] {
  --bg:            #111111;
  --text:          #f0ede6;
  --text-muted:    #555555;
  --cf-bg:         #1c1c1c;
  --cb-bg:         #f0ede6;
  --cb-text:       #111111;
  --border:        #f0ede6;
  --border-faint:  rgba(240,237,230,0.1);
  --shadow:        5px 5px 0 rgba(240,237,230,0.18);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background var(--transition), color var(--transition);
}

/* ===== Top Bar ===== */
.topbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 24px 0;
}

.topbar-name {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-faint);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
}

.theme-toggle:hover {
  border-color: var(--border);
  background: var(--text);
  color: var(--bg);
}

/* ===== Hero ===== */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 28px;
  gap: 20px;
  width: 100%;
}

/* ===== 3D Scene ===== */
.scene {
  perspective: 1200px;
  width: 420px;
  height: 240px;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
  -webkit-transition: -webkit-transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
  cursor: pointer;
  will-change: transform;
}

.card.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

/* ===== Card Faces ===== */
.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  /* clip-path instead of overflow:hidden — prevents backface mirroring */
  clip-path: inset(0 round var(--radius));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

/* ── Front ── */
.card-front {
  background: var(--cf-bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px 28px 22px;
}

.front-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* BHG monogram pill */
.monogram {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text);
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 5px;
}

/* 다크모드: 라임 배경에 흰 글자 → 얇은 다크 테두리로 가독성 확보 */
[data-theme="dark"] .monogram {
  -webkit-text-stroke: 0.6px rgba(0, 0, 0, 0.5);
  paint-order: stroke fill;
}

/* developer label */
.front-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  border: 1px solid var(--border-faint);
  padding: 3px 9px;
  border-radius: 5px;
}

.front-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.name {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

/* 앞면 영문이름 — 이름과 도메인 사이 */
.name-en {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: -4px;
}

.front-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.domain {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.flip-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover .flip-hint { opacity: 1; }

/* ── Back ── */
.card-back {
  background: var(--cb-bg);
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 24px 20px;
}

.back-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(240,237,230,0.12);
}

[data-theme="dark"] .back-header {
  border-bottom-color: rgba(17,17,17,0.12);
}

.back-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cb-text);
}

/* 뒷면 한국 이름 + 영문이름 묶음 */
.back-name-group {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

/* 뒷면 영문이름 — 한국 이름 오른쪽 작게 */
.back-name-en {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--cb-text);
  opacity: 0.45;
  letter-spacing: 0.02em;
}

.back-role {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* Contact rows + QR side by side */
.back-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex: 1;
  padding-top: 12px;
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: opacity 0.15s;
}

.contact-link:hover { opacity: 0.6; }

.cl-key {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  width: 38px;
  flex-shrink: 0;
}

/* 다크모드: 뒷면 배경이 밝아져서 라임 글자가 묻힘 → 얇은 다크 테두리로 가독성 확보 */
[data-theme="dark"] .cl-key {
  -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.75);
  paint-order: stroke fill;
}

.cl-val {
  font-size: 0.77rem;
  font-weight: 400;
  color: var(--cb-text);
  white-space: nowrap;
}

/* QR Code */
.qr-block {
  flex-shrink: 0;
  background: #ffffff;
  border-radius: 7px;
  padding: 4px;
  align-self: flex-end;
}

#qrcode canvas,
#qrcode img {
  display: block;
  width: 66px !important;
  height: 66px !important;
  border-radius: 4px;
}

/* ===== Action Buttons ===== */
.actions {
  display: flex;
  gap: 8px;
}

.btn-primary,
.btn-ghost {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 22px;
  border: 1.5px solid var(--border);
  transition: all var(--transition);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent);
  color: var(--text);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--text);
  color: var(--bg);
}

/* ===== Links Row ===== */
.links-row {
  display: flex;
  align-items: center;
  padding-bottom: 44px;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.link-item:first-child { padding-left: 0; }
.link-item:last-child  { padding-right: 0; }

.link-item:hover { color: var(--text-muted); }

.link-item i {
  font-size: 0.92rem;
}

.link-sep {
  width: 1px;
  height: 14px;
  background: var(--border-faint);
}

/* ===== Footer ===== */
.footer {
  padding-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.footer-sep { opacity: 0.35; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(72px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 20px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  pointer-events: none;
  border: 1.5px solid var(--border);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .scene   { width: 340px; height: 195px; }
  .name    { font-size: 1.65rem; }
  .cl-val  { font-size: 0.72rem; }
  #qrcode canvas, #qrcode img { width: 56px !important; height: 56px !important; }
  .card-front { padding: 20px 22px 18px; }
  .card-back  { padding: 18px 20px 16px; }
}

@media (max-width: 360px) {
  .scene { width: 300px; height: 172px; }
  .name  { font-size: 1.45rem; }
}
