/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, ul, figure { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- Variables ---------- */
:root{
  --black: #050505;
  --charcoal-900: #0c0c0c;
  --charcoal-800: #131313;
  --charcoal-700: #1c1c1c;
  --charcoal-600: #272727;
  --line: rgba(255,255,255,0.09);
  --line-strong: rgba(255,255,255,0.18);
  --grey-500: #6f6f6f;
  --grey-400: #9a9a9a;
  --grey-300: #c6c6c4;
  --off-white: #f3f2ef;
  --white: #ffffff;

  --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --container: 1180px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body{
  background: var(--black);
  color: var(--off-white);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.container{
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
}

section { position: relative; }

/* ---------- Ambient background starfield (persists behind entire page) ---------- */
#bgStars{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}
main, .site-footer{ position: relative; z-index: 1; }

/* ---------- Grain overlay ---------- */
.grain{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Progress bar ---------- */
.progress-bar{
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  z-index: 9999;
  background: transparent;
}
.progress-bar span{
  display: block;
  height: 100%;
  width: 0%;
  background: var(--white);
  transition: width 0.1s linear;
}

/* ---------- Custom cursor ---------- */
.cursor-dot{
  position: fixed;
  top: 0; left: 0;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--white);
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 9997;
  transform: translate(-100px,-100px);
  transition: width 0.3s var(--ease), height 0.3s var(--ease), margin 0.3s var(--ease), opacity 0.3s var(--ease);
}
.cursor-dot.hovering{
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
}
.cursor-dot.clicking{ width: 8px; height: 8px; margin: -4px 0 0 -4px; }
@media (hover: none), (pointer: coarse){
  .cursor-dot{ display:none; }
}

/* ---------- Buttons ---------- */
.btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 2px;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.btn-primary{ background: var(--off-white); color: var(--black); border-color: var(--off-white); }
.btn-primary:hover{ color: var(--off-white); }
.btn-primary::before{
  content:"";
  position:absolute; inset:0;
  background: var(--black);
  transform: translateY(101%);
  transition: transform 0.45s var(--ease);
  z-index: -1;
}
.btn-primary:hover::before{ transform: translateY(0); }

.btn-outline{ border-color: var(--line-strong); color: var(--off-white); }
.btn-outline:hover{ border-color: var(--white); background: rgba(255,255,255,0.06); }

.btn-ghost{ color: var(--off-white); border-bottom: 1px solid var(--line-strong); border-radius: 0; padding: 14px 4px; }
.btn-ghost:hover{ border-color: var(--white); }

/* ---------- Header ---------- */
.site-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  padding: calc(26px + env(safe-area-inset-top, 0px)) 0 26px;
  transition: padding 0.4s var(--ease), background 0.4s var(--ease), border-color 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled{
  padding: calc(16px + env(safe-area-inset-top, 0px)) 0 16px;
  background: rgba(5,5,5,0.75);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.logo{ display: flex; align-items: baseline; gap: 8px; }
.logo-mark{
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
}
.logo-sub{
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--grey-400);
  text-transform: uppercase;
}
.main-nav{ display: flex; gap: 40px; margin-left: auto; margin-right: 40px; }
.main-nav a{
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  color: var(--grey-300);
  position: relative;
  padding-bottom: 4px;
  transition: color 0.3s var(--ease);
}
.main-nav a::after{
  content:"";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--white);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s var(--ease);
}
.main-nav a:hover{ color: var(--white); }
.main-nav a:hover::after{ transform: scaleX(1); transform-origin: left; }
.main-nav a.active{ color: var(--white); }

.nav-dot{
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--white);
  opacity: 0;
  transform: translateX(-50%) scale(0);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.main-nav a.active .nav-dot{ opacity: 1; transform: translateX(-50%) scale(1); }

.nav-cta{ white-space: nowrap; }

.lang-toggle{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}
.lang-sep{ color: var(--grey-500); }
.lang-btn{
  color: var(--grey-500);
  transition: color 0.3s var(--ease);
}
.lang-btn:hover{ color: var(--grey-300); }
.lang-btn.active{ color: var(--white); }
.lang-toggle-mobile{
  font-size: 1rem;
  margin-top: 4px;
}
.lang-toggle-mobile .lang-btn{ font-family: var(--font-body); }

.nav-toggle{
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 26px;
  z-index: 600;
}
.nav-toggle span{
  height: 1px;
  width: 100%;
  background: var(--off-white);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.nav-toggle.open span:nth-child(1){ transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2){ opacity: 0; }
.nav-toggle.open span:nth-child(3){ transform: translateY(-6px) rotate(-45deg); }

.mobile-menu{
  position: fixed;
  inset: 0;
  background: var(--black);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-16px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease), visibility 0.4s;
}
.mobile-menu.open{ opacity: 1; visibility: visible; transform: translateY(0); }
.mobile-menu nav{ display: flex; flex-direction: column; align-items: center; gap: 28px; }
.mobile-menu a{
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-size: 2rem;
  font-style: normal;
}
.mobile-cta{ margin-top: 16px; font-family: var(--font-body); font-style: normal; }

/* ---------- Eyebrow / headings ---------- */
.eyebrow{
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--grey-400);
  margin-bottom: 18px;
}
h2{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.4vw, 3.1rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--white);
  margin-bottom: 28px;
}
h3{
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  color: var(--white);
}

/* ---------- Reveal animation base ---------- */
.reveal, .reveal-lines, .line .reveal-text{
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: var(--d, 0s);
}
.reveal.in-view, .reveal-lines.in-view, .in-view .reveal-text{
  opacity: 1;
  transform: translateY(0);
}
.stagger.in-view .reveal,
.reveal.in-view{ }

/* word-split reveal for reveal-lines headings */
.reveal-lines .word{
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: var(--d, 0s);
}
.reveal-lines{ overflow: hidden; }
.reveal-lines.in-view .word{ opacity: 1; transform: translateY(0); }

/* ---------- Hero ---------- */
.hero{
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, var(--charcoal-800) 0%, var(--black) 68%);
}
#particleCanvas{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-content{
  position: relative;
  z-index: 2;
  padding-top: 40px;
}
.hero-title{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 5.2vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--white);
  margin: 6px 0 32px;
}
.hero-title .line{ display: block; overflow: hidden; }
.hero-title em{ font-style: normal; font-weight: 300; color: var(--grey-300); }
.hero-sub{
  max-width: 560px;
  margin: 0 auto 40px;
  font-size: 1.05rem;
  color: var(--grey-300);
  font-weight: 300;
}
.hero-actions{ display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

.scroll-cue{
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--grey-400);
  z-index: 2;
}
.scroll-cue-line{
  width: 1px;
  height: 36px;
  background: linear-gradient(var(--grey-400), transparent);
  position: relative;
  overflow: hidden;
}
.scroll-cue-line::after{
  content:"";
  position: absolute;
  top: -100%; left: 0;
  width: 100%; height: 100%;
  background: var(--white);
  animation: scrollDrop 2.2s var(--ease) infinite;
}
@keyframes scrollDrop{
  0%{ top: -100%; }
  60%{ top: 100%; }
  100%{ top: 100%; }
}

/* ---------- Capabilities (scroll-pinned word montage) ---------- */
.capabilities{ height: 400vh; }
.capabilities-sticky{
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#capabilitiesCanvas{ position: absolute; inset: 0; width: 100%; height: 100%; }
.capability-word{
  position: absolute;
  letter-spacing: 0.02em;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.8rem);
  color: var(--off-white);
  text-shadow: 0 0 40px rgba(255,255,255,0.25);
  opacity: 0;
  will-change: opacity, transform;
}
.capability-word.pos-tl{ top: 14%; left: 8%; }
.capability-word.pos-tr{ top: 14%; right: 8%; }
.capability-word.pos-bl{ bottom: 16%; left: 8%; }
.capability-word.pos-br{ bottom: 16%; right: 8%; }
.capability-caption{
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  letter-spacing: -0.01em;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: var(--off-white);
  text-shadow: 0 0 34px rgba(255,255,255,0.28);
  opacity: 0;
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}
.capabilities-sticky.caption-visible .capability-caption{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Work (scroll-pinned project reveal) ---------- */
.work{ height: 380vh; }
.work-sticky{
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#workCanvas{ position: absolute; inset: 0; width: 100%; height: 100%; }
.work-eyebrow{
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 2;
}
.project-card{
  position: absolute;
  display: flex;
  align-items: center;
  gap: 56px;
  max-width: 980px;
  width: min(92vw, 980px);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}
.project-card.from-left{ transform: translateX(-60px); }
.project-card.from-right{ transform: translateX(60px); flex-direction: row-reverse; text-align: right; }
.mockup{
  flex: 0 0 auto;
  width: 420px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: var(--charcoal-800);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.mockup-bar{
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.mockup-bar span{ width: 7px; height: 7px; border-radius: 50%; background: var(--charcoal-600); }
.mockup-body{ height: 264px; }
.mockup-body.mockup-photo{ height: auto; animation: none; overflow: hidden; }
.mockup-body.mockup-photo img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.project-tag{
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--off-white);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 6px 14px;
}
.project-info h3{ margin: 18px 0 14px; font-size: clamp(1.45rem, 2.4vw, 1.9rem); line-height: 1.2; }
.project-info p{ color: var(--grey-400); font-size: 0.98rem; max-width: 38ch; }
.project-card.from-right .project-info p{ margin-left: auto; }

@media (max-width: 760px){
  .capabilities{ height: 320vh; }
  .capability-word{ font-size: clamp(1.8rem, 8vw, 2.8rem); }
  .work{ height: 420vh; }
  .project-card, .project-card.from-right{
    flex-direction: column;
    text-align: center;
    gap: 24px;
  }
  .project-card.from-right .project-info p{ margin-left: auto; margin-right: auto; }
  .mockup{ width: 300px; }
}

/* ---------- About ---------- */
.about{ padding: 160px 0; }
.about-inner{ max-width: 760px; }
.about-inner p{ color: var(--grey-300); margin-bottom: 20px; font-size: 1.05rem; max-width: 46ch; }


/* ---------- Services ---------- */
.services{ padding: 160px 0 140px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.service-list{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 20px;
}
.service-card{
  background: var(--charcoal-900);
  padding: 48px 36px;
  transition: background 0.4s var(--ease), transform 0.4s var(--ease);
}
.service-card:hover{ background: var(--charcoal-700); transform: translateY(-4px); }
.service-card h3{ margin-bottom: 16px; font-size: 1.5rem; }
.service-card p{ color: var(--grey-400); font-size: 0.96rem; }

/* ---------- Contact ---------- */
.contact{ padding: 170px 0; text-align: center; }
.contact-inner{ display: flex; flex-direction: column; align-items: center; }
.contact-email-row{ display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.contact-email{
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.8vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--white);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
  word-break: break-word;
}
.contact-email:hover{ border-color: var(--white); color: var(--grey-300); }
.copy-btn{
  width: 42px; height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--grey-300);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
  flex-shrink: 0;
}
.copy-btn:hover{ border-color: var(--white); color: var(--white); background: rgba(255,255,255,0.06); }
.contact-hint{ margin-top: 16px; font-size: 0.8rem; color: var(--grey-500); }

.contact-meta{
  display: flex;
  gap: 70px;
  margin-top: 80px;
  padding-top: 50px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
  justify-content: center;
}
.contact-meta > div{ display: flex; flex-direction: column; gap: 10px; min-width: 160px; }
.contact-meta span{ font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--grey-500); }
.contact-meta a, .contact-meta p{ color: var(--off-white); font-size: 1rem; }
.contact-meta a:hover{ color: var(--grey-300); }

/* ---------- Footer ---------- */
.site-footer{ border-top: 1px solid var(--line); padding: 30px 0; }
.footer-inner{
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--grey-500);
  letter-spacing: 0.03em;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px){
  .service-list{ grid-template-columns: 1fr; }
  }

@media (max-width: 860px){
  .main-nav, .nav-cta{ display: none; }
  .nav-toggle{ display: flex; }
}

@media (max-width: 600px){
  .about{ padding: 110px 0; }
  .services{ padding: 110px 0; }
  .contact{ padding: 120px 0; }
  .contact-meta{ gap: 40px; }
  .container{ padding: 0 22px; }
}

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  .reveal, .reveal-lines, .reveal-lines .word, .line .reveal-text{
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .capabilities, .work{ height: auto; }
  .capabilities-sticky, .work-sticky{
    position: relative;
    height: auto;
    flex-direction: column;
    gap: 60px;
    padding: 100px 24px;
  }
  .capability-word, .project-card, .capability-caption{
    position: relative;
    inset: auto;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto;
  }
  .project-card, .project-card.from-right{ flex-direction: column; text-align: center; }
}

/* ---------- Telemóvel: ajustes finos ---------- */
@media (max-width: 760px){
  .capability-word, .capability-word.pos-tl, .capability-word.pos-tr,
  .capability-word.pos-bl, .capability-word.pos-br{
    top: 50%; bottom: auto; left: 0; right: 0;
    margin-top: -0.6em;
    text-align: center;
    padding: 0 16px;
    font-size: clamp(1.6rem, 7.6vw, 2.5rem);
  }
  .capability-caption{ width: 88%; text-align: center; bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
  .work-eyebrow{ top: calc(92px + env(safe-area-inset-top, 0px)); white-space: nowrap; }
  .project-card, .project-card.from-right{ width: 88vw; }
  .mockup{ width: min(86vw, 340px); }
  .project-info h3{ margin: 14px 0 10px; font-size: 1.3rem; }
  .project-info p{ font-size: 0.92rem; margin-left: auto; margin-right: auto; }
}
@media (max-width: 600px){
  .site-header{ padding-bottom: 18px; }
  .hero-content{ padding-top: 70px; }
  .hero-title{ font-size: clamp(2rem, 9.2vw, 2.9rem); }
  .hero-sub{ font-size: 1rem; padding: 0 4px; }
  .hero-actions{ gap: 14px; }
  .hero-actions .btn-primary{ padding: 14px 24px; }
  .scroll-cue{ bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .about-inner p{ font-size: 1rem; }
  .service-card{ padding: 36px 24px; }
  .contact-email{ font-size: clamp(1rem, 5.2vw, 1.5rem); }
  .contact-meta{ margin-top: 56px; padding-top: 40px; gap: 32px; }
  .site-footer{ padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px)); }
  .footer-inner{ flex-direction: column; gap: 6px; }
}

.hero-title, .hero-sub{ text-shadow: 0 2px 24px rgba(0,0,0,0.7); }
