/* ===== Fonts (single source of truth for subsetting to woff2 later) ===== */
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/google-sans-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/google-sans-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/google-sans-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/google-sans-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans SC';
  src: url('assets/fonts/harmony-sc.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ===== Tokens ===== */
:root {
  color-scheme: dark;
  --bg: #0E0F11;
  --surface: #151619;
  --surface-2: #1B1D21;
  --rule: #24262B;
  --rule-2: #353840;
  --ink: #ECE8E1;
  --muted: #A4A098;
  --dim: #7A7771;
  --focus: #ECE8E1;
  --hdr: 56px;
  --pad: clamp(16px, 3vw, 32px);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: "Google Sans", "HarmonyOS Sans SC", system-ui, sans-serif;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--hdr) + 12px);
  scrollbar-color: #363940 var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.lb-open {
  overflow: hidden;
}

body {
  margin: 0;
  padding-top: var(--hdr);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(236, 232, 225, 0.2);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== Top Navigation ===== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--hdr);
  background: rgba(14, 15, 17, 0.88);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1520px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  flex: none;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  padding: 6px 0;
}

.wordmark .dot {
  color: var(--muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.6vw, 26px);
  min-width: 0;
}

.nav-link {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  padding: 6px 0;
  transition: color 160ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--ink);
}

.nav-cross {
  color: var(--dim);
  padding-left: clamp(10px, 2vw, 18px);
  border-left: 1px solid var(--rule);
}

.nav-cross:hover,
.nav-cross:focus-visible {
  color: var(--ink);
}

/* ===== Main Shell ===== */
.shell {
  flex: 1;
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ===== Profile Header ===== */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: clamp(28px, 4vw, 40px) 0 clamp(22px, 3vw, 28px);
}

.avatar {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--rule-2);
  background: var(--surface);
}

.profile-copy {
  min-width: 0;
}

.profile h1 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.name-en {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--dim);
  vertical-align: 2px;
}

.intro {
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--muted);
}

/* ===== Gallery Section ===== */
.gallery-section {
  padding-bottom: clamp(56px, 7vw, 88px);
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.filter-bar {
  display: flex;
  align-items: stretch;
  gap: 24px;
}

.filter-btn {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  transition: color 160ms ease;
}

.filter-btn:hover {
  color: var(--ink);
}

.filter-btn[aria-pressed="true"] {
  color: var(--ink);
}

.filter-btn[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--ink);
}

.filter-en {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.filter-count {
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.gallery-hint {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.empty {
  margin: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

/* Justified Equal-Height-Row Gallery */
.gallery {
  display: flex;
  flex-direction: column;
  gap: var(--gap, 6px);
}

.g-row {
  display: flex;
  gap: var(--gap, 6px);
}

.g-item {
  position: relative;
  display: block;
  flex: none;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface);
  opacity: 0;
  transition: opacity 420ms ease-out;
}

.g-item.in {
  opacity: 1;
}

.g-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.92);
  transition: filter 220ms ease, transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.g-item:hover img,
.g-item:focus-visible img {
  filter: brightness(1.04);
}

.g-cap {
  position: absolute;
  inset: auto 0 0;
  padding: 32px 12px 10px;
  background: linear-gradient(transparent, rgba(8, 9, 10, 0.82));
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.g-item:hover .g-cap,
.g-item:focus-visible .g-cap {
  opacity: 1;
}

.g-item:focus-visible {
  outline-offset: 2px;
  z-index: 2;
}

@media (hover: none) {
  .g-cap {
    display: none;
  }

  .g-item img {
    filter: none;
  }
}

/* ===== Contact Section ===== */
.contact-section {
  padding: clamp(36px, 5vw, 56px) 0 clamp(48px, 6vw, 72px);
  border-top: 1px solid var(--rule);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.section-en {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.section-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.social-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 20px 22px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.social-card:hover,
.social-card:focus-visible {
  border-color: var(--rule-2);
  background: var(--surface-2);
}

.social-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.social-icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.social-icon img {
  display: block;
  filter: invert(0.92) sepia(0.08);
  opacity: 0.92;
}

.social-name {
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.3;
}

.social-detail {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.social-action {
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--dim);
  letter-spacing: 0.02em;
  transition: color 160ms ease;
}

.social-card:hover .social-action,
.social-card:focus-visible .social-action {
  color: var(--ink);
}

.social-btn-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: rgba(236, 232, 225, 0.06);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.mini-btn:hover,
.mini-btn:focus-visible {
  border-color: var(--muted);
  background: rgba(236, 232, 225, 0.12);
}

.mini-btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--rule);
}

.mini-btn--ghost:hover,
.mini-btn--ghost:focus-visible {
  color: var(--ink);
  border-color: var(--rule-2);
  background: rgba(236, 232, 225, 0.05);
}

/* ===== Footer ===== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 20px 0 28px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--dim);
}

.copyright {
  margin: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-links a {
  transition: color 160ms ease;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--ink);
}

/* ===== Full-Screen Lightbox ===== */
.lb {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #08090A;
  animation: fadeIn 180ms ease-out both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lb-stage {
  --pt: 18px;
  --px: 72px;
  --pb: 8px;
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  touch-action: pan-y;
}

.lb-img {
  position: absolute;
  inset: var(--pt) var(--px) var(--pb);
  margin: auto;
  width: auto;
  height: auto;
  max-width: calc(100% - 2 * var(--px));
  max-height: calc(100% - var(--pt) - var(--pb));
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-img.fade {
  animation: fadeIn 200ms ease-out both;
}

.lb-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(236, 232, 225, 0.14);
  border-radius: 50%;
  background: rgba(21, 22, 25, 0.82);
  color: var(--ink);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.lb-btn:hover,
.lb-btn:focus-visible {
  background: #24262B;
  border-color: rgba(236, 232, 225, 0.36);
}

.lb-close {
  top: 14px;
  right: 16px;
}

.lb-nav {
  top: 50%;
  margin-top: -21px;
}

.lb-prev {
  left: 16px;
}

.lb-next {
  right: 16px;
}

.lb-exif {
  flex: none;
  padding: 0 var(--pad) 10px;
  max-height: 34vh;
  overflow: auto;
}

.exif {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
  gap: 10px 36px;
  justify-content: center;
  margin: 0;
  padding: 12px 0 2px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
}

.exif > div {
  min-width: 0;
}

.exif dt {
  margin: 0 0 2px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.exif dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.lb-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px 16px;
  min-height: 54px;
  padding: 6px var(--pad) 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.lb-count {
  margin: 0;
  flex: none;
  min-width: 4.5em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.lb-title {
  margin: 0 auto 0 0;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-noexif {
  flex: none;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.lb-info-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.lb-info-badge {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0;
}

.lb-info-btn:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.lb-info-btn[aria-expanded="true"] {
  color: var(--ink);
  border-color: var(--ink);
  background: rgba(236, 232, 225, 0.1);
}

/* ===== QR Dialog Modal ===== */
.qr-dialog {
  padding: 0;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72);
}

.qr-dialog::backdrop {
  background: rgba(5, 6, 7, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.qr-sheet {
  padding: 18px 20px 20px;
}

.qr-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.qr-sheet-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 500;
}

.qr-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color 160ms ease, border-color 160ms ease;
}

.qr-close:hover,
.qr-close:focus-visible {
  color: var(--ink);
  border-color: var(--muted);
}

.qr-frame {
  padding: 14px;
  background: #FFFFFF;
  border-radius: 3px;
}

.qr-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-handle {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}

.qr-sheet-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.qr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.qr-btn:hover,
.qr-btn:focus-visible {
  border-color: var(--muted);
  background: rgba(236, 232, 225, 0.08);
}

.qr-btn--primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #0E0F11;
}

.qr-btn--primary:hover,
.qr-btn--primary:focus-visible {
  background: #FFFFFF;
  border-color: #FFFFFF;
  color: #0E0F11;
}

.qr-ext-link {
  display: block;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  transition: color 160ms ease;
}

.qr-ext-link:hover,
.qr-ext-link:focus-visible {
  color: var(--ink);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translate(-50%, 14px);
  padding: 10px 18px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: #202227;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .lb-stage {
    --pt: 54px;
    --px: 0px;
    --pb: 6px;
  }

  .lb-close {
    top: 8px;
    right: 10px;
  }

  .lb-nav {
    width: 38px;
    height: 38px;
    margin-top: -19px;
  }

  .lb-prev {
    left: 8px;
  }

  .lb-next {
    right: 8px;
  }

  .lb-exif {
    padding: 0 16px 8px;
    max-height: 40vh;
  }

  .exif {
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    justify-content: stretch;
  }

  .lb-bar {
    padding: 6px 16px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .gallery-hint {
    display: none;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .social-card {
    padding: 18px;
  }
}

@media (max-width: 420px) {
  .nav {
    gap: 12px;
  }

  .nav-link {
    font-size: 13px;
  }

  .nav-cross {
    padding-left: 10px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }

  .g-item {
    opacity: 1;
  }
}
