/* ============================================
   Kevin Zi Jian Yeung, Portfolio v5
   Liquid glass blues, editorial type, glass ring "o"
   ============================================ */

:root {
  --bg-base: #0a1729;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.5);
  --accent: #64b5f6;
  --accent-light: #90caf9;
  --accent-soft: rgba(100, 181, 246, 0.12);
  --accent-line: rgba(100, 181, 246, 0.35);
  --on-accent: #0a1729;
  --line: rgba(255, 255, 255, 0.12);
  --blob-1: rgba(72, 202, 228, 0.21);
  --blob-2: rgba(100, 181, 246, 0.18);
  --blob-3: rgba(144, 224, 239, 0.15);
  --radius-md: 12px;
  --radius-lg: 18px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --pad-x: 48px;
}

[data-theme="light"] {
  --bg-base: #e6f3fc;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(10, 22, 40, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --text-primary: rgba(10, 22, 40, 0.95);
  --text-secondary: rgba(10, 22, 40, 0.72);
  --text-muted: rgba(10, 22, 40, 0.52);
  --accent: #1565c0;
  --accent-light: #1976d2;
  --accent-soft: rgba(21, 101, 192, 0.09);
  --accent-line: rgba(21, 101, 192, 0.3);
  --on-accent: #ffffff;
  --line: rgba(10, 22, 40, 0.12);
  --blob-1: rgba(72, 202, 228, 0.23);
  --blob-2: rgba(100, 181, 246, 0.23);
  --blob-3: rgba(144, 224, 239, 0.21);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

body.menu-open { overflow: hidden; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 300;
  padding: 10px 16px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; text-decoration: none;
  transform: translateY(-200%); transition: transform var(--t);
}
.skip-link:focus { transform: none; }

/* ---------- Background ---------- */

.liquid-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.8; animation: float 20s ease-in-out infinite; }
.blob-1 { width: 500px; height: 500px; background: var(--blob-1); top: -15%; left: -5%; animation-duration: 22s; }
.blob-2 { width: 450px; height: 450px; background: var(--blob-2); top: 40%; right: -10%; animation-duration: 25s; animation-delay: -5s; }
.blob-3 { width: 400px; height: 400px; background: var(--blob-3); bottom: -5%; left: 30%; animation-duration: 20s; animation-delay: -10s; }

.cursor-glow {
  position: fixed; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, var(--blob-2) 0%, rgba(100, 181, 246, 0.08) 50%, transparent 70%);
  filter: blur(40px); opacity: 0.85; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 0; transition: opacity 0.4s ease;
}
.cursor-glow.hidden { opacity: 0; }
[data-theme="light"] .cursor-glow {
  background: radial-gradient(circle, rgba(21, 101, 192, 0.2) 0%, rgba(25, 118, 210, 0.13) 40%, rgba(100, 181, 246, 0.09) 70%, transparent 100%);
  opacity: 0.65;
}
@media (hover: none) { .cursor-glow { display: none; } }

@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(20px, -20px) scale(1.02); } }

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 1px 0 var(--glass-highlight);
}
[data-theme="light"] .glass { box-shadow: 0 8px 32px rgba(10, 22, 40, 0.06), inset 0 1px 0 var(--glass-highlight); }

/* ---------- The signature glass ring "o" ---------- */

.ring-o {
  display: inline-block;
  width: 0.52em;
  height: 0.52em;
  margin: 0 0.035em;
  border-radius: 50%;
  border: 0.075em solid var(--accent);
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.45), var(--accent-soft) 42%, transparent 72%);
  box-shadow: 0 0 0.3em var(--accent-line), inset 0 0 0.16em var(--accent-soft);
  animation: ring-glow 4.5s ease-in-out infinite;
}

@keyframes ring-glow {
  0%, 100% { box-shadow: 0 0 0.22em var(--accent-line), inset 0 0 0.12em var(--accent-soft); }
  50% { box-shadow: 0 0 0.5em var(--accent-line), inset 0 0 0.22em var(--accent-line); }
}

/* ---------- Top navigation ---------- */

.topnav {
  position: fixed; top: 16px; left: 0; right: 0; z-index: 200;
  display: flex; justify-content: center; padding: 0 16px;
  pointer-events: none;
}

.topnav-inner {
  pointer-events: auto;
  display: flex; align-items: center; gap: 4px;
  padding: 7px 7px 7px 20px;
  border-radius: 999px;
  transition: padding var(--t), box-shadow var(--t);
}

.nav-logo {
  font-family: var(--serif); font-size: 1.4rem; line-height: 1;
  color: var(--text-primary); text-decoration: none; margin-right: 14px;
}

.nav-links { display: flex; gap: 2px; }

.nav-links a {
  padding: 8px 14px; border-radius: 999px;
  font-size: 0.86rem; font-weight: 500;
  color: var(--text-secondary); text-decoration: none;
  transition: color var(--t), background-color var(--t);
}
.nav-links a:hover { color: var(--text-primary); }
.nav-links a.active { color: var(--text-primary); background: var(--accent-soft); }

.nav-resume {
  margin-left: 6px; padding: 8px 16px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 0.84rem; font-weight: 600; text-decoration: none;
  transition: transform var(--t), box-shadow var(--t);
}
.nav-resume:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--accent); }

.icon-btn {
  position: relative; width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--text-primary); cursor: pointer;
  transition: background-color var(--t);
}
.icon-btn:hover { background: var(--accent-soft); }

.theme-toggle .theme-icon { position: absolute; display: flex; transition: opacity var(--t), transform 0.5s var(--ease-out); }
.theme-toggle .theme-moon { opacity: 1; }
.theme-toggle .theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
[data-theme="light"] .theme-toggle .theme-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }
[data-theme="light"] .theme-toggle .theme-sun { opacity: 1; transform: none; }

.menu-btn { display: none; }
.menu-btn span { position: absolute; width: 18px; height: 1.5px; border-radius: 2px; background: currentColor; transition: transform 0.4s var(--ease-out); }
.menu-btn span:first-child { transform: translateY(-4px); }
.menu-btn span:last-child { transform: translateY(4px); }
.menu-open .menu-btn span:first-child { transform: rotate(45deg); }
.menu-open .menu-btn span:last-child { transform: rotate(-45deg); }

.menu-overlay {
  position: fixed; inset: 0; z-index: 150;
  display: flex; flex-direction: column; justify-content: center;
  padding: 110px 28px 40px;
  background: var(--bg-base);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.menu-open .menu-overlay { opacity: 1; visibility: visible; }

.menu-link {
  display: block; overflow: hidden;
  font-family: var(--serif); font-size: clamp(2.8rem, 13vw, 4.6rem);
  line-height: 1.08; letter-spacing: -0.02em;
  color: var(--text-primary); text-decoration: none;
}
.menu-link > span { display: inline-block; transform: translateY(105%); transition: transform 0.7s var(--ease-out); transition-delay: var(--d, 0s); }
.menu-open .menu-link > span { transform: none; }

.menu-foot { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 44px; }
.menu-foot a { color: var(--text-secondary); text-decoration: none; font-size: 0.95rem; }

/* ---------- Layout ---------- */

.main-content { padding: 104px var(--pad-x) 80px; }
body { padding-bottom: 96px; }

.section {
  max-width: 1040px;
  margin: 0 auto 170px;
  scroll-margin-top: 110px;
}

.big-heading {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.4rem, 9.5vw, 7.6rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin-bottom: 56px;
}

.mask { display: block; overflow: hidden; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.mask > span { display: inline-block; }

.word { display: inline-block; white-space: nowrap; }
.ch { display: inline-block; }
.js .reveal .ch {
  transform: translateY(115%) rotate(8deg);
  transform-origin: 0 100%;
  transition: transform 0.95s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 38ms);
}
.js .reveal.in-view .ch { transform: none; }

.js .reveal-item { opacity: 0; transform: translateY(22px); transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out); }
.js .reveal-item.in-view { opacity: 1; transform: none; }

.lead {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  max-width: 860px;
  margin-bottom: 40px;
}

.js [data-words] .w { opacity: 0.18; transition: opacity 0.35s ease, color 0.35s ease; }
.js [data-words] .w.lit { opacity: 1; }

.body-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 48px;
  max-width: 900px;
  margin-left: auto;
}

.body-cols p, .body-text {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.8;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  max-width: 1180px;
  margin: 0 auto 170px;
  min-height: calc(100vh - 220px);
  display: flex; flex-direction: column; justify-content: center;
}

.hero-status {
  display: inline-flex; align-items: center; gap: 10px;
  align-self: flex-start;
  padding: 7px 16px 7px 13px; border-radius: 999px;
  font-size: 0.8rem; color: var(--text-secondary);
  margin-bottom: 26px;
  opacity: 0; animation: fadeUp 0.7s var(--ease-out) 0.05s forwards;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 2.2s ease-out infinite; }

.hero-stage { position: relative; }
.hero-name, .portrait { will-change: transform; }

.hero-name {
  position: relative; z-index: 2;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(4.6rem, 15vw, 12.8rem);
  line-height: 0.86; letter-spacing: -0.045em;
}

.name-line { display: block; overflow: hidden; padding-bottom: 0.22em; margin-bottom: -0.15em; }
.name-line > span { display: inline-block; transform: translateY(108%); animation: rise 1.15s var(--ease-out) forwards; animation-delay: var(--d, 0.1s); }
.name-line-2 { padding-left: 13%; }

.hero-ticker {
  position: relative; z-index: 1;
  margin: 14px calc(var(--pad-x) * -1);
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  opacity: 0; animation: fadeIn 1s ease 0.5s forwards;
}

.ticker-track { display: flex; width: max-content; animation: ticker 40s linear infinite; }

.ticker-track span {
  display: inline-flex; align-items: center; gap: 26px;
  padding-right: 26px;
  font-size: 0.98rem; color: var(--text-secondary); white-space: nowrap;
}

.ticker-track span::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}

/* Portrait: natural color, arched frame */
.portrait {
  position: absolute; z-index: 3;
  right: 0; top: -6px;
  width: clamp(220px, 23vw, 290px);
}

.portrait-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 999px 999px 22px 22px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: #0a1729;
  box-shadow: 0 34px 70px -24px rgba(0, 0, 0, 0.6);
  animation: portraitIn 1.3s var(--ease-out) 0.3s both;
}

.portrait-frame img {
  width: 100%; height: 100%; object-fit: cover;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}

.portrait-badge {
  position: absolute; left: -48px; bottom: -40px;
  width: 124px; height: 124px;
  animation: spin 24s linear infinite, fadeIn 1s ease 1s both;
}
.portrait-badge .badge-bg { fill: var(--bg-base); opacity: 0.88; }
.portrait-badge text { font-family: var(--sans); font-size: 9.4px; letter-spacing: 0.04em; fill: var(--text-primary); }
.portrait-badge .badge-ring { fill: none; stroke: var(--accent); stroke-width: 2.4; }

.hero-bottom {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: end;
  margin-top: 44px;
  opacity: 0; animation: fadeUp 0.8s var(--ease-out) 0.75s forwards;
}

.hero-role { font-size: 1.22rem; font-weight: 500; color: var(--accent-light); margin-bottom: 12px; letter-spacing: 0.01em; }
.hero-role [data-decode] { display: inline-block; }
.hero-role .decoding { color: var(--accent); opacity: 0.85; }
.hero-role .sep { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 0 0.8em; vertical-align: middle; }
.hero-subtitle { font-size: 1.02rem; line-height: 1.75; color: var(--text-secondary); max-width: 560px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }

.hero-facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
  margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line);
  opacity: 0; animation: fadeUp 0.8s var(--ease-out) 0.9s forwards;
}
.fact-label { display: block; font-size: 0.74rem; color: var(--text-muted); margin-bottom: 4px; }
.fact-value { font-size: 0.92rem; }

@keyframes rise { to { transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes portraitIn { from { clip-path: inset(100% 0 0 0 round 200px 200px 22px 22px); } to { clip-path: inset(0 0 0 0 round 0); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-line); }
  70% { box-shadow: 0 0 0 9px rgba(100, 181, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(100, 181, 246, 0); }
}

/* ---------- Buttons and links ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 26px; border-radius: 999px; border: 1px solid transparent;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), background-color var(--t), color var(--t), border-color var(--t), translate 0.45s var(--ease-out);
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px -8px var(--accent); }
.btn-ghost { color: var(--text-primary); border-color: var(--line); background: transparent; }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent-line); transform: translateY(-2px); }
.btn[aria-disabled="true"] { background: var(--glass-bg); color: var(--text-muted); border-color: var(--line); cursor: not-allowed; pointer-events: none; box-shadow: none; }

.text-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size 0.35s var(--ease-out), color var(--t);
}
.text-link:hover { background-size: 100% 1px; }

.back-link {
  display: flex; width: fit-content; align-items: center; gap: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 0.88rem;
  margin-bottom: 28px; transition: color var(--t), gap var(--t);
}
.back-link:hover { color: var(--accent); gap: 12px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  font-size: 0.74rem; font-weight: 600; color: var(--accent);
  padding: 4px 11px; border-radius: 999px; background: var(--accent-soft);
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Experience rows ---------- */

.rows { list-style: none; border-top: 1px solid var(--line); }

.row {
  display: grid; grid-template-columns: 190px 1fr; gap: 32px;
  padding: 36px 0; border-bottom: 1px solid var(--line);
  position: relative;
}

.row::before {
  content: ''; position: absolute; left: 0; top: -1px; height: 1px; width: 0;
  background: var(--accent); transition: width 0.7s var(--ease-out);
}
.row:hover::before { width: 100%; }

.row-date { font-size: 0.84rem; color: var(--text-muted); padding-top: 0.5em; font-variant-numeric: tabular-nums; }

.row h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.5rem, 2.6vw, 1.9rem); line-height: 1.15; }
.row-company { color: var(--accent); font-weight: 500; font-size: 0.94rem; margin-top: 4px; }
.row-desc { color: var(--text-secondary); font-size: 0.96rem; line-height: 1.7; margin-top: 6px; }

.points { list-style: none; margin-top: 16px; display: grid; gap: 8px; max-width: 680px; }
.points li { position: relative; padding-left: 20px; font-size: 0.95rem; line-height: 1.65; color: var(--text-secondary); }
.points li::before { content: ''; position: absolute; left: 0; top: 0.8em; width: 8px; height: 1px; background: var(--accent); }

.metrics { display: flex; flex-wrap: wrap; gap: 14px 34px; margin-top: 22px; }
.metric { display: inline-flex; align-items: baseline; gap: 10px; font-size: 0.84rem; color: var(--text-secondary); }
.metric strong { font-family: var(--serif); font-weight: 400; font-size: 2.7rem; line-height: 1; color: var(--accent); letter-spacing: -0.02em; }

.earlier summary {
  list-style: none; display: inline-flex; align-items: center; gap: 10px;
  margin-top: 22px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-secondary);
  font-size: 0.86rem; font-weight: 500; cursor: pointer;
  transition: color var(--t), border-color var(--t);
}
.earlier summary::-webkit-details-marker { display: none; }
.earlier summary:hover { color: var(--accent); border-color: var(--accent-line); }
.earlier .chev { transition: transform 0.35s var(--ease-out); }
.earlier[open] .chev { transform: rotate(180deg); }
.earlier .rows { margin-top: 22px; }
.earlier[open] .rows { animation: fadeUp 0.5s var(--ease-out); }

/* ---------- Toolkit (text only, no cards) ---------- */

.toolkit { border-top: 1px solid var(--line); }

.tk-row {
  display: grid; grid-template-columns: 250px 1fr; gap: 32px;
  padding: 28px 0; border-bottom: 1px solid var(--line);
}

.tk-row dt { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; }

.tk-row dd {
  display: flex; flex-wrap: wrap; align-items: baseline; row-gap: 6px;
  padding-top: 0.45em;
  font-size: 1.02rem; color: var(--text-secondary);
}

.tk-row dd span { transition: color var(--t); }
.tk-row dd span:hover { color: var(--accent); }
.tk-row dd span:not(:last-child)::after { content: '/'; margin: 0 0.75em; color: var(--accent-line); }

/* ---------- Portfolio list with cursor preview ---------- */

.work-list { list-style: none; border-top: 1px solid var(--line); }

.work-row {
  display: grid; grid-template-columns: 70px 1fr auto 34px; align-items: center; gap: 24px;
  padding: 30px 6px; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
  transition: opacity 0.4s ease;
}

.work-list:hover .work-row { opacity: 0.35; }
.work-list .work-row:hover, .work-list .work-row:focus-visible { opacity: 1; }

.work-year { font-size: 0.84rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.work-title {
  font-family: var(--serif); font-size: clamp(2rem, 4.8vw, 3.8rem);
  line-height: 1.02; letter-spacing: -0.025em;
  transition: transform 0.6s var(--ease-out);
}
.work-row:hover .work-title { transform: translateX(16px); }

.work-meta { font-size: 0.86rem; color: var(--text-secondary); text-align: right; }

.work-arrow { color: var(--accent); transition: transform 0.5s var(--ease-out); }
.work-row:hover .work-arrow { transform: rotate(-45deg); }

.work-thumb { display: none; }

.work-preview {
  position: fixed; left: 0; top: 0; z-index: 60;
  width: 290px; aspect-ratio: 3 / 4;
  border-radius: 20px; overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.6);
  pointer-events: none; opacity: 0;
  transition: opacity 0.35s ease;
  will-change: transform;
}
.work-preview.visible { opacity: 1; }
.work-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Ask an AI ---------- */

.ask-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.ask-links svg { color: var(--accent); }

/* ---------- Contact ---------- */

.contact-email {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(2rem, 6.4vw, 5rem);
  line-height: 1.05; letter-spacing: -0.03em;
  color: var(--text-primary); text-decoration: none;
  overflow-wrap: anywhere;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 2px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size 0.6s var(--ease-out), color var(--t);
}
.contact-email:hover { color: var(--accent); background-size: 100% 2px; }

.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin: 18px 0 40px; }

.copy-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent;
  color: var(--text-secondary); font-family: inherit; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: color var(--t), border-color var(--t), background-color var(--t), translate 0.45s var(--ease-out);
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.copy-btn.copied { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.contact-links { display: flex; flex-wrap: wrap; gap: 10px 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.contact-links a {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text-secondary); text-decoration: none; font-size: 0.95rem; font-weight: 500;
  transition: color var(--t);
}
.contact-links a:hover { color: var(--accent); }
.contact-links svg { color: var(--accent); }

/* ---------- Case study pages ---------- */

.case { max-width: 1040px; margin: 0 auto; }

.case-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(3.2rem, 8.5vw, 6.8rem);
  line-height: 0.95; letter-spacing: -0.04em;
  margin: 14px 0 40px;
}

.case-meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px;
  padding: 22px 0; margin-bottom: 52px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.case-meta dt { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 4px; }
.case-meta dd { font-size: 0.94rem; }

.case-hero {
  border-radius: 22px; overflow: hidden; margin-bottom: 72px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
}
.case-hero img { width: 100%; }

.case-block {
  display: grid; grid-template-columns: 250px 1fr; gap: 32px;
  padding: 36px 0; border-top: 1px solid var(--line);
}
.case-block h2 { font-family: var(--serif); font-weight: 400; font-size: 1.8rem; line-height: 1.15; }
.case-block p { color: var(--text-secondary); font-size: 1.02rem; line-height: 1.8; max-width: 640px; }
.case-block p + p { margin-top: 16px; }

.case-next {
  display: block; margin-top: 90px; padding-top: 34px;
  border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.case-next small { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 8px; }
.case-next span {
  display: inline-flex; align-items: center; gap: 18px;
  font-family: var(--serif); font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 1; letter-spacing: -0.03em;
  transition: transform 0.6s var(--ease-out), color var(--t);
}
.case-next:hover span { transform: translateX(14px); color: var(--accent); }

/* ---------- Creative gallery and viewer ---------- */

.sub-heading { font-family: var(--serif); font-size: 1.8rem; font-weight: 400; margin: 8px 0 22px; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 72px; }
.gallery-wide { grid-column: 1 / -1; }
.gallery-item figcaption { margin-top: 10px; font-size: 0.84rem; color: var(--text-muted); }

.gallery-open {
  display: block; width: 100%; padding: 0; aspect-ratio: 3 / 2;
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--glass-bg); cursor: zoom-in;
}
.gallery-open img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.9s var(--ease-out); }
.gallery-open:hover img { transform: scale(1.04); }

.lightbox { border: 0; padding: 0; background: transparent; max-width: min(1200px, 94vw); max-height: 92vh; margin: auto; overflow: visible; }
.lightbox::backdrop { background: rgba(5, 12, 22, 0.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lightbox[open] { animation: lightboxIn 0.45s var(--ease-out); }
.lightbox img { max-width: 100%; max-height: 84vh; border-radius: var(--radius-md); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.lightbox figcaption { margin-top: 12px; text-align: center; font-size: 0.88rem; color: rgba(255, 255, 255, 0.75); }
.lightbox-close {
  position: absolute; top: -52px; right: 0; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
@keyframes lightboxIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

/* ---------- Shop ---------- */

.product {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 44px;
  padding: 28px; border-radius: var(--radius-lg); margin-bottom: 28px;
}

.product-cover {
  position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius-md); padding: 26px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff; overflow: hidden;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(144, 224, 239, 0.55), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgba(100, 181, 246, 0.6), transparent 60%),
    linear-gradient(160deg, #1565c0 0%, #0d2d57 100%);
  box-shadow: 0 24px 48px -20px rgba(10, 23, 41, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.6s var(--ease-out);
}
.product:hover .product-cover { transform: rotate(-1.5deg) translateY(-4px); }
.cover-top { font-size: 0.74rem; letter-spacing: 0.04em; opacity: 0.8; }
.cover-number { font-family: var(--serif); font-size: clamp(5rem, 11vw, 7.5rem); line-height: 0.85; letter-spacing: -0.04em; }
.cover-title { font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; margin-top: 8px; }
.cover-author { font-size: 0.78rem; opacity: 0.8; }

.product-details { display: flex; flex-direction: column; justify-content: center; }
.product-details h2 { font-family: var(--serif); font-size: clamp(1.8rem, 3vw, 2.2rem); font-weight: 400; line-height: 1.1; margin: 12px 0; }
.product-details > p { color: var(--text-secondary); font-size: 0.96rem; line-height: 1.7; margin-bottom: 22px; }
.product-includes { list-style: none; display: grid; gap: 10px; margin-bottom: 28px; }
.product-includes li { display: flex; align-items: flex-start; gap: 10px; font-size: 0.92rem; color: var(--text-secondary); }
.product-includes svg { flex-shrink: 0; margin-top: 3px; color: var(--accent); }
.buy-row { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; padding-top: 22px; border-top: 1px solid var(--line); }
.product-price { font-family: var(--serif); font-size: 2.4rem; line-height: 1; }
.buy-row .btn { flex: 1; min-width: 180px; }
.product-details .fine-print { margin-top: 14px; font-size: 0.8rem; color: var(--text-muted); }

.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px 0; font-family: var(--serif); font-size: 1.4rem; cursor: pointer; transition: color var(--t);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent); }
.faq .plus { position: relative; width: 14px; height: 14px; flex-shrink: 0; }
.faq .plus::before, .faq .plus::after { content: ''; position: absolute; top: 50%; left: 0; width: 14px; height: 1.5px; background: currentColor; transition: transform 0.35s var(--ease-out); }
.faq .plus::after { transform: rotate(90deg); }
.faq details[open] .plus::after { transform: rotate(0); }
.faq details p { padding-bottom: 22px; color: var(--text-secondary); font-size: 0.96rem; line-height: 1.7; max-width: 620px; }
.faq details[open] p { animation: fadeUp 0.4s var(--ease-out); }
.faq a { color: var(--accent); }

/* ---------- Footer ---------- */

.footer {
  max-width: 1040px; margin: 0 auto; padding: 28px var(--pad-x) 40px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.footer p { font-size: 0.84rem; color: var(--text-muted); }
.to-top { display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--text-muted); text-decoration: none; transition: color var(--t); }
.to-top:hover { color: var(--accent); }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .nav-links, .nav-resume { display: none; }
  .menu-btn { display: flex; }
  .topnav-inner { width: 100%; justify-content: space-between; padding-left: 20px; }
  .nav-logo { margin-right: auto; }

  .hero-bottom { grid-template-columns: 1fr; gap: 26px; }
  .hero-cta { justify-content: flex-start; }
  .body-cols { grid-template-columns: 1fr; margin-left: 0; }
  .product { grid-template-columns: 1fr; gap: 28px; }
  .product-cover { aspect-ratio: 16 / 11; }
}

@media (max-width: 768px) {
  :root { --pad-x: 22px; }
  .main-content { padding-top: 110px; }
  .section { margin-bottom: 120px; }
  .big-heading { margin-bottom: 36px; }

  .hero { min-height: auto; margin-bottom: 120px; }
  .portrait { position: relative; right: auto; top: auto; width: 48vw; max-width: 210px; margin: 6px 0 44px 30px; }
  .portrait-badge { width: 96px; height: 96px; left: -34px; bottom: -30px; }
  .name-line-2 { padding-left: 9%; }

  .row, .tk-row, .case-block { grid-template-columns: 1fr; gap: 10px; }
  .row { padding: 28px 0; }
  .row-date { padding-top: 0; }

  .work-row { grid-template-columns: 1fr auto; gap: 10px 16px; padding: 26px 0; }
  .work-thumb { display: block; grid-column: 1 / -1; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; margin-bottom: 8px; border: 1px solid var(--glass-border); }
  .work-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .work-year { grid-column: 1; }
  .work-title { grid-column: 1 / -1; }
  .work-meta { grid-column: 1; text-align: left; }
  .work-arrow { grid-column: 2; grid-row: 2; }
  .work-list:hover .work-row { opacity: 1; }

  .case-meta { grid-template-columns: repeat(2, 1fr); }
  .product { padding: 18px; }
}

@media (max-width: 600px) {
  .hero-facts { grid-template-columns: 1fr; gap: 14px; }
  .hero-cta { flex-direction: column; }
  .hero-cta .btn { width: 100%; }
  .gallery { grid-template-columns: 1fr; }
  .product-cover { aspect-ratio: 4 / 3; padding: 22px; }
}

@media (hover: none) { .work-preview { display: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .ticker-track, .blob, .portrait-badge { animation: none !important; }
  .portrait-badge { opacity: 1; }
}

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

/* ---------- Scroll animations ---------- */

/* Ring "o" pops in after its heading lands */
.js .reveal .ring-o { transform: scale(0); }
.js .reveal.in-view .ring-o {
  animation: ringPop 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) 0.55s both, ring-glow 4.5s ease-in-out 1.4s infinite;
}
@keyframes ringPop { from { transform: scale(0); } to { transform: scale(1); } }

/* Divider lines draw themselves, then the row content rises */
.row.draw, .tk-row.draw { border-bottom-color: transparent; }
.draw::after {
  content: ''; position: absolute; left: 0; bottom: -1px; width: 100%; height: 1px;
  background: var(--line);
  transform-origin: left; transform: scaleX(1);
}
.tk-row { position: relative; }
.js .draw.reveal-item { opacity: 1; transform: none; }
.js .draw::after { transform: scaleX(0); transition: transform 1.2s var(--ease-out); }
.js .draw.in-view::after { transform: scaleX(1); }
.js .row.draw > *, .js .tk-row.draw dt {
  opacity: 0; transform: translateY(18px);
  transition: opacity 0.8s var(--ease-out) 0.25s, transform 0.8s var(--ease-out) 0.25s;
}
.js .row.draw.in-view > *, .js .tk-row.draw.in-view dt { opacity: 1; transform: none; }

/* Toolkit items appear one after another */
.js .tk-row.draw dd span {
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.45s ease, transform 0.45s var(--ease-out), color var(--t);
  transition-delay: calc(0.35s + var(--i, 0) * 0.07s), calc(0.35s + var(--i, 0) * 0.07s), 0s;
}
.js .tk-row.draw.in-view dd span { opacity: 1; transform: none; }

/* Portfolio titles rise out of a mask */
.work-title { display: block; overflow: hidden; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.work-title > span { display: inline-block; }
.js .work-row.reveal-item { opacity: 1; transform: none; transition: opacity 0.4s ease; }
.js .work-row .work-title > span { transform: translateY(110%); transition: transform 1s var(--ease-out); }
.js .work-row.in-view .work-title > span { transform: none; }
.js .work-row .work-year, .js .work-row .work-meta, .js .work-row .work-arrow { opacity: 0; transition: opacity 0.8s ease 0.35s, transform 0.5s var(--ease-out); }
.js .work-row.in-view .work-year, .js .work-row.in-view .work-meta, .js .work-row.in-view .work-arrow { opacity: 1; }
.work-list:hover .work-row { opacity: 0.35; }
.work-list .work-row:hover, .work-list .work-row:focus-visible { opacity: 1; }
@media (max-width: 768px) { .work-list:hover .work-row { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .js [data-words] .w { opacity: 1; }
  .js .reveal .ring-o { transform: none; }
}

/* ============================================
   KY logo, corner mark and dock
   ============================================ */

.ky { display: block; width: 100%; height: 100%; overflow: visible; fill: currentColor; stroke: currentColor; stroke-width: 5; stroke-linejoin: round; }

.corner-logo {
  position: fixed; top: 20px; left: 24px; z-index: 200;
  width: 48px; height: 48px; color: var(--text-primary);
  transition: opacity 0.6s ease, transform 0.5s var(--ease-out);
}
.corner-logo:hover { transform: rotate(-8deg) scale(1.06); }

.badge-ky { fill: var(--accent); stroke: var(--accent); stroke-width: 6; stroke-linejoin: round; }

.dock-wrap {
  position: fixed; left: 0; right: 0; bottom: 18px; z-index: 200;
  display: flex; justify-content: center; padding: 0 10px;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.dock {
  --base: 46px;
  pointer-events: auto;
  display: flex; align-items: flex-end; gap: 6px;
  height: calc(var(--base) + 16px);
  padding: 8px 10px; border-radius: 24px;
}

.dock-item {
  --s: 1;
  position: relative; flex-shrink: 0;
  width: calc(var(--base) * var(--s)); height: calc(var(--base) * var(--s));
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 14px; background: transparent;
  color: var(--text-secondary); text-decoration: none; cursor: pointer;
  transition: width 0.2s var(--ease-out), height 0.2s var(--ease-out), color var(--t), background-color var(--t);
}
.dock-item .icon { width: calc(21px * var(--s)); height: calc(21px * var(--s)); transition: width 0.2s var(--ease-out), height 0.2s var(--ease-out); }
.dock-item:hover, .dock-item:focus-visible { color: var(--text-primary); background: var(--accent-soft); }
.dock-item.active { color: var(--text-primary); }
.dock-item.active::after {
  content: ''; position: absolute; bottom: -6px; left: 50%;
  width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent);
}

.dock-label {
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translate(-50%, 6px);
  padding: 5px 10px; border-radius: 8px;
  background: var(--text-primary); color: var(--bg-base);
  font-size: 0.74rem; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.dock-item:hover .dock-label, .dock-item:focus-visible .dock-label { opacity: 1; transform: translate(-50%, 0); }

.dock-sep { width: 1px; height: 28px; align-self: center; background: var(--line); margin: 0 4px; }

.dock .theme-toggle .theme-icon { position: absolute; display: flex; }

.dock-logo { color: var(--text-primary); }
.dock-logo .ky { width: 64%; height: 64%; }
.dock-progress { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); transform: rotate(-90deg); overflow: visible; }
.dock-progress circle { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.dock-progress .track { stroke: var(--line); }
.dock-progress .bar { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; }

/* ============================================
   Opening animation
   ============================================ */

html.intro .hero, html.intro .hero * { animation-play-state: paused !important; }
html.intro .corner-logo, html.intro .dock-wrap { opacity: 0; }

.intro-screen {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base); color: var(--text-primary);
  transition: opacity 0.65s ease;
  cursor: pointer;
}
.intro-screen svg { width: 150px; height: 150px; overflow: visible; transition: transform 0.85s cubic-bezier(0.7, 0, 0.2, 1); }
.intro-screen .intro-ring { fill: none; stroke: currentColor; stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw 1.1s ease 0.15s forwards; }
.intro-screen .ky-draw { fill: transparent; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw 1.35s cubic-bezier(0.6, 0, 0.3, 1) forwards, fillIn 0.5s ease 1.15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fillIn { to { fill: currentColor; stroke-width: 5; } }

/* ============================================
   Page transitions
   ============================================ */

:root { --cover-logo: url("assets/ky-logo-light.svg"); }
[data-theme="light"] { --cover-logo: url("assets/ky-logo.svg"); }

html::after {
  content: ''; position: fixed; inset: 0; z-index: 1000;
  background: var(--bg-base) var(--cover-logo) center / 92px no-repeat;
  transform: translateY(100%);
  pointer-events: none;
}
html.pt-leave::after { transform: none; transition: transform 0.55s cubic-bezier(0.7, 0, 0.3, 1); }
html.pt-enter::after { transform: none; transition: none; }
html.pt-exit::after { transform: translateY(-100%); transition: transform 0.7s cubic-bezier(0.7, 0, 0.3, 1); }

/* ============================================
   Background that shifts with each section
   ============================================ */

.blob { transition: translate 2.6s var(--ease-out), background-color 2.6s ease, scale 2.6s var(--ease-out); }
[data-zone="about"] .blob-1 { translate: 55vw 25vh; background-color: rgba(129, 140, 248, 0.16); }
[data-zone="about"] .blob-2 { translate: -60vw -10vh; }
[data-zone="work"] .blob-1 { translate: 10vw 55vh; }
[data-zone="work"] .blob-2 { translate: -20vw -35vh; background-color: rgba(45, 212, 191, 0.13); }
[data-zone="work"] .blob-3 { translate: 35vw -30vh; }
[data-zone="portfolio"] .blob-1 { translate: 60vw 5vh; scale: 1.2; background-color: rgba(100, 181, 246, 0.22); }
[data-zone="portfolio"] .blob-3 { translate: -30vw -40vh; background-color: rgba(129, 140, 248, 0.15); }
[data-zone="toolkit"] .blob-2 { translate: -55vw 15vh; background-color: rgba(72, 202, 228, 0.2); }
[data-zone="toolkit"] .blob-3 { translate: 40vw -50vh; }
[data-zone="ask"] .blob-1 { translate: 35vw 40vh; background-color: rgba(129, 140, 248, 0.2); }
[data-zone="ask"] .blob-2 { translate: -30vw 5vh; }
[data-zone="contact"] .blob-1 { translate: 20vw 50vh; scale: 1.25; }
[data-zone="contact"] .blob-2 { translate: -45vw -30vh; background-color: rgba(45, 212, 191, 0.14); }

/* ============================================
   Phones and reduced motion for the new pieces
   ============================================ */

@media (max-width: 600px) {
  .dock { --base: 36px; gap: 2px; padding: 7px 8px; border-radius: 20px; }
  .dock-home { display: none; }
  .dock-item { border-radius: 11px; }
  .dock-item .icon { width: calc(18px * var(--s)); height: calc(18px * var(--s)); }
  .dock-sep { margin: 0 2px; height: 22px; }
  .corner-logo { top: 16px; left: 18px; width: 40px; height: 40px; }
}
@media (hover: none) {
  .dock-label { display: none; }
  .dock-item:active { transform: scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal .ch { transform: none; }
  .blob { transition: none; }
  html::after { display: none; }
}
