/* Yim Kin Cheong — portfolio
   Dark glass UI over persistent full-bleed coding video */

:root {
  --bg-deep: #070d18;
  --navy: #0c1a2e;
  --accent: #4aa3e0;
  --accent-2: #58c4aa;
  --text: #f3f6fb;
  --muted: #a8b8cc;
  --glass: rgba(10, 18, 32, 0.55);
  --glass-strong: rgba(8, 14, 26, 0.78);
  --line: rgba(120, 160, 210, 0.22);
  --radius: 18px;
  --nav-h: 72px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ——— Dual persistent video background ——— */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  transform: scale(1.04);
  filter: saturate(0.95) brightness(0.72);
}

.bg__label {
  position: absolute;
  bottom: 3.25rem;
  left: 1rem;
  z-index: 2;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(230, 240, 255, 0.75);
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(120, 160, 210, 0.25);
  opacity: 1;
}

/* Split only: human | robot */
.bg__layer--human {
  inset: 0 50% 0 0;
  z-index: 1;
  opacity: 1;
  border-right: 1px solid rgba(120, 160, 210, 0.35);
}

.bg__layer--robot {
  inset: 0 0 0 50%;
  z-index: 1;
  opacity: 1;
}

.bg__layer--human .bg__video {
  left: 0;
  object-position: 30% 40%;
  width: 100%;
  height: 100%;
  transform: scale(1.02);
}

.bg__layer--robot .bg__video {
  left: 0;
  object-position: 55% 40%;
  width: 100%;
  height: 100%;
  transform: scale(1.02);
  filter: saturate(1.05) brightness(0.7);
}

.bg__layer--robot .bg__label {
  left: auto;
  right: 1rem;
}

.bg__scrim {
  position: absolute;
  inset: 0;
  z-index: 4;
  background:
    linear-gradient(180deg, rgba(6, 12, 22, 0.5) 0%, rgba(6, 12, 22, 0.25) 45%, rgba(6, 12, 22, 0.82) 100%),
    linear-gradient(90deg, rgba(6, 12, 22, 0.45) 0%, rgba(6, 12, 22, 0.15) 50%, rgba(6, 12, 22, 0.45) 100%);
}

.bg__grain {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ——— Nav ——— */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.72), rgba(6, 12, 22, 0.28));
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.nav.is-solid {
  border-bottom-color: var(--line);
  background: rgba(6, 12, 22, 0.82);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1f4e79, #3d8fd4);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.nav__name {
  font-size: 0.95rem;
}

.nav__links {
  display: flex;
  gap: 0.25rem;
}

.nav__links a {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}

.nav__links a:hover,
.nav__links a.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav__links a.nav__cta {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, #2a6fad, #3d9fe0);
  box-shadow: 0 4px 16px rgba(61, 159, 224, 0.3);
}

.nav__links a.nav__cta:hover,
.nav__links a.nav__cta.is-active {
  color: #fff;
  background: linear-gradient(135deg, #3279b8, #4aabe8);
  box-shadow: 0 6px 20px rgba(61, 159, 224, 0.4);
}

.nav__menu {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
}

.nav__menu span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s var(--ease);
}

/* ——— Scroll shell (video stays fixed underneath) ——— */
.shell--scroll {
  position: relative;
  z-index: 1;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem) 4rem;
}

.section {
  position: relative;
  min-height: auto;
  padding: 4.5rem 0 2rem;
  scroll-margin-top: calc(var(--nav-h) + 0.5rem);
}

.section--hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 1rem) 0 5rem;
}

.section--last {
  padding-bottom: 6rem;
}

.panel__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border-radius: calc(var(--radius) + 6px);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.panel__inner--narrow {
  max-width: 720px;
}

/* ——— Scroll-triggered reveals ——— */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.85s var(--ease),
    transform 0.85s var(--ease);
  will-change: opacity, transform;
}

.reveal.is-inview {
  opacity: 1;
  transform: translateY(0);
}

.reveal-child {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.7s var(--ease),
    transform 0.7s var(--ease);
}

.reveal.is-inview .reveal-child {
  opacity: 1;
  transform: translateY(0);
}

.reveal.is-inview .reveal-child:nth-child(1) { transition-delay: 0.05s; }
.reveal.is-inview .reveal-child:nth-child(2) { transition-delay: 0.12s; }
.reveal.is-inview .reveal-child:nth-child(3) { transition-delay: 0.19s; }
.reveal.is-inview .reveal-child:nth-child(4) { transition-delay: 0.26s; }
.reveal.is-inview .reveal-child:nth-child(5) { transition-delay: 0.33s; }
.reveal.is-inview .reveal-child:nth-child(6) { transition-delay: 0.4s; }
.reveal.is-inview .reveal-child:nth-child(7) { transition-delay: 0.47s; }
.reveal.is-inview .reveal-child:nth-child(8) { transition-delay: 0.54s; }

/* Nested grids: stagger cards */
.reveal.is-inview .about-grid > .reveal-child:nth-child(1) { transition-delay: 0.15s; }
.reveal.is-inview .about-grid > .reveal-child:nth-child(2) { transition-delay: 0.28s; }
.reveal.is-inview .project-grid > .reveal-child:nth-child(1) { transition-delay: 0.2s; }
.reveal.is-inview .project-grid > .reveal-child:nth-child(2) { transition-delay: 0.32s; }
.reveal.is-inview .skills-grid > .reveal-child:nth-child(1) { transition-delay: 0.12s; }
.reveal.is-inview .skills-grid > .reveal-child:nth-child(2) { transition-delay: 0.2s; }
.reveal.is-inview .skills-grid > .reveal-child:nth-child(3) { transition-delay: 0.28s; }
.reveal.is-inview .skills-grid > .reveal-child:nth-child(4) { transition-delay: 0.36s; }
.reveal.is-inview .contact-list > .reveal-child:nth-child(1) { transition-delay: 0.15s; }
.reveal.is-inview .contact-list > .reveal-child:nth-child(2) { transition-delay: 0.25s; }
.reveal.is-inview .contact-list > .reveal-child:nth-child(3) { transition-delay: 0.35s; }

.scroll-cue {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
}

.scroll-cue i {
  display: block;
  width: 1px;
  height: 36px;
  background: linear-gradient(180deg, var(--accent), transparent);
  animation: cueBounce 1.8s var(--ease) infinite;
}

@keyframes cueBounce {
  0%,
  100% {
    transform: scaleY(1);
    opacity: 0.9;
  }
  50% {
    transform: scaleY(0.65);
    opacity: 0.4;
  }
}

.section--hero .hero {
  animation: heroFloat 8s ease-in-out infinite alternate;
}

@keyframes heroFloat {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-6px);
  }
}

.hero__tags li {
  transition: transform 0.25s var(--ease), border-color 0.25s, color 0.25s;
}

.hero__tags li:hover {
  transform: translateY(-2px);
  border-color: rgba(126, 200, 245, 0.55);
  color: var(--text);
}

.skill-block,
.project--card,
.contact-item,
.project--featured {
  transition: transform 0.35s var(--ease), border-color 0.35s, box-shadow 0.35s;
}

.skill-block:hover,
.project--card:hover,
.project--featured:hover {
  transform: translateY(-4px);
  border-color: rgba(126, 200, 245, 0.35);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.panel__head {
  margin-bottom: 1.75rem;
}

.panel__head h2 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ——— Hero ——— */
.hero {
  max-width: 820px;
  padding: clamp(2rem, 6vh, 4rem) 0 1rem;
}

.hero h1 {
  margin: 0.6rem 0 1rem;
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.hero h1 .accent {
  background: linear-gradient(105deg, #7ec8f5 0%, #58c4aa 55%, #e8f4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 0 0 1.75rem;
  max-width: 38rem;
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  line-height: 1.65;
  color: var(--muted);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.lede--sm {
  font-size: 1.05rem;
}

.lede strong {
  color: var(--text);
  font-weight: 600;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.35rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: linear-gradient(135deg, #2a6fad, #3d9fe0);
  color: #fff;
  box-shadow: 0 8px 28px rgba(61, 159, 224, 0.35);
}

.btn--primary:hover {
  box-shadow: 0 12px 36px rgba(61, 159, 224, 0.45);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.hero__tags li {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
}

.gate-flow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.gate-flow span {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  background: rgba(160, 180, 200, 0.2);
  color: var(--muted);
}

.gate-flow__mid {
  background: rgba(55, 120, 180, 0.45) !important;
  color: var(--text) !important;
}

.gate-flow__ok {
  background: rgba(88, 196, 170, 0.35) !important;
  color: #c8ffe8 !important;
}

.gate-flow i {
  font-style: normal;
  color: var(--muted);
  opacity: 0.7;
}

/* ——— About ——— */
.about-grid {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 1.75rem;
  align-items: start;
}

.about-card--photo {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--glass-strong);
}

.about-card--photo img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center 20%;
}

.caption {
  margin: 0;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.about-copy p {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.02rem;
}

.about-copy strong {
  color: var(--text);
}

.facts {
  margin: 1.5rem 0 0;
  display: grid;
  gap: 1rem;
}

.facts div {
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.facts dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.facts dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* ——— Work ——— */
.project--featured {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}

.project__media {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 200px;
}

.project__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 220px;
}

.project__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(88, 196, 170, 0.9);
  color: #04120e;
  font-weight: 600;
}

.project__body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.project__meta {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.project__body > p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  line-height: 1.65;
}

.outcomes {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.outcomes strong {
  color: var(--text);
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.project__links a {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--accent);
  transition: background 0.2s;
}

.project__links a:hover {
  background: rgba(74, 163, 224, 0.12);
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.project--card {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.project--card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.project--card p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.stack {
  font-family: var(--mono) !important;
  font-size: 0.75rem !important;
  color: var(--accent) !important;
  margin-bottom: 0 !important;
}

/* ——— Skills ——— */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.skill-block {
  padding: 1.2rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.skill-block h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.skill-block ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-block li {
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(120, 160, 210, 0.1);
  color: var(--muted);
  font-size: 0.95rem;
}

.skill-block li:last-child {
  border-bottom: 0;
}

/* ——— Contact ——— */
.contact-list {
  display: grid;
  gap: 0.65rem;
}

.contact-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.contact-item:hover {
  border-color: rgba(74, 163, 224, 0.45);
  background: rgba(40, 90, 140, 0.15);
  transform: translateX(3px);
}

.contact-item span {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.contact-item strong {
  font-weight: 500;
  font-size: 1.05rem;
}

/* ——— Footer ——— */
.foot {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem clamp(1.25rem, 4vw, 2.5rem) 1.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.foot__hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

/* ——— Mobile ——— */
@media (max-width: 860px) {
  .about-grid,
  .project--featured,
  .project-grid,
  .skills-grid {
    grid-template-columns: 1fr;
  }

  .nav__links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 1rem;
    background: rgba(8, 14, 26, 0.94);
    border-bottom: 1px solid var(--line);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s var(--ease), opacity 0.3s;
  }

  .nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav__menu {
    display: flex;
  }

  .nav__name {
    display: none;
  }

  .section--hero {
    min-height: auto;
    padding-top: calc(var(--nav-h) + 2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-child {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .section--hero .hero,
  .scroll-cue i {
    animation: none !important;
  }

  .bg__video {
    display: none;
  }

  .bg {
    background: url("assets/images/coding-room.jpg") center / cover no-repeat;
  }
}
