/* base.css — shared nav + modal styles (index + aboutme). Edit here once. */

/*
 * NAV: logo + links left, Resume/LinkedIn right.
 * Mobile: hamburger toggles a full-width dropdown; open/close is driven by
 * the checkbox #nav-check (checked = menu open). No JS needed for open/close.
 */
body {
  letter-spacing: 0.04em;
  font-weight: 400;
  font-family:
    Urbanist,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

/* --- Desktop load animation (home page only) ---
 * On first load, nav pill expands from center and items fade in with stagger.
 */
@keyframes navExpandFromCenter {
  from {
    width: 100px;
    max-width: 100px;
  }
  to {
    width: 50%;
    max-width: 1440px;
  }
}

@keyframes navFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (min-width: 769px) {
  body.home .nav {
    animation: navExpandFromCenter 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  body.home .nav-logo-img {
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  body.home .nav-links.nav-links-desktop li:nth-child(1) {
    opacity: 0;
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
  }
  body.home .nav-links.nav-links-desktop li:nth-child(2) {
    opacity: 0;
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) 0.6s forwards;
  }
  body.home .nav-links.nav-links-desktop li:nth-child(3) {
    opacity: 0;
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) 0.7s forwards;
  }
  body.home .nav-right li:nth-child(1) {
    opacity: 0;
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) 0.6s forwards;
  }
  body.home .nav-right li:nth-child(2) {
    opacity: 0;
    animation: navFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
  }
}

/* --- Base nav --- */
.nav {
  --nav-height: 60px;
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 50%;
  max-width: 1440px;
  height: var(--nav-height);
  margin: 42px auto;
  padding: 0 24px;
  border-radius: 1000px;
  background-color: hsla(0, 0%, 100%, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 4px 4px 40px 4px rgba(0, 0, 0, 0.05);
  transition: 0.1s;
}

/* Hidden checkbox: when checked, menu is open. Used by ~ selectors for open state. */
.nav-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-logo {
  display: flex;
  align-items: center;
  padding-right: 12px;
  transition: opacity 0.5s;
}

.nav-logo:hover {
  opacity: 0.5;
}

.nav-logo-img {
  display: block;
  height: 20px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  font-size: 14px;

  color: gray;
  text-decoration: none;
  padding: 0 10px;
  line-height: var(--nav-height);
  transition: color 0.25s;
}

.nav-links a:hover {
  color: black;
}

.nav-links-mobile {
  display: none;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-right {
  list-style: none;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-right a {
  font-size: 14px;

  color: gray;
  text-decoration: none;
  padding: 0 10px;
  line-height: var(--nav-height);
  transition: color 0.25s;
}

.nav-right a:hover {
  color: black;
}

.nav-ext-arrow {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  vertical-align: middle;
  transition: transform 0.3s ease;
  transform-origin: center;
}

a:hover .nav-ext-arrow {
  transform: rotate(22.5deg);
}

.nav-ext-arrow svg {
  display: block;
  color: currentColor;
}

.nav-toggle {
  display: none;
  cursor: pointer;
}

.nav-icon {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 7.5px;
  width: 24px;
  /* height: 26px; */
}

.nav-icon span {
  display: block;
  width: 100%;
  height: 4.5px;
  background: black;
  border-radius: 100px;
  transition:
    transform 0.25s ease-out,
    opacity 0.25s ease-out;
  transform-origin: center;
}

/* Hamburger → X when open (JS adds .open to #nav-icon; mobile also uses :checked ~ .nav-toggle) */
.nav-icon.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-icon.open span:nth-child(2) {
  transform: translateY(-4px) rotate(-45deg);
}

/* --- Mobile: keyframe for each link sliding up + fading in (staggered on open) --- */
@keyframes navMobileLinkIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== MOBILE NAV: OPEN / CLOSE ==========
 * State is driven by #nav-check (checkbox). Label toggles it on tap.
 * OPEN  = .nav-check:checked  (or .nav:has(.nav-check:checked))
 * CLOSED = default
 */

@media (max-width: 1120px) {
  /* Disable desktop load animations on small screens */
  .nav,
  .nav-logo-img,
  .nav-links.nav-links-desktop li,
  .nav-right li {
    animation: none;
    opacity: 1;
  }

  /* ----- Nav bar container (pill) -----
   * CLOSED: pill shape, centered. OPEN: same but border-radius animates to 24px below.
   */
  .nav {
    width: 87%;
    max-width: 87%;
    margin: 4vw auto;
    left: 0;
    right: 0;
    height: auto;
    min-height: var(--nav-height);
    padding-top: var(--nav-height);
    flex-wrap: wrap;
    align-content: flex-start;
    transition:
      background-color 0.5s ease,
      box-shadow 0.3s ease,
      border-radius 0.45s ease-out 0.35s;
  }

  /* OPEN: pill becomes rounded rectangle (border-radius 24px), no delay on close */
  .nav:has(.nav-check:checked) {
    background-color: hsla(0, 0%, 100%, 0.9);
    border-radius: 24px;
    transition:
      background-color 0.5s ease,
      box-shadow 0.3s ease,
      border-radius 0s;
  }

  /* Logo and hamburger stay in top row; hamburger is the toggle (label for #nav-check) */
  .nav-left {
    position: absolute;
    left: 24px;
    top: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
  }

  .nav-toggle {
    position: absolute;
    right: 12px;
    top: 0;
    width: 50px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  /* OPEN: hamburger lines rotate into X */
  .nav-check:checked ~ .nav-toggle .nav-icon span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  .nav-check:checked ~ .nav-toggle .nav-icon span:nth-child(2) {
    transform: translateY(-4px) rotate(-45deg);
  }

  /* ----- Dropdown panel (.nav-menu) -----
   * CLOSED: max-height 0, opacity 0, overflow hidden → panel is collapsed and invisible.
   * Closing: transition runs so panel shrinks and fades out.
   */
  .nav-menu {
    width: 100%;
    flex-basis: 100%;
    order: 2;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    background: transparent;
    box-shadow: none;
    transition:
      max-height 0.35s ease-out,
      opacity 0.3s ease-out;
  }

  /* OPEN: panel expands (max-height 80vh) and fades in; slightly delayed opacity for smooth open */
  .nav-check:checked ~ .nav-menu {
    max-height: 80vh;
    opacity: 1;
    padding: 0 20px 24px;
    transition:
      max-height 1s ease-out,
      opacity 0.5s ease-out 0.2s;
  }

  .nav-links-desktop {
    display: none;
  }

  .nav-links-mobile {
    display: flex;
  }

  /* ----- Link lists inside dropdown -----
   * CLOSED: lists have opacity 0 (panel is hidden anyway).
   * OPEN: opacity 1 after a short delay so they appear as panel opens.
   */
  .nav-menu .nav-links,
  .nav-menu .nav-right {
    flex-direction: column;
    width: 100%;
    gap: 0;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
  }

  .nav-check:checked ~ .nav-menu .nav-links,
  .nav-check:checked ~ .nav-menu .nav-right {
    opacity: 1;
    transition: opacity 0.3s ease-out 0.06s;
  }

  .nav-menu .nav-links li,
  .nav-menu .nav-right li {
    width: 100%;
    text-align: center;
  }

  /* ----- OPEN: links animate in one by one -----
   * Each li runs navMobileLinkIn (fade + slide up). animation-fill-mode: both
   * keeps them invisible until their delay, then visible after the animation.
   * Delays: Experience → Work → About → Resume → LinkedIn.
   */
  .nav-check:checked ~ .nav-menu .nav-links li,
  .nav-check:checked ~ .nav-menu .nav-right li {
    opacity: 0;
    animation: navMobileLinkIn 0.35s ease-out both;
  }
  .nav-check:checked ~ .nav-menu .nav-links li:nth-child(1) {
    animation-delay: 0.05s;
  }
  .nav-check:checked ~ .nav-menu .nav-links li:nth-child(2) {
    animation-delay: 0.1s;
  }
  .nav-check:checked ~ .nav-menu .nav-links li:nth-child(3) {
    animation-delay: 0.15s;
  }
  .nav-check:checked ~ .nav-menu .nav-right li:nth-child(1) {
    animation-delay: 0.2s;
  }
  .nav-check:checked ~ .nav-menu .nav-right li:nth-child(2) {
    animation-delay: 0.25s;
  }

  .nav-menu .nav-links a,
  .nav-menu .nav-right a {
    display: block;
    line-height: 48px;
  }
}
/*
 * Shared modal styles for image lightbox (index + about me).
 */
html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.modal {
  display: flex;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  max-height: 80%;
  max-width: 60%;
  width: auto;
  height: auto;
  border-radius: 2vw;
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.modal-video {
  display: none;
}

.modal.active .modal-content {
  transform: scale(1);
}

@media (max-width: 920px) {
  .modal-content {
    max-height: 85%;
    max-width: 90%;
    border-radius: 12px;
  }
}

/* When image modal is open: lock background scroll (same behaviour as work modal) */
html.image-modal-open,
body.image-modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}
html.image-modal-open {
  height: 100vh;
  width: 100%;
  scroll-behavior: auto !important;
}
body.image-modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  /* top set via JS to -scrollY */
}

/* Work case study modals (beacon, timeline, applemusic) */
.work-modal {
  display: flex;
  position: fixed;
  z-index: 1100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* height: 100vh; */
  overscroll-behavior: contain;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.work-modal.active {
  opacity: 1;
  visibility: visible;
  overflow: hidden;
  /* height: 100vh; */
}

.work-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
}

.work-modal-container {
  position: relative;
  width: 80%;
  max-width: 1400px;
  height: 85vh;
  max-height: 1000px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  overscroll-behavior: contain;
  z-index: 1;
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.work-modal.active .work-modal-container {
  transform: scale(1);
}

.work-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: gray;
  font-size: 32px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: 0.3s ease;
}

.work-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  transition: 0.3s ease;
}

.work-modal-close:focus,
.work-modal-close:active {
  outline: none;
  border: none;
}

.work-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* When work modal is open: lock scroll so iframe link clicks don't scroll background (Safari) */
html.work-modal-open {
  overflow: hidden;
  /* height: 100vh; */
  overscroll-behavior: none;
  scroll-behavior: auto !important;
  /* width: 100%; */
}
/* Body position:fixed prevents background from scrolling when iframe is focused or scroll chains */
body.work-modal-open {
  position: fixed;
  left: 0;
  right: 0;
  /* width: 100%; */
  overflow: hidden;
  overscroll-behavior: none;
  /* top is set via JS to -scrollY so layout doesn't jump */
}
html.work-modal-open::-webkit-scrollbar {
  overflow: hidden;
  /* height: 100vh; */
  overscroll-behavior: none;
  scroll-behavior: auto !important;
  /* width: 100%; */
}

@media (max-width: 920px) {
  .work-modal {
    /* Inset by safe area so modal sits below status/notch and above home indicator */
    top: env(safe-area-inset-top, 0px);
    right: env(safe-area-inset-right, 0px);
    bottom: env(safe-area-inset-bottom, 0px);
    left: env(safe-area-inset-left, 0px);
    width: auto;
    height: auto;
  }
  .work-modal-container {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .work-modal-close {
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    font-size: 26px;
  }
}
