/* REM is intentionally scoped only to the typography requested by the client. */
.topbar,
.topbar .brand,
.topbar .brand small,
.topbar nav,
.topbar nav a,
.topbar .menu-toggle,
.hero-role,
.hero-role span,
.hero-actions .btn-primary,
.hero-actions .btn-secondary,
.intro-copy h2,
.experience-grid h2,
.skills-head h2,
.portfolio-head h2,
.contact h2,
.filters button,
.load-more,
button {
  font-family: "REM", sans-serif !important;
}

/* Fine-tuning for REM's proportions and descenders. */
.contact h2 {
  line-height: 1 !important;
  padding-bottom: 0.12em;
}

.contact-label span {
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.experience-grid h2 {
  line-height: 0.96 !important;
}

/* Mobile only: let the animated hero role occupy more of the available line. */
@media (max-width: 600px) {
  .hero-role {
    font-size: min(
      calc(var(--hero-mobile-role-size, 38px) + 5px),
      14vw
    ) !important;
    line-height: 1 !important;
    letter-spacing: -0.065em !important;
  }
}

/* Final mobile hero sizing: preserve a single button row and strengthen both text levels. */
@media (max-width: 600px) {
  .hero .eyebrow {
    font-size: 13px !important;
    line-height: 1.35 !important;
    white-space: pre-line !important;
  }

  .hero-actions {
    width: 100%;
    max-width: none !important;
    flex-wrap: nowrap !important;
    align-items: center;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    flex: 0 0 auto;
    width: auto !important;
    white-space: nowrap;
  }
}

/* Mobile menu: translucent panel reveal followed by a restrained item cascade. */
@media (max-width: 600px) {
  .topbar.open nav {
    align-items: flex-start !important;
    gap: 22px !important;
    padding: 28px var(--pad) 30px !important;
    background: rgba(5, 8, 10, 0.88) !important;
    border-top: 1px solid rgba(255,255,255,.1);
    border-bottom: 1px solid rgba(255,255,255,.1);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transform-origin: top center;
    animation: mobileMenuPanelIn 460ms cubic-bezier(.16,1,.3,1) both;
  }

  .topbar.open nav > a,
  .topbar.open nav > .language-switcher {
    opacity: 0;
    transform: translate3d(-18px,10px,0);
    animation: mobileMenuItemIn 460ms cubic-bezier(.16,1,.3,1) forwards;
  }

  .topbar.open nav > :nth-child(1) { animation-delay: 90ms; }
  .topbar.open nav > :nth-child(2) { animation-delay: 135ms; }
  .topbar.open nav > :nth-child(3) { animation-delay: 180ms; }
  .topbar.open nav > :nth-child(4) { animation-delay: 225ms; }
  .topbar.open nav > :nth-child(5) { animation-delay: 270ms; }
  .topbar.open nav > :nth-child(6) { animation-delay: 315ms; }

  .topbar.open nav > a {
    width: auto !important;
    font-size: 17px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
  }

  .topbar.open nav .nav-cta {
    align-self: flex-start !important;
    padding: 11px 18px !important;
    font-weight: 700 !important;
  }

  .topbar.open .language-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 0 !important;
  }

  .topbar.open .language-switcher button {
    width: 42px !important;
    height: 42px !important;
    font-size: 19px !important;
  }
}

@keyframes mobileMenuPanelIn {
  from { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate3d(0,-10px,0); }
  to { opacity: 1; clip-path: inset(0); transform: translate3d(0,0,0); }
}

@keyframes mobileMenuItemIn {
  to { opacity: 1; transform: translate3d(0,0,0); }
}

@media (max-width: 600px) and (prefers-reduced-motion: reduce) {
  .topbar.open nav,
  .topbar.open nav > a,
  .topbar.open nav > .language-switcher {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }
}

/* Mobile controls: stronger hierarchy and comfortable touch targets. */
@media (max-width: 600px) {
  .menu-toggle {
    min-width: 48px;
    min-height: 48px;
    padding: 10px 0 10px 10px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    min-height: 48px !important;
    padding: 0 18px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
  }

  .topbar.open nav .nav-cta {
    min-height: 48px;
    padding: 13px 20px !important;
    font-size: 17px !important;
  }

  .filters {
    gap: 9px !important;
    padding-bottom: 22px !important;
  }

  .filters button {
    min-height: 44px;
    padding: 11px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap;
  }

  .load-more {
    min-height: 50px;
    padding: 14px 18px !important;
    gap: 34px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
  }

  .load-more b {
    font-size: 20px;
    line-height: 1;
  }

  .contact > a {
    min-height: 64px;
    padding-bottom: 16px !important;
    align-items: center !important;
  }

  .contact-label span {
    font-size: 20px !important;
    font-weight: 700 !important;
  }

  .contact > a > b {
    font-size: 50px !important;
    line-height: .8 !important;
    font-weight: 500 !important;
    transform: none !important;
  }
}

/* Experimental hero motion: overlapping soft-focus letter cascade. */
.hero-role {
  --role-motion-duration: 620ms;
  --role-motion-stagger: 22ms;
  position: relative;
  overflow: hidden;
  font-size: var(--hero-role-fit-size, clamp(48px, 7.5vw, 112px)) !important;
}

.hero-role > #heroTyped {
  position: relative;
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 1.08em;
  overflow: hidden;
  color: #f3a52b;
}

.hero-role > i {
  display: none !important;
}

/* Desktop hero: use one size across translations and keep the full role
   column clear of the portrait. The fit calculation sizes every language
   against its widest phrase. */
@media (min-width: 801px) {
  .hero-content,
  .hero-content.visible {
    right: 46% !important;
    max-width: none !important;
  }

  .hero-role,
  .hero-role > #heroTyped {
    width: 100% !important;
    max-width: 100% !important;
  }
}

.hero-word {
  position: absolute;
  inset: 0 auto auto 0;
  display: flex;
  white-space: nowrap;
  color: inherit;
  pointer-events: none;
  transform: none;
  transform-origin: left center;
}

.hero-letter {
  display: inline-block;
  opacity: 0;
  filter: blur(8px);
  transform: translate3d(0, 72%, 0) rotateX(-42deg);
  transform-origin: 50% 100%;
  will-change: transform, opacity, filter;
}

.hero-word.is-entering .hero-letter {
  animation: heroLetterEnter var(--role-motion-duration) cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--letter-index) * var(--role-motion-stagger));
}

.hero-word.is-current .hero-letter {
  opacity: 1;
  filter: blur(0);
  transform: translate3d(0,0,0) rotateX(0);
}

.hero-word.is-leaving .hero-letter {
  animation: heroLetterLeave 480ms cubic-bezier(.7,0,.84,0) forwards;
  animation-delay: calc(var(--letter-reverse) * 14ms);
}

@keyframes heroLetterEnter {
  0% { opacity: 0; filter: blur(8px); transform: translate3d(0,72%,0) rotateX(-42deg); }
  58% { opacity: 1; }
  100% { opacity: 1; filter: blur(0); transform: translate3d(0,0,0) rotateX(0); }
}

@keyframes heroLetterLeave {
  0% { opacity: 1; filter: blur(0); transform: translate3d(0,0,0) rotateX(0); }
  100% { opacity: 0; filter: blur(7px); transform: translate3d(0,-58%,0) rotateX(34deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-role > #heroTyped { height: auto; overflow: visible; }
}

@media (max-width: 600px) {
  .hero-role {
    font-size: var(
      --hero-role-fit-size,
      min(calc(var(--hero-mobile-role-size, 38px) + 5px), 14vw)
    ) !important;
  }
}

/* Mobile portrait: move the existing composition 20px lower without resizing it. */
@media (max-width: 600px) {
  .hero-portrait-wrap,
  .hero-portrait-wrap.visible {
    transform: translate(-50%, 20px) !important;
  }
}


/* Portfolio 2: full-bleed responsive mosaic; Portfolio 1 remains in the source for quick restoration. */
#portfolio.section { padding-left:0!important; padding-right:0!important; }
#portfolio .portfolio-head { padding-left:var(--site-gutter,var(--pad)); padding-right:var(--site-gutter,var(--pad)); margin-bottom:clamp(28px,4vw,54px); }
#portfolio1[hidden], #portfolio2[hidden] { display:none!important; }
.portfolio2-grid { width:100%; column-count:5; column-gap:0; line-height:0; }
.portfolio2-item { display:block; break-inside:avoid; margin:0; padding:0; width:100%; line-height:0; overflow:visible; background:#171719; cursor:zoom-in; }
.portfolio2-item:focus-visible { position:relative; z-index:2; outline:3px solid var(--lime,#f3a52b); outline-offset:-3px; }
.portfolio2-item img { display:block; width:100%; height:auto; object-fit:contain; margin:0; padding:0; border:0; border-radius:0!important; vertical-align:top; opacity:0; transform:translateY(10px); transition:opacity .55s ease,transform .55s cubic-bezier(.2,.7,.2,1),filter .25s ease; }
.portfolio2-item img.is-loaded { opacity:1; transform:none; }
.portfolio2-item:hover img { filter:brightness(.92); }
.portfolio2-more { display:flex; align-items:center; justify-content:center; gap:10px; margin:34px auto 0!important; min-height:54px; padding:0 28px!important; background:var(--lime,#f3a52b)!important; color:#191a1d!important; border:0!important; font-weight:800!important; }
.portfolio2-more:hover { filter:brightness(1.08); transform:translateY(-2px); }
@media(max-width:1200px){ .portfolio2-grid { column-count:4; } }
@media(max-width:800px){ .portfolio2-grid { column-count:3; } }
@media(max-width:520px){ .portfolio2-grid { column-count:2; } }
.lightbox-count[hidden],.lightbox-zoom[hidden] { display:none!important; }
.lightbox-transition-clone { position:absolute!important; inset:0; z-index:2; width:auto!important; height:auto!important; max-width:100%!important; max-height:100%!important; margin:auto!important; object-fit:contain!important; pointer-events:none; }
@media(prefers-reduced-motion:reduce){ .portfolio2-item img { transition:none; opacity:1; transform:none; } }

/* Portfolio lightbox: retain a subtle view of the page behind the artwork. */
.lightbox { background:rgba(12,13,15,.9)!important; }
.lightbox::backdrop { background:transparent!important; }

/* Portfolio 2 hover: gently enlarge and darken the focused artwork. */
.portfolio2-item { overflow:hidden; }
.portfolio2-item img { transition:opacity .5s ease,transform .55s cubic-bezier(.2,.7,.2,1),filter .3s ease; }
.portfolio2-item:hover img,
.portfolio2-item:focus-visible img { transform:scale(1.04); filter:brightness(.78); }
@media(prefers-reduced-motion:reduce) {
  .portfolio2-item img { transition:none; }
  .portfolio2-item:hover img,
  .portfolio2-item:focus-visible img { transform:none; }
}
