/* ==========================================================================
   Steven Chang — Portfolio (folio02)
   Base styles + home page. Breakpoints follow the Figma frames:
   1920 / 1280 (Desktop) / 800 (Tablet) / 375 (Mobile)
   ========================================================================== */

:root {
  --bg: #fcfdff;
  --ink: #242424;
  --gray-body: #666666;
  --gray-label: #636363;
  --gray-desc: #5a5a5a;
  --gray-sub: #636567;
  --card: #f8f9fa;
  --pill: #f2f2f2;
  --pill-border: #ececec;
  --cover: #f0f4f9;
  --footer-muted: #a3adb7;
  --footer-link: #5b5b5b;
  --font-stack: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "SF Pro", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

/* --------------------------------------------------------------------------
   Desktop topbar (.cs-topbar) — Figma 453:21458 / 453:21476 / 453:21492
   Shared by home, Work case studies, and Audio Identity.
   Playground scopes its own bar via .page-playground .cs-topbar.
   ≤799: hidden here; mobile uses shared .menu-v2 below.
   -------------------------------------------------------------------------- */

.cs-topbar {
  display: none;
}

.cs-topbar__about-narrow { display: none; }

@media (min-width: 800px) {
  .cs-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 62px;
    z-index: 100;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    /* 800–1365 → 453:21492 */
    padding: 0 64px;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(80px);
    backdrop-filter: blur(80px);
  }

  .cs-topbar__nav {
    display: flex;
    align-items: center;
    gap: 56px;
  }

  .cs-topbar__nav a {
    font-family: var(--font-stack);
    font-size: 17px;
    line-height: 1.4;
    font-weight: 400;
    color: #666;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
  }

  .cs-topbar__nav a:hover { color: #000; }

  .cs-topbar__nav a.is-active {
    color: #000;
    font-weight: 500;
  }

  /* 800 frame: CV label (27px slot); 1366+ uses About */
  .cs-topbar__about-wide { display: none; }
  .cs-topbar__about-narrow { display: inline; }
}

@media (min-width: 1366px) {
  .cs-topbar {
    /* 1366–1919 → 453:21476 (pad 88, bg still 0.1) */
    padding: 0 88px;
  }

  .cs-topbar__about-wide { display: inline; }
  .cs-topbar__about-narrow { display: none; }
}

@media (min-width: 1920px) {
  .cs-topbar {
    /* ≥1920 → 453:21458 */
    padding: 0 88px;
    background: rgba(255, 255, 255, 0.2);
  }
}

/* --------------------------------------------------------------------------
   Pill navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: absolute;
  top: 32px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 10;
}

.pill-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.pill-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 100px;
  font-size: 16px;
  letter-spacing: -0.03em;
  line-height: 0.9;
  color: #000;
  white-space: nowrap;
  transition: background 0.2s ease;
}

.pill-nav__link:hover { background: var(--pill); }

/* --------------------------------------------------------------------------
   Scroll-in motion (subtle fade + rise)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .anim {
    opacity: 0;
    transition:
      opacity 0.75s cubic-bezier(0.2, 0.6, 0.2, 1),
      transform 0.75s cubic-bezier(0.2, 0.6, 0.2, 1);
    transition-delay: var(--anim-delay, 0s);
    will-change: opacity, transform;
  }

  /* Rise only for content — fade-only chrome (e.g. .menu-v2) must keep its
     own positioning transforms; never set transform: none on those. */
  .anim:not(.anim--fade) {
    transform: translateY(16px);
  }

  .anim-in {
    opacity: 1;
  }

  .anim.anim-in:not(.anim--fade) {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Home — hero
   -------------------------------------------------------------------------- */

.hero {
  padding: 240px 0 200px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 100%);
}

.hero__inner {
  max-width: 1274px;
  margin: 0 auto;
}

/* Horizontal layout is owned by index.html breakpoint CSS (Figma 437:10094 /
   437:13159: max 1500 content + 320px inline padding). Keep only type tokens here. */
.hero__text {
  max-width: 100%;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.hero__text p + p { margin-top: 27.5px; }

/* Match footer social links: underline only on hover */
.hero__text a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Home — project cards
   -------------------------------------------------------------------------- */

.projects {
  max-width: 1280px;
  margin: 0 auto;
  padding: 70px 120px 220px;
}

.projects__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 77px;
}

.project-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
}

.project-card__content {
  display: flex;
  flex-direction: column;
  gap: 15px;
  justify-content: center;
  padding-right: 125px;
}

.project-card--flip .project-card__content {
  padding-right: 0;
  padding-left: 125px;
}

.project-card--flip .project-card__media { order: -1; }

.project-card__company {
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--gray-label);
}

.project-card__title {
  font-size: 28px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.021em;
  color: var(--ink);
}

.project-card__desc {
  font-size: 19px;
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: -0.03em;
  color: var(--gray-desc);
}

.project-card__media img {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
}

.project-card--flip .project-card__media img { margin-right: auto; }
.project-card:not(.project-card--flip) .project-card__media img { margin-left: auto; }

/* No base transition here — it was overriding .anim entrance fades */
a.project-card:hover { opacity: 0.92; }

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

.site-footer {
  background: #fcfcfc;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 60px 64px;
  font-size: 20px;
  line-height: 1.4;
}

.site-footer__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
}

.site-footer__note { color: #a3adb7; }

.site-footer__links {
  list-style: none;
  display: flex;
  gap: 24px;
}

.site-footer__links a { color: #5b5b5b; }
.site-footer__links a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   1920 breakpoint
   -------------------------------------------------------------------------- */

@media (min-width: 1500px) {
  .hero__inner { max-width: 1500px; }
  .projects { max-width: 1500px; }
  .project-card__content { padding-right: 125px; }
}

/* --------------------------------------------------------------------------
   Tablet (≤ 1024px, designed at 800)
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .hero { padding: 170px 0 140px; }

  .hero__inner { max-width: 794px; padding: 0 24px; }

  .hero__text {
    width: 640px;
    margin-left: 77px;
    font-size: 18px;
  }

  .projects {
    max-width: 800px;
    padding: 70px 100px 150px;
  }

  .project-card__content { padding-right: 50px; }
  .project-card--flip .project-card__content { padding-left: 50px; }

  .project-card__company { font-size: 17px; }
  .project-card__title { font-size: 24px; }
  .project-card__desc { font-size: 16px; }

  /* Tablet footer (241:22114): three centred rows, 18px, 250px tall */
  .site-footer {
    font-size: 18px;
    min-height: 250px;
    padding: 40px 24px 55px;
    gap: 40px;
    align-items: center;
    text-align: center;
  }

  .site-footer__row {
    justify-content: center;
    gap: 40px;
  }

  .site-footer__row:first-child {
    flex-direction: column;
    align-items: center;
  }

  .site-footer__row:last-child { gap: 6px; }

  .site-footer__note { color: #788088; }

  .site-footer__links { gap: 32px; }
}

@media (max-width: 900px) {
  .hero__text { margin-left: 40px; }
  .projects { padding: 60px 60px 140px; }
}

/* --------------------------------------------------------------------------
   Mobile (≤ 640px, designed at 375)
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .site-header { top: 21px; }

  .pill-nav { gap: 14px; }

  .pill-nav__link {
    padding: 8px 12px;
    font-size: 12px;
  }

  .hero { padding: 114px 0 60px; }

  .hero__inner { padding: 0 20px; }

  .hero__text {
    width: 100%;
    margin-left: 0;
    font-size: 15px;
  }

  .projects { padding: 70px 44px 120px; }

  .projects__list { gap: 77px; }

  .project-card {
    grid-template-columns: 1fr;
    gap: 24px;                 /* image -> text */
  }

  /* Mobile: every card is image first, then text (167:3116) */
  .project-card__media,
  .project-card--flip .project-card__media { order: -1; }

  .project-card__content,
  .project-card--flip .project-card__content {
    padding: 0;
    max-width: none;
    gap: 15px;
  }

  .project-card__media img {
    width: 100%;
    max-width: none;
    margin: 0 !important;
  }

  .project-card__company { font-size: 18px; line-height: 1.1; }
  .project-card__title { font-size: 18px; line-height: 1.1; letter-spacing: -0.01em; }
  .project-card__desc { font-size: 13px; line-height: 1.3; }

  .site-footer {
    font-size: 14px;
    gap: 16px;
    padding: 40px 24px;
  }

  .site-footer__row { flex-direction: column; gap: 10px; align-items: flex-start; }
  .site-footer__links { gap: 18px; }
}

/* --------------------------------------------------------------------------
   Mobile bottom menu (.menu-v2) — Figma 299:26569 (default) / 299:26558 (open)
   Visible ≤799. Center with left:50% + negative margin (never translateX(-50%);
   landing fade sets transform:none on .anim--fade).
   -------------------------------------------------------------------------- */

.menu-v2 { display: none; }

@media (max-width: 799px) {
  :root {
    --menu-v2-width: 142px;
    --menu-v2-height: 192px;
    --menu-v2-collapsed-w: 81px;
    --menu-v2-collapsed-h: 44px;
    --menu-v2-spring-w: linear(0, 0.0238 4.43%, 0.0917 8.86%, 0.3441 17.71%, 0.6533 26.57%, 0.9054 35.43%, 1.0638 41.51%, 1.1471 47.59%, 1.1629 50.92%, 1.1595 54.43%, 1.1389 60.69%, 1.0914 67.69%, 1.0452 73.96%, 1.0135 80.22%, 0.9975 87.04%, 0.9953 93.85%, 1);
    --menu-v2-spring-w-retract: linear(0, 0.0238 4.43%, 0.0917 8.86%, 0.3441 17.71%, 0.6533 26.57%, 0.9054 35.43%, 1.024 41.51%, 1.0551 47.59%, 1.0611 50.92%, 1.0599 54.43%, 1.0521 60.69%, 1.0343 67.69%, 1.017 73.96%, 1.0051 80.22%, 0.999 87.04%, 0.9983 93.85%, 1);
    --menu-v2-spring-h: linear(0, 0.0089 2.95%, 0.0349 5.91%, 0.1366 11.81%, 0.2941 17.72%, 0.4884 23.62%, 0.685 29.53%, 0.8503 35.43%, 0.9683 41.34%, 1.0223 47.24%, 1.0402 53.15%, 1.0428 59.05%, 1.0366 64.96%, 1.0269 70.86%, 1.0174 76.77%, 1.0097 82.67%, 1.0046 88.58%, 1.0015 94.48%, 1);
    --menu-v2-spring-h-retract: linear(0, 0.0089 2.95%, 0.0349 5.91%, 0.1366 11.81%, 0.2941 17.72%, 0.4884 23.62%, 0.685 29.53%, 0.8503 35.43%, 0.9683 41.34%, 1.0167 47.24%, 1.0302 53.15%, 1.0321 59.05%, 1.0275 64.96%, 1.0202 70.86%, 1.0131 76.77%, 1.0073 82.67%, 1.0035 88.58%, 1.0011 94.48%, 1);
    --menu-v2-dur-h: 655ms;
    --menu-v2-dur-v: 475ms;
    --menu-v2-dur-h-expand: 590ms;
    --menu-v2-dur-v-expand: 428ms;
  }

  .menu-v2 {
    display: block;
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    right: auto;
    margin-left: calc(var(--menu-v2-collapsed-fit, var(--menu-v2-collapsed-w)) / -2);
    margin-right: 0;
    z-index: 9999;
    width: var(--menu-v2-collapsed-fit, var(--menu-v2-collapsed-w));
    height: var(--menu-v2-collapsed-h);
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #fcfcfc;
    border-radius: 32px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    contain: layout paint;
    will-change: width, height, bottom, margin-left;
    -webkit-tap-highlight-color: transparent;
    --menu-v2-spring-w-active: var(--menu-v2-spring-w-retract);
    --menu-v2-spring-h-active: var(--menu-v2-spring-h-retract);
    --menu-v2-dur-h-active: var(--menu-v2-dur-h);
    --menu-v2-dur-v-active: var(--menu-v2-dur-v);
    transition:
      width var(--menu-v2-dur-h-active) var(--menu-v2-spring-w-active),
      height var(--menu-v2-dur-v-active) var(--menu-v2-spring-h-active),
      bottom var(--menu-v2-dur-v-active) var(--menu-v2-spring-h-active),
      margin-left var(--menu-v2-dur-h-active) var(--menu-v2-spring-w-active),
      background 132ms ease,
      box-shadow 216ms ease,
      opacity 216ms ease;
  }

  .menu-v2.menu-v2--no-anim,
  .menu-v2.menu-v2--no-anim * { transition: none !important; }

  .menu-v2.is-open {
    --menu-v2-spring-w-active: var(--menu-v2-spring-w);
    --menu-v2-spring-h-active: var(--menu-v2-spring-h);
    --menu-v2-dur-h-active: var(--menu-v2-dur-h-expand);
    --menu-v2-dur-v-active: var(--menu-v2-dur-v-expand);
    width: var(--menu-v2-width);
    height: var(--menu-v2-height);
    margin-left: calc(var(--menu-v2-width) / -2);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: #f4f4f5;
  }

  .menu-v2-inner {
    position: absolute;
    bottom: 0;
    left: 50%;
    right: auto;
    width: var(--menu-v2-width);
    margin-left: calc(var(--menu-v2-width) / -2);
    margin-right: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    /* Open Figma uses 24px pad; closed needs 12px bottom so Menu centers in 44px. */
    padding: 24px 32px 12px;
    transition: bottom var(--menu-v2-dur-v-active) var(--menu-v2-spring-h-active);
  }

  /* +12px lifts inner so open bottom pad matches Figma 24px (12 + 12). */
  .menu-v2.is-open .menu-v2-inner { bottom: 12px; }

  .menu-v2-inner > a,
  .menu-v2-trigger {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 400;
    color: #858585;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
    width: 100%;
    padding: 0;
    margin: 0;
    transition: color 264ms ease;
  }

  .menu-v2-trigger {
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
  }

  .menu-v2-inner > a:hover,
  .menu-v2-inner > a:focus-visible { color: #000; }
  .menu-v2-inner > a.active { color: #000; font-weight: 500; }
  .menu-v2-inner > a:focus,
  .menu-v2-trigger:focus { outline: none; }
  .menu-v2:not(.is-open) .menu-v2-trigger { color: #000; }
  .menu-v2.is-open .menu-v2-trigger { color: #858585; }
  .menu-v2:not(.is-open) .menu-v2-inner > a,
  .menu-v2:not(.is-open) .menu-v2-divider { pointer-events: none; }

  .menu-v2-divider {
    display: block;
    width: 24px;
    height: 1px;
    flex-shrink: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(133, 133, 133, 0.35);
  }

  .menu-v2-inner > :nth-last-child(2) { --menu-v2-stagger-i: 0; }
  .menu-v2-inner > :nth-last-child(3) { --menu-v2-stagger-i: 1; }
  .menu-v2-inner > :nth-last-child(4) { --menu-v2-stagger-i: 2; }
  .menu-v2-inner > :nth-last-child(5) { --menu-v2-stagger-i: 3; }
  .menu-v2-inner > :nth-last-child(6) { --menu-v2-stagger-i: 4; }
  .menu-v2-inner > :not(.menu-v2-trigger) {
    opacity: 0;
    transition: opacity .2s ease calc((4 - var(--menu-v2-stagger-i, 0)) * 25ms), color 264ms ease;
  }
  .menu-v2.is-open .menu-v2-inner > :not(.menu-v2-trigger) {
    opacity: 1;
    transition: opacity .2s ease calc(var(--menu-v2-stagger-i, 0) * 25ms), color 264ms ease;
  }

  .menu-v2.scroll-hidden {
    opacity: 0;
    pointer-events: none;
  }

  @media (prefers-reduced-motion: reduce) {
    .menu-v2 { transition: width 216ms ease, height 216ms ease, background 216ms ease; }
    .menu-v2-inner > :not(.menu-v2-trigger),
    .menu-v2.is-open .menu-v2-inner > :not(.menu-v2-trigger) {
      transition: opacity .15s ease, color .15s ease;
    }
  }
}
