/* =========================================================================
   Zhijie Tan · Personal Site
   Two-theme system: dark (default — Private Banking) + light (minimal warm).
   Both share the same champagne-gold accent for visual continuity.
   ========================================================================= */

/* ---------- 1. Theme tokens ----------------------------------------------- */

:root,
:root[data-theme="dark"] {
  --bg:              #10151C;
  --bg-accent:       #1A222D;
  --surface:         #1E2832;
  --surface-glass:   rgba(30, 40, 50, 0.55);
  --ink:             #EDE4CE;
  --ink-soft:        rgba(237, 228, 206, 0.72);
  --ink-muted:       rgba(237, 228, 206, 0.45);
  --divider:         rgba(237, 228, 206, 0.10);
  --accent:          #C9A876;
  --accent-soft:     rgba(201, 168, 118, 0.45);
  --accent-deep:     #E0C28A;
  --halo:            radial-gradient(ellipse at 50% 88%, rgba(201,168,118,0.20) 0%, transparent 55%);
  --photo-shadow:    drop-shadow(0 30px 50px rgba(0,0,0,0.55)) drop-shadow(0 0 30px rgba(201,168,118,0.10));
  --shadow:          0 30px 80px -30px rgba(0, 0, 0, 0.7);
  --footer-bg:       #0A0E14;
  --footer-ink:      #EDE4CE;
  --footer-ink-soft: rgba(237, 228, 206, 0.55);
  --badge-bg:        #FFFFFF;
  --badge-ink:       #1A1410;
  --social-hover-bg: #FFFFFF;
  --grain-blend:     screen;
  --grain-opacity:   0.04;
  --font-display:    'DM Serif Display', 'Noto Serif SC', Georgia, serif;
  --font-body:       'Outfit', 'Noto Sans SC', system-ui, sans-serif;
}

:root[data-theme="light"] {
  --bg:              #F1E9D7;
  --bg-accent:       #E5D9BD;
  --surface:         #FBF6E8;
  --surface-glass:   rgba(251, 246, 232, 0.65);
  --ink:             #1E1812;
  --ink-soft:        rgba(30, 24, 18, 0.72);
  --ink-muted:       rgba(30, 24, 18, 0.48);
  --divider:         rgba(30, 24, 18, 0.14);
  --accent:          #9B7A47;
  --accent-soft:     rgba(155, 122, 71, 0.45);
  --accent-deep:     #7A5E33;
  --halo:            radial-gradient(ellipse at 50% 88%, rgba(155,122,71,0.18) 0%, transparent 55%);
  --photo-shadow:    drop-shadow(0 24px 40px rgba(30,24,18,0.18));
  --shadow:          0 30px 60px -28px rgba(30, 24, 18, 0.28);
  --footer-bg:       #1E1812;
  --footer-ink:      #F1E9D7;
  --footer-ink-soft: rgba(241, 233, 215, 0.62);
  --badge-bg:        #FFFFFF;
  --badge-ink:       #1A1410;
  --social-hover-bg: #FFFFFF;
  --grain-blend:     multiply;
  --grain-opacity:   0.03;
  --font-display:    'DM Serif Display', 'Noto Serif SC', Georgia, serif;
  --font-body:       'Outfit', 'Noto Sans SC', system-ui, sans-serif;
}

/* ---------- 2. Base ------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(16px * var(--font-scale, 1));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.45s ease, color 0.45s ease;
}

body { min-height: 100vh; overflow-x: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 3. Shell + background design ---------------------------------- */

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: background-color 0.45s ease;
}

/* Subtle grain texture for premium tactile feel — uniform, no seams */
.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, currentColor 0.5px, transparent 0);
  background-size: 4px 4px;
  color: var(--ink);
  opacity: var(--grain-opacity);
  z-index: 1;
  mix-blend-mode: var(--grain-blend);
}

/* Background ornament is now a no-op — user wants a single uniform bg */
.bg-ornament { display: none; }

/* ---------- 4. Header ----------------------------------------------------- */

.site-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 22px clamp(20px, 4vw, 56px);
}

/* When hamburger is visible (phone), space header items apart */
@media (max-width: 639px) {
  .site-header { justify-content: space-between; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Desktop Z monogram — removed per request. Hamburger appears only on phone. */
.brand-mark {
  display: none;
}

.brand-mark.hamburger {
  display: none; /* enabled at phone breakpoint */
  width: 40px; height: 40px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
}

.brand-mark.hamburger:hover {
  background: var(--accent);
  color: var(--bg);
}

.brand-mark.hamburger svg { width: 18px; height: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--divider);
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.04em;
  font-family: var(--font-body);
}

.header-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.header-btn svg { width: 15px; height: 15px; }

.header-btn.icon-only { padding: 10px; }
.header-btn.icon-only svg { width: 16px; height: 16px; }

/* ---------- 5. Hero ------------------------------------------------------- */

.hero {
  flex: 1;
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 1.5vw, 28px);
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(8px, 1.5vw, 16px) clamp(20px, 4vw, 64px) 0;
}

/* Photo column */
.hero-photo {
  position: relative;
  display: grid;
  place-items: end center;
  align-self: stretch;
  min-height: clamp(380px, 56vh, 580px);
}

.photo-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--halo);
}

.photo-img {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 520px;
  height: auto;
  filter: var(--photo-shadow);
  -webkit-mask-image: linear-gradient(to bottom, black 93%, transparent 100%);
          mask-image: linear-gradient(to bottom, black 93%, transparent 100%);
}

/* Light mode: left edge needs softening — dark suit vs warm-beige bg is high contrast */
[data-theme="light"] .photo-img {
  -webkit-mask-image:
    linear-gradient(to right, transparent 0%, black 12%),
    linear-gradient(to bottom, black 85%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to right, transparent 0%, black 12%),
    linear-gradient(to bottom, black 85%, transparent 100%);
          mask-composite: intersect;
}

.photo-img-mobile { display: none; }

/* Info column */
.hero-info {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 24px);
  max-width: 560px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.eyebrow::before {
  content: "";
  width: 36px;
  height: 1px;
  background: var(--accent);
}

.name-block { display: flex; flex-direction: column; gap: 4px; }

.name-en {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 4.6vw, 60px);
  line-height: 1.05;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.32em;
  row-gap: 0.1em;
}

/* Keep each name part together — if the line is too tight,
   the Chinese span wraps to a new line instead of breaking mid-word. */
.name-en > span { white-space: nowrap; }

.name-zh {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.72em;            /* relative to .name-en parent */
  color: var(--accent);
  margin: 0;
  letter-spacing: 0.08em;
}

.title-line {
  font-size: clamp(13.5px, 1vw, 15.5px);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.55;
  margin: 0;
  text-wrap: pretty;
}

/* Licenses now stack vertically */
.licenses {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.licenses li {
  position: relative;
  padding-left: 16px;
}
.licenses li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.7em;
  width: 8px; height: 1px;
  background: var(--accent);
  opacity: 0.7;
}

/* Contact list */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 20px 0 0;
  padding: 20px 0 0;
  list-style: none;
  border-top: 1px solid var(--divider);
}

.contact-row {
  display: grid;
  grid-template-columns: 22px 86px 1fr;
  align-items: start;
  gap: 10px;
  font-size: 14.5px;
}

.contact-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-top: 2px;
}
.contact-icon svg { width: 18px; height: 18px; }

.contact-label {
  color: var(--ink-muted);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
}

.contact-value {
  color: var(--ink);
  word-break: normal;
  overflow-wrap: anywhere;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.contact-value a {
  color: var(--ink);
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}
.contact-value a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.copy-btn {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0;
  transform: translateY(2px);
  transition: all 0.2s ease;
}

.contact-row:hover .copy-btn { opacity: 1; transform: translateY(0); }

.copy-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.copy-btn svg { width: 12px; height: 12px; }

/* Social section */
.social {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
}

.social-label {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.social-label .contact-icon { margin-top: 0; }

.social-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-left: 0;       /* align with contact icons on left edge */
  margin-top: 4px;
}

.social-link {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--divider);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.social-link svg { width: 20px; height: 20px; transition: color 0.3s ease; position: relative; z-index: 2; }

/* WeChat icon path data only fills ~80% of its viewBox — bump it up so it
   reads at the same visual weight as the other social glyphs. */
.social-link[data-network="wechat"] svg { width: 26px; height: 26px; }

/* Brand-color hover with inverted background so the icon really pops */
.social-link:hover {
  transform: translateY(-3px);
  background: var(--social-hover-bg);
  border-color: var(--social-hover-bg);
  box-shadow: 0 14px 28px -10px rgba(0,0,0,0.35);
}

.social-link[data-network="linkedin"]:hover  { color: #0A66C2; }
.social-link[data-network="facebook"]:hover  { color: #1877F2; }
.social-link[data-network="wechat"]:hover    { color: #07C160; }
.social-link[data-network="instagram"]:hover { color: #fff; }
/* Instagram needs a real bg gradient when hovered to be readable */
.social-link[data-network="instagram"]:hover {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border-color: transparent;
}

/* ---------- 6. Footer ----------------------------------------------------- */

.site-footer {
  position: relative;
  z-index: 20;
  background: var(--footer-bg);
  color: var(--footer-ink);
  padding: 32px clamp(20px, 4vw, 64px);
  margin-top: auto;
  transition: background-color 0.5s ease, color 0.5s ease;
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr auto;
  gap: 40px;
  align-items: center;
}

.footer-links { display: flex; flex-direction: column; gap: 16px; }

.footer-link-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: center;
}

.footer-link {
  position: relative;
  color: var(--footer-ink);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.footer-link::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.footer-link:hover { color: var(--accent); }
.footer-link:hover::after { width: 100%; }

.footer-divider {
  display: inline-block;
  width: 1px;
  height: 12px;
  background: var(--footer-ink-soft);
  opacity: 0.45;
}

.footer-disclaimer {
  font-size: 11.5px;
  color: var(--footer-ink-soft);
  max-width: 640px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.footer-badges {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.footer-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  border-radius: 8px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  width: fit-content;
}
.footer-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(0,0,0,0.5);
}
.footer-badge img { height: 28px; width: auto; display: block; }
.footer-badge-label {
  font-size: 10px;
  color: var(--footer-ink-soft);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- 7. Mobile menu drawer ----------------------------------------- */

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 24px clamp(20px, 5vw, 32px);
  transform: translateX(-100%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
  pointer-events: none;
}
.mobile-menu.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 56px;
}

.mobile-menu-items {
  display: flex;
  flex-direction: column;
  gap: 24px;
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}
.mobile-menu-items a {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 22px;
  transition: color 0.2s ease;
}
.mobile-menu-items a:hover { color: var(--accent); }

.mobile-menu-foot {
  display: flex;
  gap: 10px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}
.mobile-menu-foot .header-btn { flex: 1; justify-content: center; }

/* ---------- 8. Modal & toast --------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  background: var(--surface);
  color: var(--ink);
  padding: 32px;
  border-radius: 16px;
  max-width: 360px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
  animation: slideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  border: 1px solid var(--divider);
}

.modal-card h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  margin: 0 0 6px;
  color: var(--ink);
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.qr-box {
  width: 220px;
  height: 220px;
  margin: 0 auto 18px;
  background: white;
  border: 1px solid var(--divider);
  border-radius: 12px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.modal-close:hover { border-color: var(--accent); color: var(--accent); }
.modal-close svg { width: 14px; height: 14px; }

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 22px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.4);
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent-deep);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

/* ---------- 9. Reveal / lang fade ----------------------------------------- */

.reveal {
  animation: revealIn 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--reveal-delay, 0ms);
}

@keyframes revealIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.lang-fade { transition: opacity 0.25s ease; }
.lang-fade.is-out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
}

/* ---------- 10. Responsive ------------------------------------------------ */

@media (min-width: 960px) {
  .hero { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 0; }
  .hero-info { max-width: none; padding-right: 24px; align-self: end; }
  .hero-photo { place-items: end start; }
  .photo-img { max-width: none; }
}

/* iPad portrait + tablet: stack, but use circular photo */
@media (max-width: 959px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 8px;
  }
  .hero-photo {
    min-height: auto;
    order: -1;
    padding-top: 16px;
  }
  /* Use circular photo (with gray bg) at tablet + mobile */
  .photo-img { display: none; }
  .photo-img-mobile {
    display: block;
    width: clamp(180px, 28vw, 240px);
    height: clamp(180px, 28vw, 240px);
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 2px solid var(--accent);
    box-shadow: 0 16px 40px -16px rgba(0,0,0,0.45);
    position: relative;
    z-index: 2;
  }
  .photo-glow { display: none; }
  .name-en { justify-content: center; }
  .name-en, .name-zh { text-align: center; }
  .hero-info { margin: 0 auto; align-items: stretch; max-width: 540px; }
  .eyebrow { display: flex; justify-content: center; }
  .eyebrow::before { display: none; }
  .licenses { align-items: center; }
  .licenses li { padding-left: 0; }
  .licenses li::before { display: none; }
  .title-line { text-align: center; }
  .title-sep { display: none; }
  .title-part1, .title-part2 { display: block; text-align: center; }
  .footer-inner { grid-template-columns: 1fr; text-align: center; gap: 24px; }
  .footer-link-row { justify-content: center; }
  .footer-badges { justify-content: center; }
  .bg-corner.tl { display: none; }
}

/* Phone: hamburger menu */
@media (max-width: 639px) {
  .site-header { padding: 16px 18px; }
  .brand-mark { display: none; }
  .brand-mark.hamburger { display: grid; }
  .header-btn span { font-size: 12px; }
  .header-actions { gap: 8px; }
  .header-btn { padding: 9px 12px; font-size: 12px; }
  .hero { padding: 4px 18px 32px; }
  .name-en { font-size: 38px; }
  .name-zh { font-size: 22px; }

  .contact-row {
    grid-template-columns: 22px 1fr;
    gap: 4px 10px;
  }
  .contact-icon { grid-row: 1 / span 2; }
  .contact-label { grid-column: 2; margin-top: 0; font-size: 10.5px; }
  .contact-value { grid-column: 2; font-size: 14px; }
  .copy-btn { opacity: 1; }

  .social { align-items: center; }
  .social-label { display: flex; justify-content: center; gap: 8px; grid-template-columns: unset; }
  .social-label .contact-icon { display: none; }
  .social-row { padding-left: 0; justify-content: center; }

  /* Footer simplifies on phone — links move into hamburger menu */
  .site-footer { padding: 24px 18px; }
  .footer-link-row { display: none; }
  .footer-badges { gap: 14px; }
  .footer-badge img { height: 28px; }
  .footer-disclaimer { font-size: 10.5px; }

  .bg-corner { display: none; }
  .bg-watermark { font-size: 60vw; bottom: -12%; right: -8%; }
}

/* ---------- 11. Keyframes ------------------------------------------------- */

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
