/* William Chong - consulting credibility site
   SDG-inspired: dark canvas, large type, engineering-first tone */

:root {
  --bg: #0a0a0b;
  --bg-elevated: #111114;
  --surface: #16161a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --dim: #71717a;
  --accent: #c8ff00;
  --accent-dim: rgba(200, 255, 0, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Syne", var(--font-sans);
  --font-heading: "Outfit", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 72px;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal,
  .hero__bg {
    animation: none !important;
    -webkit-animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 150;
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--accent), rgba(200, 255, 0, 0.5));
  will-change: transform;
}

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

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

a:hover {
  color: var(--accent);
}

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

.wrap {
  width: min(1120px, 100% - 48px);
  margin-inline: auto;
}

/* Header */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent;
  overflow: visible;
  transition: background 0.35s var(--ease-out), border-color 0.35s var(--ease-out),
    backdrop-filter 0.35s var(--ease-out);
}

.site-header.is-scrolled {
  background: rgba(10, 10, 11, 0.82);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.012em;
  line-height: 1.35;
  padding-block: 0.15em;
}

.logo span {
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(820px, 100%);
}

.nav a {
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}

@media (min-width: 900px) {
  .nav a {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
}

.nav a:hover,
.nav a[aria-current="page"],
.nav a.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav a.is-active {
  box-shadow: inset 0 0 0 1px rgba(200, 255, 0, 0.35);
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

@media (max-width: 820px) {
  .nav-toggle {
    display: block;
  }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    padding: 16px 24px 20px;
    background: rgba(10, 10, 11, 0.96);
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s var(--ease-out), opacity 0.3s;
  }
  .nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav a {
    border-radius: var(--radius-sm);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), background 0.2s, border-color 0.2s,
    color 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: #0a0a0b;
  border-color: var(--accent);
}

.btn--primary:hover {
  filter: brightness(1.05);
  color: #0a0a0b;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

/* Hero */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding-top: calc(var(--header-h) + 32px);
  padding-bottom: 64px;
  /* Text must not be clipped; glow is clipped inside .hero__bg-wrap only */
  overflow: visible;
  scroll-margin-top: 0;
}

.hero__bg-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero__bg {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 70%;
  background: radial-gradient(
      ellipse 80% 60% at 50% -10%,
      rgba(200, 255, 0, 0.14),
      transparent 55%
    ),
    radial-gradient(ellipse 50% 40% at 100% 20%, rgba(255, 255, 255, 0.06), transparent);
  pointer-events: none;
  animation: heroGlow 14s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes heroGlow {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  overflow: visible;
  min-height: min-content;
  padding-bottom: 0.35rem;
}

.hero__layout {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hero__eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}

/* Portrait out of flow on desktop so the row is not stretched to image height (removes the big gap). */
.hero__main {
  position: relative;
}

@media (min-width: 861px) {
  .hero__lead,
  .hero__rest {
    padding-right: clamp(200px, 32vw, 300px);
    max-width: 100%;
  }

  .hero__portrait {
    position: absolute;
    top: 0;
    right: 0;
    width: min(280px, 30vw);
    max-width: 280px;
    margin: 0;
    z-index: 1;
  }
}

.hero__lead .hero__roles {
  margin-bottom: 0;
}

.hero__portrait {
  margin: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.38);
}

.hero__portrait img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: center 12%;
  aspect-ratio: 4 / 5;
  vertical-align: middle;
}

.hero__rest {
  margin-top: 1.15rem;
}

.hero__rest .hero__value {
  margin-top: 0;
}

@media (max-width: 860px) {
  .hero__lead,
  .hero__rest {
    padding-right: 0;
  }

  .hero__portrait {
    position: static;
    width: 100%;
    max-width: min(280px, 76vw);
    margin-inline: auto;
  }

  .hero__main {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
  }

  .hero__rest {
    margin-top: 0;
  }
}

.hero h1 {
  font-weight: 800;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  /* Generous line box for descenders (g, y, etc.) */
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  padding-block: 0.08em 0.22em;
  overflow: visible;
}

.hero__roles {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--muted);
  letter-spacing: -0.006em;
  line-height: 1.45;
  margin: 0 0 28px;
  max-width: 52ch;
  padding-block: 0.06em 0.18em;
  overflow: visible;
}

.hero__value {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.55;
  color: var(--text);
  max-width: 56ch;
  margin: 0;
  padding-block: 0.04em 0.12em;
  overflow: visible;
}

.hero__bio {
  margin: 22px 0 0;
  max-width: 62ch;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--muted);
  padding-block: 0.04em 0.1em;
  overflow: visible;
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scroll-hint__line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: scrollPulse 2.2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scaleY(0.6);
    transform-origin: top;
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
  }
}

/* Sections */
section {
  padding: 96px 0;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

/* Resume (and similar) uses nested <section>s for semantics only - do not apply page section padding */
.prose > section {
  padding-block: 0;
  scroll-margin-top: 0;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .view-tilt {
      animation: viewTilt linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 35%;
    }
  }
}

@keyframes viewTilt {
  from {
    opacity: 0.65;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.section-title {
  font-weight: 800;
  font-size: clamp(1.85rem, 3.5vw, 2.75rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 20px;
  max-width: 20ch;
}

.section-lede {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 62ch;
  margin: 0 0 40px;
}

/* Credibility strip */
.credibility {
  padding: 56px 0 72px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.cred-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 48px;
}

@media (max-width: 720px) {
  .cred-stats {
    grid-template-columns: 1fr;
  }
}

.stat {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 8px;
}

.stat__label {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.brands-marquee {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
  mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
}

/* JS rAF marquee: drop mask so WebKit composites transforms reliably (incl. iOS pointer:fine) */
.brands-marquee.brands-marquee--js-fallback {
  -webkit-mask-image: none;
  mask-image: none;
}

/* iOS Safari: mask + animated transform often fails to composite — drop mask on touch hardware */
@media (pointer: coarse) {
  .brands-marquee {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

/* Opacity-only reveal: parent transform breaks child translateX marquee on many mobile WebKits */
.brands-marquee.reveal {
  transform: none;
  transition: opacity 0.8s var(--ease-out);
}

.brands-marquee.reveal.is-visible {
  transform: none;
}

.marquee-track {
  display: flex;
  gap: 48px;
  width: max-content;
  animation: marquee 36s linear infinite;
  -webkit-animation: marquee 36s linear infinite;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* JS-driven marquee (see main.js) — disable CSS keyframes to avoid double motion */
.marquee-track.marquee-track--js-fallback {
  animation: none !important;
  -webkit-animation: none !important;
  will-change: transform;
}

@media (max-width: 640px) {
  .marquee-track {
    gap: 36px;
    animation-duration: 28s;
    -webkit-animation-duration: 28s;
  }
}

/* Manual swipe only when JS marquee is unavailable (no --js-fallback class).
   If we used transform:none !important on .marquee-track here, it would override
   the JS-driven translate3d() even with inline styles. */
@media (prefers-reduced-motion: reduce) {
  .brands-marquee:not(.brands-marquee--js-fallback) {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    mask-image: none;
    -webkit-mask-image: none;
    touch-action: pan-x;
  }

  .brands-marquee:not(.brands-marquee--js-fallback) .marquee-track {
    animation: none !important;
    -webkit-animation: none !important;
    will-change: auto;
    flex-wrap: nowrap;
    width: max-content;
    justify-content: flex-start;
    transform: none !important;
  }
}

@keyframes marquee {
  from {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
  to {
    -webkit-transform: translate3d(-50%, 0, 0);
    transform: translate3d(-50%, 0, 0);
  }
}

.brand-pill {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s;
}

.brand-pill:hover {
  color: var(--text);
}

/* Services grid */
.services-grid {
  display: grid;
  gap: 20px;
}

@media (min-width: 680px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.service-card {
  padding: 28px 28px 32px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.3s, transform 0.35s var(--ease-out), box-shadow 0.35s;
}

.service-card:hover {
  border-color: rgba(200, 255, 0, 0.25);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  transform: translateY(-4px);
}

.service-card h3 {
  font-weight: 700;
  font-size: 1.2rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.service-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.services-cta {
  margin-top: 36px;
}

/* Impact list */
.impact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.impact-list li {
  position: relative;
  padding-left: 28px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.impact-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(200, 255, 0, 0.45);
}

.impact-note {
  margin-top: 28px;
  padding: 20px 22px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(200, 255, 0, 0.2);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

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

/* Clients block */
.clients-block {
  background: var(--bg-elevated);
  border-block: 1px solid var(--border);
}

.resume-section {
  background: var(--bg-elevated);
  border-block: 1px solid var(--border);
}

.clients-block .section-title {
  max-width: none;
}

.client-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.client-tags span {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
}

/* Experience */
.exp-highlights {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.exp-item {
  display: grid;
  gap: 6px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface), transparent);
}

.exp-item strong {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.exp-item span {
  color: var(--muted);
  font-size: 0.95rem;
}

.resume-cta-row {
  margin-top: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* Contact */
.contact-section {
  padding-bottom: 120px;
}

.contact-grid {
  display: grid;
  gap: 32px;
}

@media (min-width: 800px) {
  .contact-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.contact-links a {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.contact-links p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 16px 0 0;
}

.contact-form {
  position: relative;
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.contact-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}

.contact-form button[type="submit"] {
  width: 100%;
}

.form-note {
  font-size: 0.85rem;
  color: var(--dim);
  margin-top: 14px;
}

.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Footer */
.site-footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 0.88rem;
}

.site-footer .wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.site-footer__top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.site-footer__note {
  margin: 0;
  padding-top: 4px;
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.03em;
  color: rgba(113, 113, 122, 0.72);
  text-align: center;
}

.footer-nav {
  display: flex;
  gap: 20px;
}

.footer-nav a:hover {
  color: var(--text);
}

/* Inner pages */
.page-hero {
  padding: calc(var(--header-h) + 80px) 0 56px;
}

.page-hero h1 {
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}

.page-hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 60ch;
  margin: 0;
}

.prose {
  max-width: 720px;
}

.prose h2 {
  font-size: 1.5rem;
  margin: 1.75rem 0 0.65rem;
  letter-spacing: -0.02em;
}

.resume-prose > .resume-header + section > h2 {
  margin-top: 0;
}

.prose h3 {
  font-size: 1.1rem;
  margin: 28px 0 10px;
  color: var(--text);
}

.prose p,
.prose li {
  color: var(--muted);
}

.prose ul {
  padding-left: 1.2rem;
}

.prose li {
  margin-bottom: 8px;
}

.resume-header {
  margin-bottom: 2rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.section-title--resume-name {
  max-width: none;
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  letter-spacing: -0.025em;
  margin-bottom: 14px;
}

.resume-lede {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
}

.resume-meta {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.resume-meta a {
  color: var(--accent);
}

.service-detail {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
}

.service-detail:last-of-type {
  border-bottom: none;
}

.service-detail h2 {
  font-size: 1.45rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.service-detail p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  max-width: 70ch;
}

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

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

.reveal-delay-1 {
  transition-delay: 0.08s;
}
.reveal-delay-2 {
  transition-delay: 0.16s;
}
.reveal-delay-3 {
  transition-delay: 0.24s;
}
