html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  overscroll-behavior: none;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  display: none;
}

main > :first-child {
  margin-top: 0 !important;
}

main > :last-child {
  margin-bottom: 0 !important;
}

:focus-visible {
  outline: 2px solid #9c6455;
  outline-offset: 4px;
}

button,
[role="button"],
a {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Hero portrait framing */
#top .hero-portrait-frame {
  height: clamp(520px, 66vh, 680px);
}

.portrait-motion-pending [data-hero="portrait-enter"] {
  visibility: hidden;
}

#top img[data-hero="portrait"] {
  width: 150%;
  max-width: none;
  max-height: 100%;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center top;
}

/* Selected work cards */
.project-card[hidden] {
  display: none !important;
}

.project-card img {
  transform-origin: center;
  transition: transform 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.project-card:hover img {
  transform: scale(1.04);
}

.gsap-ready .project-card img {
  transition: none;
}

.project-card h3 {
  transition: color 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.project-card:hover h3,
.project-card:focus-within h3 {
  transform: translateX(4px);
}

.project-card button[onclick^="openProjectModal"] span,
.project-card button[data-open-project] span {
  transition: transform 0.25s ease;
}

.project-card:hover button[onclick^="openProjectModal"] span,
.project-card:focus-within button[onclick^="openProjectModal"] span,
.project-card:hover button[data-open-project] span,
.project-card:focus-within button[data-open-project] span {
  transform: translate(2px, -2px);
}

.project-card button[onclick^="openProjectModal"],
.project-card button[data-open-project] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.project-card:hover button[onclick^="openProjectModal"],
.project-card:focus-within button[onclick^="openProjectModal"],
.project-card:hover button[data-open-project],
.project-card:focus-within button[data-open-project] {
  opacity: 1;
  transform: translateY(0);
}

/* Navigation & services */
[data-nav].is-active {
  color: #855143 !important;
  text-decoration: underline;
  text-underline-offset: 5px;
}

.service-detail {
  max-width: 100%;
  overflow: hidden;
}

.service-item {
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.service-item[data-open="true"] {
  border-color: #855143;
  background: rgba(133, 81, 67, 0.035);
}

/* Experience transition & hover preview */
.experience-transition {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    #f9f9f9 0%,
    rgba(249, 249, 249, 0.84) 15%,
    rgba(17, 17, 17, 0) 48%
  );
}

.experience-hover-card {
  position: fixed;
  z-index: 60;
  width: min(18rem, calc(100vw - 2rem));
  padding: 1rem;
  background: #1b1b1b;
  border: 1px solid #393333;
  color: #f9f9f9;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(-200vw, -200vh, 0);
  will-change: transform, opacity;
}

/* Fallback reveal animation */
.fallback-reveal {
  animation: fallback-settle 0.38s ease-out both;
}

@keyframes fallback-settle {
  from {
    transform: translateY(8px);
  }
  to {
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  #work-filters {
    max-width: 100%;
    overflow-x: auto;
  }

  .project-card button {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 767px) {
  #work-filters {
    max-width: 100%;
    overflow-x: auto;
  }

  .project-card button[onclick^="openProjectModal"],
  .project-card button[data-open-project] {
    opacity: 1;
    transform: none;
  }

  .experience-hover-card {
    display: none !important;
  }

  #top .hero-portrait-frame {
    height: min(52vh, 420px);
    min-height: 340px;
  }

  #top img[data-hero="portrait"] {
    width: 166%;
  }
}

@media (hover: none) {
  .project-card button[onclick^="openProjectModal"],
  .project-card button[data-open-project] {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .project-card:hover img {
    transform: none;
  }
}
