/* ============================================================
   Doll Han Han — modern-AI / 3D-cartoon, greyscale single screen
   ============================================================ */

:root {
  --bg-0:   #eef0f2;   /* page backdrop        */
  --bg-1:   #dfe1e4;   /* backdrop edge        */
  --surface:#fbfbfc;   /* cards                */
  --surface-2:#f1f2f4;
  --ink:    #17181b;   /* near-black text      */
  --muted:  #6a6e73;   /* grey text            */
  --line:   rgba(23, 24, 27, 0.12);
  --accent: #2b2d31;   /* mono emphasis / hover */

  --sans:    'Poppins', system-ui, -apple-system, sans-serif;
  --display: 'Poppins', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(62% 58% at 50% 40%, var(--bg-0) 0%, var(--bg-1) 100%);
  /* faint machine-grain */
  background-image:
    radial-gradient(62% 58% at 50% 40%, var(--bg-0) 0%, var(--bg-1) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.28'/%3E%3C/svg%3E");
  background-blend-mode: normal, overlay;
  -webkit-font-smoothing: antialiased;
}

/* ---------- one-screen stage ---------- */
.stage { position: fixed; inset: 0; overflow: hidden; }

/* ---------- centre: the avatar (square card) ---------- */
.doll {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doll__fig {
  position: relative;
  width: clamp(260px, 78vmin, 900px);
  height: clamp(260px, 78vmin, 900px);
  aspect-ratio: 1 / 1;
  will-change: transform;
}
.doll__img {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
  object-position: center 42%;
  border-radius: clamp(22px, 3vw, 44px);
  transform: perspective(900px);          /* JS updates rotateX/rotateY */
  transition: transform 60ms linear;
  box-shadow: 0 34px 60px -24px rgba(23, 24, 27, 0.32);
  -webkit-user-drag: none;
  user-select: none;
}
/* ---------- left column: hero headline (reel-style, no card) ---------- */
.intro {
  position: absolute;
  left: clamp(18px, 4.5vw, 72px);
  bottom: clamp(18px, 6vh, 68px);
  max-width: min(40vw, 520px);
  z-index: 2;
}
.intro__eyebrow {
  margin: 0 0 10px;
  font-size: clamp(0.6rem, 0.85vw, 0.76rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.intro__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.3rem, 6vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.intro__text {
  margin: 14px 0 0;
  max-width: 29ch;
  font-size: clamp(0.8rem, 1.05vw, 0.95rem);
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- bottom-right: dock ---------- */
.dock {
  position: absolute;
  right: clamp(16px, 4vw, 60px);
  bottom: clamp(16px, 4vh, 56px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: clamp(150px, 18vw, 190px);
}
.dock__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 24px -18px rgba(23, 24, 27, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.dock__btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 18px 32px -18px rgba(23, 24, 27, 0.55);
}
.dock__btn:active { transform: translateY(-1px) scale(0.97); }
.dock__btn--primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.dock__btn--primary .dock__ico { color: rgba(255, 255, 255, 0.75); }
.dock__btn--primary:hover {
  background: #000;
  border-color: #000;
  background: var(--accent);
}
.dock__ico {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- top-left teaser ---------- */
.view-all {
  position: absolute;
  left: clamp(16px, 4vw, 60px);
  top: clamp(16px, 4vh, 44px);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.view-all:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-2px); }

/* ---------- top-right: other versions ---------- */
.versions {
  position: absolute;
  right: clamp(16px, 4vw, 60px);
  top: clamp(16px, 4vh, 44px);
  display: flex;
  align-items: center;
  gap: 8px;
}
.versions__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}
.versions__dot {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px -4px rgba(23, 24, 27, 0.4), inset 0 2px 5px rgba(255, 255, 255, 0.45);
  transition: transform 0.18s ease;
}
.versions__dot:hover { transform: scale(1.14); }
.versions__dot--blob { background: radial-gradient(circle at 32% 28%, #fbe4ec, #f4a6c0 55%, #d6577a); }
.versions__dot--claw {
  background:
    #c6a681
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.14' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='discrete' tableValues='0 0 0 1 1 0 0 0 1 0'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.16 0 0 0 0 0.09 0 0 0 0 0.04 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
  background-size: 22px 22px;
}
.versions__dot::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}
.versions__dot:hover::after { opacity: 1; }

/* ---------- modal ---------- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 24, 27, 0.44);
  backdrop-filter: blur(7px);
  animation: fade 0.18s ease;
}
.modal__panel {
  position: relative;
  width: min(60vw, 880px);
  height: min(60vh, 620px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 26px clamp(20px, 3vw, 36px) 30px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 54px 110px -44px rgba(23, 24, 27, 0.75);
  animation: pop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal__x {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}
.modal__x:hover { transform: scale(1.1); background: #e6e7ea; }
.modal__title {
  margin: 0 0 4px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--ink);
}
.modal__body {
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: translateY(10px) scale(0.94); } }

/* ---- modal content: projects ---- */
.plist { display: grid; gap: 14px; }
.pcard {
  display: block;
  padding: 15px 17px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.pcard:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 18px 32px -20px rgba(23, 24, 27, 0.5);
}
.pcard__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pcard__name { font-weight: 700; font-size: 1rem; }
.pcard__go { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pcard:hover .pcard__go { color: var(--ink); }
.pcard__desc { margin: 6px 0 0; font-size: 0.85rem; line-height: 1.45; color: var(--muted); }
.pmore {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.pmore:hover { color: var(--ink); }

/* ---- modal content: contact ---- */
.clist { display: grid; gap: 12px; margin-top: 4px; }
.clink {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.clink:hover { transform: translateY(-2px); border-color: var(--accent); }
.cnote { margin-top: 14px; font-size: 0.82rem; color: var(--muted); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .doll__img { transition: none; }
  .modal__scrim, .modal__panel { animation: none; }
}

/* ============================================================
   MOBILE / SHORT VIEWPORTS — graceful vertical scroll fallback
   ============================================================ */
@media (max-width: 760px), (max-height: 560px) {
  html, body { overflow: auto; height: auto; }
  body { min-height: 100dvh; }

  .stage {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 64px 18px 40px;
    min-height: 100dvh;
  }
  .view-all, .versions { position: static; align-self: center; }
  .versions { order: 5; }
  .doll { position: static; height: auto; display: block; order: 1; }
  .doll__fig { width: min(84vw, 340px); height: auto; margin: 0 auto; }
  .doll__img { transform: none !important; }
  .intro { position: static; max-width: 520px; width: 100%; text-align: center; order: 2; backdrop-filter: none; }
  .dock { position: static; width: 100%; max-width: 420px; order: 3; }
  .dock__btn { justify-content: center; }
  .view-all { order: 4; }
  .modal__panel { width: 90vw; height: auto; max-height: 82vh; }
}
